Scribus
Open source desktop publishing at your fingertips
pconsole.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /*
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12 */
13 
14 #ifndef PCONSOLE_H
15 #define PCONSOLE_H
16 
17 #include <QLabel>
18 #include <QMainWindow>
19 #include <QSyntaxHighlighter>
20 #include "ui_pconsole.h"
21 
22 
28 class PythonConsole : public QMainWindow, public Ui::PythonConsole
29 {
30  Q_OBJECT
31 
32  public:
33  PythonConsole( QWidget* parent = 0);
34  ~PythonConsole();
35 
36  void setFonts();
37 
40  QString command() { return m_command; };
42  QString filename;
43 
45  void closeEvent(QCloseEvent *);
46 
47  void updateSyntaxHighlighter();
48 
49  public slots:
51  virtual void slot_runScript();
52  virtual void slot_runScriptAsConsole();
53  virtual void slot_open();
54  virtual void slot_save();
55  virtual void slot_saveAs();
56  virtual void slot_saveOutput();
57  virtual void slot_quit();
60  virtual void commandEdit_cursorPositionChanged();
61 
62  signals:
64  void paletteShown(bool);
66  void runCommand();
67 
68  protected:
70  void parsePythonString();
71 
73  QString m_command;
74 
75  QLabel * changedLabel;
76  QLabel * cursorLabel;
77  QString cursorTemplate;
78 
79  protected slots:
80  virtual void languageChange();
81  void documentChanged(bool state);
82 
83 };
84 
89 {
90  public:
91  SyntaxColors();
92 
93  QColor errorColor;
94  QColor commentColor;
95  QColor keywordColor;
96  QColor signColor;
97  QColor numberColor;
98  QColor stringColor;
99  QColor textColor;
100 
101  void saveToPrefs();
102 
103  private:
106  QString qcolor2named(QColor color);
107 };
108 
116 class SyntaxHighlighter : public QSyntaxHighlighter
117 {
118  public:
119  SyntaxHighlighter(QTextEdit *textEdit);
120 
121  protected:
122  virtual void highlightBlock(const QString &text);
123 
125  {
126  QRegExp pattern;
127  QTextCharFormat format;
128  };
129  QVector<HighlightingRule> highlightingRules;
130 
131  QTextCharFormat keywordFormat;
132  QTextCharFormat singleLineCommentFormat;
133  QTextCharFormat quotationFormat;
134  QTextCharFormat numberFormat;
135  QTextCharFormat operatorFormat;
136 
137  SyntaxColors colors;
138 
139 };
140 
141 #endif
This is simple "IDE"/python console for interactive commands execution. It's used e...
Definition: pconsole.h:28
void runCommand()
Scripter Core launcher.
void paletteShown(bool)
Menu indication trigger.
QString m_command
String with the script to run (part of the all text)
Definition: pconsole.h:73
virtual void slot_runScript()
menu operations
Definition: pconsole.cpp:125
Simple syntax highlighting for Scripter (QTextEdit). Based on the source of the Sqliteman and Qt4 exa...
Definition: pconsole.h:116
Definition: pconsole.h:124
QString command()
The command string.
Definition: pconsole.h:40
QString filename
File name for saving the contents.
Definition: pconsole.h:40
Store colors for syntax highligter. It provides defaults, loading and storing preferences.
Definition: pconsole.h:88
void closeEvent(QCloseEvent *)
Close event for turning the action off.
Definition: pconsole.cpp:99
void parsePythonString()
prepare Python "script" from GUI widget
Definition: pconsole.cpp:160
virtual void commandEdit_cursorPositionChanged()
Slot processed after user change cursor postion in "programmer's editor".
Definition: pconsole.cpp:104