qscimacro.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // This defines the interface to the QsciMacro class.
  2. //
  3. // Copyright (c) 2023 Riverbank Computing Limited <[email protected]>
  4. //
  5. // This file is part of QScintilla.
  6. //
  7. // This file may be used under the terms of the GNU General Public License
  8. // version 3.0 as published by the Free Software Foundation and appearing in
  9. // the file LICENSE included in the packaging of this file. Please review the
  10. // following information to ensure the GNU General Public License version 3.0
  11. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  12. //
  13. // If you do not wish to use this file under the terms of the GPL version 3.0
  14. // then you may purchase a commercial license. For more information contact
  15. // [email protected].
  16. //
  17. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  18. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. #ifndef QSCIMACRO_H
  20. #define QSCIMACRO_H
  21. #include <QList>
  22. #include <QObject>
  23. #include <QString>
  24. #include <Qsci/qsciglobal.h>
  25. class QsciScintilla;
  26. enum USER_DEFINE_MACRO {
  27. MACRO_FIND_NEXT = 5000,//查找下一个
  28. MACRO_REPLACE_ALL,//全部替换
  29. MACRO_REPLACE_ONE,//替换一条
  30. MACRO_EXE_MENU_FUN,//执行菜单栏上面的命令
  31. };
  32. //! \brief The QsciMacro class represents a sequence of recordable editor
  33. //! commands.
  34. //!
  35. //! Methods are provided to convert convert a macro to and from a textual
  36. //! representation so that they can be easily written to and read from
  37. //! permanent storage.
  38. class QSCINTILLA_EXPORT QsciMacro : public QObject
  39. {
  40. Q_OBJECT
  41. public:
  42. //! Construct a QsciMacro with parent \a parent.
  43. QsciMacro(QsciScintilla *parent);
  44. //! Construct a QsciMacro from the printable ASCII representation \a asc,
  45. //! with parent \a parent.
  46. QsciMacro(const QString &asc, QsciScintilla *parent);
  47. //! Destroy the QsciMacro instance.
  48. virtual ~QsciMacro();
  49. //! Clear the contents of the macro.
  50. void clear();
  51. //! Load the macro from the printable ASCII representation \a asc. Returns
  52. //! true if there was no error.
  53. //!
  54. //! \sa save()
  55. bool load(const QString &asc);
  56. //! Return a printable ASCII representation of the macro. It is guaranteed
  57. //! that only printable ASCII characters are used and that double quote
  58. //! characters will not be used.
  59. //!
  60. //! \sa load()
  61. QString save() const;
  62. //signals:
  63. // //从外部调用记录宏,非qscintilla内部宏
  64. // void s_record(unsigned int msg, unsigned long wParam, void* lParam);
  65. public slots:
  66. //! Play the macro.
  67. virtual void play();
  68. //! Start recording user commands and add them to the macro.
  69. virtual void startRecording();
  70. //! Stop recording user commands.
  71. virtual void endRecording();
  72. private slots:
  73. void record(unsigned int msg, unsigned long wParam, void *lParam);
  74. private:
  75. struct Macro {
  76. unsigned int msg;
  77. unsigned long wParam;
  78. QByteArray text;
  79. };
  80. QsciScintilla *qsci;
  81. QList<Macro> macro;
  82. QsciMacro(const QsciMacro &);
  83. QsciMacro &operator=(const QsciMacro &);
  84. };
  85. #endif