qscimacro.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // This defines the interface to the QsciMacro class.
  2. //
  3. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  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. // info@riverbankcomputing.com.
  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. //! \brief The QsciMacro class represents a sequence of recordable editor
  27. //! commands.
  28. //!
  29. //! Methods are provided to convert convert a macro to and from a textual
  30. //! representation so that they can be easily written to and read from
  31. //! permanent storage.
  32. class QSCINTILLA_EXPORT QsciMacro : public QObject
  33. {
  34. Q_OBJECT
  35. public:
  36. //! Construct a QsciMacro with parent \a parent.
  37. QsciMacro(QsciScintilla *parent);
  38. //! Construct a QsciMacro from the printable ASCII representation \a asc,
  39. //! with parent \a parent.
  40. QsciMacro(const QString &asc, QsciScintilla *parent);
  41. //! Destroy the QsciMacro instance.
  42. virtual ~QsciMacro();
  43. //! Clear the contents of the macro.
  44. void clear();
  45. //! Load the macro from the printable ASCII representation \a asc. Returns
  46. //! true if there was no error.
  47. //!
  48. //! \sa save()
  49. bool load(const QString &asc);
  50. //! Return a printable ASCII representation of the macro. It is guaranteed
  51. //! that only printable ASCII characters are used and that double quote
  52. //! characters will not be used.
  53. //!
  54. //! \sa load()
  55. QString save() const;
  56. public slots:
  57. //! Play the macro.
  58. virtual void play();
  59. //! Start recording user commands and add them to the macro.
  60. virtual void startRecording();
  61. //! Stop recording user commands.
  62. virtual void endRecording();
  63. private slots:
  64. void record(unsigned int msg, unsigned long wParam, void *lParam);
  65. private:
  66. struct Macro {
  67. unsigned int msg;
  68. unsigned long wParam;
  69. QByteArray text;
  70. };
  71. QsciScintilla *qsci;
  72. QList<Macro> macro;
  73. QsciMacro(const QsciMacro &);
  74. QsciMacro &operator=(const QsciMacro &);
  75. };
  76. #endif