1 // 2 // Description: Kate Plugin for GDB integration 3 // 4 // 5 // SPDX-FileCopyrightText: 2010 Ian Wakeling <ian.wakeling@ntlworld.com> 6 // SPDX-FileCopyrightText: 2010-2014 Kåre Särs <kare.sars@iki.fi> 7 // 8 // SPDX-License-Identifier: LGPL-2.0-only 9 10 #ifndef PLUGIN_KATEGDB_H 11 #define PLUGIN_KATEGDB_H 12 13 #include <QPointer> 14 15 #include <KActionMenu> 16 #include <KTextEditor/Application> 17 #include <KTextEditor/MainWindow> 18 #include <KTextEditor/Message> 19 #include <KTextEditor/Plugin> 20 #include <KTextEditor/SessionConfigInterface> 21 #include <KXMLGUIClient> 22 23 #include "configview.h" 24 #include "debugview.h" 25 #include "ioview.h" 26 #include "localsview.h" 27 28 class KHistoryComboBox; 29 class QTextEdit; 30 class QTreeWidget; 31 32 typedef QList<QVariant> VariantList; 33 34 class KatePluginGDB : public KTextEditor::Plugin 35 { 36 Q_OBJECT 37 38 public: 39 explicit KatePluginGDB(QObject *parent = nullptr, const VariantList & = VariantList()); 40 ~KatePluginGDB() override; 41 42 QObject *createView(KTextEditor::MainWindow *mainWindow) override; 43 }; 44 45 class KatePluginGDBView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface 46 { 47 Q_OBJECT 48 Q_INTERFACES(KTextEditor::SessionConfigInterface) 49 50 public: 51 KatePluginGDBView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWin); 52 ~KatePluginGDBView() override; 53 54 // reimplemented: read and write session config 55 void readSessionConfig(const KConfigGroup &config) override; 56 void writeSessionConfig(KConfigGroup &config) override; 57 58 private Q_SLOTS: 59 void slotDebug(); 60 void slotRestart(); 61 void slotToggleBreakpoint(); 62 void slotMovePC(); 63 void slotRunToCursor(); 64 void slotGoTo(const QUrl &fileName, int lineNum); 65 void slotValue(); 66 67 void aboutToShowMenu(); 68 void slotBreakpointSet(const QUrl &file, int line); 69 void slotBreakpointCleared(const QUrl &file, int line); 70 void slotSendCommand(); 71 void enableDebugActions(bool enable); 72 void programEnded(); 73 void gdbEnded(); 74 75 void insertStackFrame(QString const &level, QString const &info); 76 void stackFrameChanged(int level); 77 void stackFrameSelected(); 78 79 void insertThread(int number, bool active); 80 void threadSelected(int thread); 81 82 void showIO(bool show); 83 void addOutputText(QString const &text); 84 void addErrorText(QString const &text); 85 void clearMarks(); 86 void handleEsc(QEvent *e); 87 88 protected: 89 bool eventFilter(QObject *obj, QEvent *ev) override; 90 91 private: 92 QString currentWord(); 93 94 void displayMessage(const QString &message, KTextEditor::Message::MessageType level); 95 96 KTextEditor::Application *m_kateApplication; 97 KTextEditor::MainWindow *m_mainWin; 98 std::unique_ptr<QWidget> m_toolView; 99 std::unique_ptr<QWidget> m_localsStackToolView; 100 QTabWidget *m_tabWidget; 101 QTextEdit *m_outputArea; 102 KHistoryComboBox *m_inputArea; 103 QWidget *m_gdbPage; 104 QComboBox *m_threadCombo; 105 int m_activeThread; 106 QTreeWidget *m_stackTree; 107 QString m_lastCommand; 108 DebugView *m_debugView; 109 ConfigView *m_configView; 110 std::unique_ptr<IOView> m_ioView; 111 LocalsView *m_localsView; 112 QPointer<KActionMenu> m_menu; 113 QAction *m_breakpoint; 114 QUrl m_lastExecUrl; 115 int m_lastExecLine; 116 int m_lastExecFrame; 117 bool m_focusOnInput; 118 QPointer<KTextEditor::Message> m_infoMessage; 119 }; 120 121 #endif 122