5 #ifndef BALL_VIEW_WIDGETS_PYWIDGET_H 6 #define BALL_VIEW_WIDGETS_PYWIDGET_H 12 #ifndef BALL_DATATYPE_STRING_H 16 #ifndef BALL_VIEW_WIDGETS_DOCKWIDGET_H 20 #ifndef BALL_VIEW_WIDGETS_TEXTEDITORWIDGET_H 24 #include <QtGui/QDragEnterEvent> 25 #include <QtGui/QKeyEvent> 26 #include <QtGui/QDropEvent> 27 #include <QtWidgets/QLineEdit> 28 #include <QtWidgets/QComboBox> 29 #include <QtWidgets/QTabWidget> 30 #include <QtGui/QSyntaxHighlighter> 31 #include <QtGui/QValidator> 32 #include <QtCore/QStringList> 34 #include <QtCore/QThread> 44 class RunPythonThread;
58 void compilePattern();
59 void highlightBlock(
const QString& text);
83 virtual State validate(QString& input,
int& pos)
const;
107 bool& ok,
String comment =
"");
122 bool set(
const String& data);
125 void get(
String& data)
const;
149 void setPyWidget(
PyWidget* pw) { pw_ = pw;}
153 virtual void keyPressEvent(QKeyEvent* event);
165 void setPyWidget(
PyWidget* pw) { pw_ = pw;}
169 virtual void keyPressEvent(QKeyEvent* event);
174 friend class MyLineEdit;
210 virtual void initializeWidget(
MainControl& main_control);
214 virtual void finalizeWidget(
MainControl& main_control);
217 void initializePreferencesTab(
Preferences &preferences);
220 void finalizePreferencesTab(
Preferences &preferences);
223 virtual void applyPreferences();
226 virtual void scriptDialog(
bool run =
false);
229 bool toAbortScript();
241 void insertHotkey(
const Hotkey& hotkey);
244 void removeHotkey(
const Hotkey& hotkey);
247 void reactTo(
const QKeyEvent& e);
254 virtual bool canHandle(
const String& fileformat)
const;
260 virtual bool openFile(
const String& filename);
265 bool openFile(
const String& filename,
bool run,
bool is_current =
false);
268 bool runString(
String command);
271 String getCurrentLine()
const;
274 void dump(std::ostream& s,
Size depth)
const;
280 virtual void fetchPreferences(
INIFile& inifile);
283 virtual void writePreferences(
INIFile& inifile);
289 QString getCurrentScript();
292 bool isInDirectMode()
const;
297 void showEditContextMenu(
const QPoint& point);
300 void showContextMenu(
const QPoint& point);
303 void showCompletion();
309 void exportHistory();
318 bool runCurrentScript();
332 virtual void hotkeyItem();
334 virtual void modifyHotkeys();
336 void appendText(
const String& text,
bool output =
false,
bool state_message =
false);
338 bool getMembers(
const String& classname, QStringList& sl,
const String& prefix);
342 virtual bool returnPressed();
344 virtual bool completionSelected_();
349 virtual void printCursorPosition_();
351 virtual void createScript_();
353 virtual void clearHistory_();
357 bool getClassAndMember_(
String toc);
359 void setError_(
bool state);
366 virtual void startInterpreter();
368 virtual void paste();
371 bool parseLine_(
String line);
373 void appendToHistory_(
const String& line);
382 bool testMultilineStart_(
const String& line);
385 const char* getPrompt_()
const;
401 void retrieveHistoryLine_(
Position index);
403 virtual void contentsDragEnterEvent(QDragEnterEvent* e);
405 virtual void contentsDropEvent(QDropEvent* e);
407 bool keyPressed(QKeyEvent* e);
412 void findError_(
String result);
414 String getCurrentWord_(QTextCursor& text_cursor);
416 QComboBox* getCompletionBox_();
418 std::list<Hotkey>::iterator findKey_(
Hotkey& hotkey);
458 #endif // BALL_VIEW_WIDGETS_PYWIDGET_H
#define BALL_EMBEDDABLE(TYPE, BASE)
std::list< Hotkey > hotkeys_
vector< QRegExp > BALL_patterns
QStringList BALL_keywords
Position history_position_
QTextCharFormat comment_format
QComboBox * editor_combo_box_
QStringList python_keywords
TextEditorWidget * text_edit_
QTextCharFormat python_format
vector< String > history_
QTextCharFormat string_format
RunPythonThread * thread_
QTextCharFormat my_class_format
Preferences * preferences_
BALL_EXPORT bool operator<(const String &s1, const String &s2)
Qt::KeyboardModifiers button_state
PythonValidator validator_
PythonHighlighter highlighter_2_
vector< QRegExp > python_patterns
PythonSettings * python_settings_
BALL_EXPORT bool operator==(const String &s1, const String &s2)
bool started_startup_script_
bool isValid() const
Is full Python support available?
MyTextEdit * script_edit_