| 1 | /**************************************************************************** |
| 2 | ** SASM - simple IDE for assembler development |
| 3 | ** Copyright (C) 2013 Dmitriy Manushin |
| 4 | ** Contact: site: http://dman95.github.io/SASM/ |
| 5 | ** e-mail: [email protected] |
| 6 | ** |
| 7 | ** This file is part of SASM. |
| 8 | ** |
| 9 | ** SASM is free software: you can redistribute it and/or modify |
| 10 | ** it under the terms of the GNU General Public License as published by |
| 11 | ** the Free Software Foundation, either version 3 of the License, or |
| 12 | ** (at your option) any later version. |
| 13 | ** |
| 14 | ** SASM is distributed in the hope that it will be useful, |
| 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | ** GNU General Public License for more details. |
| 18 | ** |
| 19 | ** You should have received a copy of the GNU General Public License |
| 20 | ** along with SASM. If not, see <http://www.gnu.org/licenses/>. |
| 21 | ** |
| 22 | ** Этот файл — часть SASM. |
| 23 | ** |
| 24 | ** SASM - свободная программа: вы можете перераспространять ее и/или |
| 25 | ** изменять ее на условиях Стандартной общественной лицензии GNU в том виде, |
| 26 | ** в каком она была опубликована Фондом свободного программного обеспечения; |
| 27 | ** либо версии 3 лицензии, либо (по вашему выбору) любой более поздней |
| 28 | ** версии. |
| 29 | ** |
| 30 | ** SASM распространяется в надежде, что она будет полезной, |
| 31 | ** но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА |
| 32 | ** или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Подробнее см. в Стандартной |
| 33 | ** общественной лицензии GNU. |
| 34 | ** |
| 35 | ** Вы должны были получить копию Стандартной общественной лицензии GNU |
| 36 | ** вместе с этой программой. Если это не так, см. |
| 37 | ** <http://www.gnu.org/licenses/>.) |
| 38 | ** |
| 39 | ****************************************************************************/ |
| 40 | |
| 41 | #ifndef RUQPLAINTEXTEDIT_H |
| 42 | #define RUQPLAINTEXTEDIT_H |
| 43 | |
| 44 | #include <QPlainTextEdit> |
| 45 | #include <QAction> |
| 46 | #include <QMenu> |
| 47 | #include <QContextMenuEvent> |
| 48 | #include <QTextBlock> |
| 49 | #include <QTextStream> |
| 50 | #include <QPointer> |
| 51 | #include <QSettings> |
| 52 | #include "common.h" |
| 53 | |
| 54 | /** |
| 55 | * @file ruqplaintextedit.h |
| 56 | * Text editor base class definition file. |
| 57 | */ |
| 58 | |
| 59 | |
| 60 | /*! \brief This defines the base class which the text editor is derived from. |
| 61 | * |
| 62 | * The class contains methods that are used in the editor. These range from simple |
| 63 | * copying and pasting to enabling/disabling the debugger. |
| 64 | */ |
| 65 | |
| 66 | class RuQPlainTextEdit : public QPlainTextEdit |
| 67 | { |
| 68 | Q_OBJECT |
| 69 | |
| 70 | public: |
| 71 | //! The class constructor creates the editor, given a specified parent QWidget object. |
| 72 | RuQPlainTextEdit(QWidget *parent = 0); |
| 73 | ~RuQPlainTextEdit(); |
| 74 | |
| 75 | //! Creates a menu |
| 76 | QMenu *createMenu(); |
| 77 | |
| 78 | //! Defines a structure to keep track of a watched variable. |
| 79 | struct Watch { |
| 80 | QString name; |
| 81 | int type; |
| 82 | int size; |
| 83 | int arraySize; |
| 84 | bool address; |
| 85 | }; |
| 86 | |
| 87 | protected: |
| 88 | void contextMenuEvent(QContextMenuEvent *e); |
| 89 | |
| 90 | private: |
| 91 | RuQPlainTextEdit::Watch variableOnCurrentLine(); |
| 92 | |
| 93 | QPointer<QMenu> contextMenu; |
| 94 | //! Creates a comment |
| 95 | QAction *commentAction; |
| 96 | //! Removes a comment |
| 97 | QAction *uncommentAction; |
| 98 | //! Undo the last action |
| 99 | QAction *undoAction; |
| 100 | //! Do the previous action again. |
| 101 | QAction *redoAction; |
| 102 | //! Cut a selected text string. |
| 103 | QAction *cutAction; |
| 104 | //! Copy a selected text string. |
| 105 | QAction *copyAction; |
| 106 | //! Paste the clipboard contents. |
| 107 | QAction *pasteAction; |
| 108 | //! Delete a selected text string. |
| 109 | QAction *deleteAction; |
| 110 | //! Select all of the text. |
| 111 | QAction *selectAllAction; |
| 112 | //! Add a watch on a variable. |
| 113 | QAction *addWatchAction; |
| 114 | //! Used to keep track if the debugger is enabled. |
| 115 | bool debugEnabled; |
| 116 | |
| 117 | public slots: |
| 118 | //! Method that comments the user selected code. |
| 119 | void commentSelectedCode(); |
| 120 | //! Method for uncommenting a previously commented code block. |
| 121 | void uncommentSelectedCode(); |
| 122 | |
| 123 | void deleteSelected(); |
| 124 | //! Method for adding a variable watch. |
| 125 | void addWatch(); |
| 126 | //! Used to enable the debugger. |
| 127 | void setDebugEnabled(); |
| 128 | //! Used to disable the debugger. |
| 129 | void setDebugDisabled(); |
| 130 | |
| 131 | signals: |
| 132 | //! Signal which emited when watch variable action is selected. |
| 133 | void addWatchSignal(RuQPlainTextEdit::Watch variable); |
| 134 | }; |
| 135 | |
| 136 | #endif // RUQPLAINTEXTEDIT_H |