Rev 2600 | Rev 2957 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2503 | subik | 1 | /* |
2 | This program is free software; you can redistribute it and/or modify |
||
3 | it under the terms of the GNU General Public License as published by |
||
4 | the Free Software Foundation; either version 2 of the License, or |
||
5 | (at your option) any later version. |
||
6 | */ |
||
7 | |||
82 | Franz | 8 | #ifndef PCONSOLE_H |
9 | #define PCONSOLE_H |
||
10 | |||
11 | #include <qvariant.h> |
||
12 | #include <qlayout.h> |
||
13 | #include <qtooltip.h> |
||
14 | #include <qwhatsthis.h> |
||
2503 | subik | 15 | #include <qsyntaxhighlighter.h> |
82 | Franz | 16 | |
2503 | subik | 17 | class QVBoxLayout; |
18 | class QHBoxLayout; |
||
19 | class QGridLayout; |
||
20 | class QSpacerItem; |
||
21 | class QListView; |
||
22 | class QListViewItem; |
||
23 | class QTextEdit; |
||
24 | class QMenuBar; |
||
25 | |||
26 | /*! This is simple "IDE"/python console for interactive commands execution. |
||
27 | It's used e.g. like Tora (SQLnavigator) console. Sample: highlight some code, |
||
28 | press F9, then see the results. |
||
29 | \author Petr Vanek <petr@yarpen.cz> |
||
30 | */ |
||
31 | class PythonConsole : public QWidget |
||
32 | { |
||
2226 | cbradney | 33 | Q_OBJECT |
82 | Franz | 34 | |
2503 | subik | 35 | public: |
36 | PythonConsole( QWidget* parent = 0); |
||
37 | ~PythonConsole(); |
||
82 | Franz | 38 | |
2503 | subik | 39 | //! String with the script to run (part of the all text) |
40 | QString command; |
||
41 | //! File name for saving the contents |
||
42 | QString filename; |
||
43 | |||
44 | //! Programmer's editor ;) |
||
45 | QTextEdit* commandEdit; |
||
46 | //! Results viewer |
||
47 | QTextEdit* outputEdit; |
||
2614 | subik | 48 | |
2600 | cbradney | 49 | //! Close event for turning the action off |
50 | void closeEvent(QCloseEvent *); |
||
2503 | subik | 51 | |
52 | public slots: |
||
53 | //! menu operations |
||
54 | virtual void slot_runScript(); |
||
2614 | subik | 55 | virtual void slot_runScriptAsConsole(); |
2503 | subik | 56 | virtual void slot_open(); |
57 | virtual void slot_save(); |
||
58 | virtual void slot_saveAs(); |
||
59 | virtual void slot_saveOutput(); |
||
60 | virtual void slot_quit(); |
||
61 | |||
62 | signals: |
||
63 | //! Menu indication trigger |
||
1269 | cbradney | 64 | void paletteShown(bool); |
2503 | subik | 65 | //! Scripter Core launcher |
66 | void runCommand(); |
||
82 | Franz | 67 | |
2503 | subik | 68 | protected: |
69 | QGridLayout* gridLayout; |
||
70 | QVBoxLayout* editorsLayout; |
||
71 | QMenuBar* menuBar; |
||
72 | |||
73 | protected slots: |
||
74 | virtual void languageChange(); |
||
75 | |||
82 | Franz | 76 | }; |
77 | |||
2503 | subik | 78 | /*! Simple syntax highlighting for Scripter (QTextEdit). |
79 | Based on the source of the Python Realizer (http://www.python-realizer.net) |
||
80 | but very simplifier. Improved too (of course). |
||
2543 | subik | 81 | TODO: colors of the higlited texts. User should set the colors in the |
82 | preferences. Waiting for the new plugin API. |
||
2503 | subik | 83 | \author Petr Vanek, <petr@yarpen.cz> |
2543 | subik | 84 | \author Richard Magnor Stenbro <stenbror@hotmail.com> |
2503 | subik | 85 | */ |
86 | class SyntaxHighlighter : public QSyntaxHighlighter |
||
87 | { |
||
88 | public: |
||
89 | SyntaxHighlighter(QTextEdit *textEdit); |
||
90 | |||
91 | /*! Reimplementation of the Qt highligtion for python. |
||
92 | \param text string (one row) provided by text editor via QSyntaxHighlighter inheritance. |
||
93 | \param endStateOfLastPara how is the syntax left for next paragraph? 0 - normal text, 1 - multirows comment continues |
||
94 | */ |
||
95 | int highlightParagraph(const QString &text, int endStateOfLastPara); |
||
96 | |||
97 | private: |
||
98 | //! Reserved python keywords |
||
99 | QStringList keywords; |
||
100 | |||
101 | }; |
||
102 | |||
82 | Franz | 103 | #endif // PCONSOLE_H |