Editor widget with support for evaluating expressions and executing code. More...
#include <ScriptEdit.h>
Public Slots | |
void | evaluate () |
void | execute () |
void | executeAll () |
QString | exportASCII (const QString &file=QString::null) |
void | exportPDF (const QString &fileName) |
QString | importASCII (const QString &file=QString::null) |
void | insertFunction (QAction *action) |
void | insertFunction (const QString &) |
void | print () |
void | scriptPrint (const QString &) |
void | setContext (QObject *context) |
void | setDirPath (const QString &path) |
void | updateIndentation () |
Signals | |
void | dirPathChanged (const QString &path) |
Public Member Functions | |
void | customEvent (QEvent *) |
Handle changing of scripting environment. | |
bool | error () |
int | lineNumber (int pos) const |
Map cursor positions to line numbers. | |
ScriptEdit (ScriptingEnv *env, QWidget *parent=0, const char *name=0) | |
void | setCompleter (QCompleter *c) |
Protected Member Functions | |
virtual void | contextMenuEvent (QContextMenuEvent *e) |
void | focusInEvent (QFocusEvent *e) |
virtual void | keyPressEvent (QKeyEvent *e) |
Private Slots | |
void | handleContentsChange (int position, int chars_removed, int chars_added) |
Called whenever the contents of the text document changes. | |
void | insertCompletion (const QString &completion) |
void | insertErrorMsg (const QString &message) |
Insert an error message from the scripting system at printCursor. | |
Private Member Functions | |
QString | textUnderCursor () const |
Private Attributes | |
QAction * | actionEval |
QAction * | actionExecute |
QAction * | actionExecuteAll |
QAction * | actionExport |
QAction * | actionImport |
QAction * | actionPrint |
bool | d_changing_fmt |
True if the text is programmatically changed and handleContentsChange() should do nothing. | |
QCompleter * | d_completer |
bool | d_error |
True if we are inside evaluate(), execute() or executeAll() there were errors. | |
QTextBlockFormat | d_fmt_default |
Format used for resetting success/failure markers. | |
QTextBlockFormat | d_fmt_failure |
Format used for marking code that resulted in an error. | |
QTextBlockFormat | d_fmt_success |
Format used for marking code that was executed or evaluated successfully. | |
QMenu * | functionsMenu |
Submenu of context menu with mathematical functions. | |
Script * | myScript |
QTextCursor | printCursor |
Cursor used for output of evaluation results and error messages. | |
QString | scriptsDirPath |
Editor widget with support for evaluating expressions and executing code.
ScriptEdit::ScriptEdit | ( | ScriptingEnv * | env, | |
QWidget * | parent = 0 , |
|||
const char * | name = 0 | |||
) |
References actionEval, actionExecute, actionExecuteAll, actionExport, actionImport, actionPrint, d_fmt_default, d_fmt_failure, d_fmt_success, error(), evaluate(), execute(), executeAll(), exportASCII(), functionsMenu, handleContentsChange(), importASCII(), insertErrorMsg(), insertFunction(), myScript, ScriptingEnv::newScript(), print(), printCursor, scripted::scriptEnv, scriptPrint(), and scriptsDirPath.
void ScriptEdit::contextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
void ScriptEdit::customEvent | ( | QEvent * | e | ) |
Handle changing of scripting environment.
References error(), insertErrorMsg(), myScript, ScriptingEnv::newScript(), print(), scripted::scriptEnv, SCRIPTING_CHANGE_EVENT, scripted::scriptingChangeEvent(), and scriptPrint().
void ScriptEdit::dirPathChanged | ( | const QString & | path | ) | [signal] |
Referenced by importASCII().
bool ScriptEdit::error | ( | ) | [inline] |
References d_error.
Referenced by customEvent(), ApplicationWindow::loadScript(), and ScriptEdit().
void ScriptEdit::evaluate | ( | ) | [slot] |
References d_changing_fmt, d_error, d_fmt_default, d_fmt_failure, d_fmt_success, Script::eval(), lineNumber(), myScript, printCursor, Script::setCode(), and Script::setName().
Referenced by Note::evaluate(), and ScriptEdit().
void ScriptEdit::execute | ( | ) | [slot] |
References d_changing_fmt, d_error, d_fmt_failure, d_fmt_success, Script::exec(), lineNumber(), myScript, printCursor, Script::setCode(), and Script::setName().
Referenced by Note::execute(), and ScriptEdit().
void ScriptEdit::executeAll | ( | ) | [slot] |
References Script::exec(), myScript, printCursor, Script::setCode(), and Script::setName().
Referenced by ScriptWindow::executeAll(), Note::executeAll(), ApplicationWindow::performCustomAction(), and ScriptEdit().
QString ScriptEdit::exportASCII | ( | const QString & | file = QString::null |
) | [slot] |
References ScriptingEnv::fileFilter(), scripted::scriptEnv, and scriptsDirPath.
Referenced by Note::exportASCII(), ScriptWindow::saveAs(), and ScriptEdit().
void ScriptEdit::exportPDF | ( | const QString & | fileName | ) | [slot] |
Referenced by Note::exportPDF().
void ScriptEdit::focusInEvent | ( | QFocusEvent * | e | ) | [protected] |
References d_completer.
void ScriptEdit::handleContentsChange | ( | int | position, | |
int | chars_removed, | |||
int | chars_added | |||
) | [private, slot] |
Called whenever the contents of the text document changes.
References d_changing_fmt, and d_fmt_default.
Referenced by ScriptEdit().
QString ScriptEdit::importASCII | ( | const QString & | file = QString::null |
) | [slot] |
References dirPathChanged(), ScriptingEnv::fileFilter(), scripted::scriptEnv, and scriptsDirPath.
Referenced by Note::importASCII(), ScriptWindow::open(), ApplicationWindow::performCustomAction(), and ScriptEdit().
void ScriptEdit::insertCompletion | ( | const QString & | completion | ) | [private, slot] |
References d_completer.
Referenced by setCompleter().
void ScriptEdit::insertErrorMsg | ( | const QString & | message | ) | [private, slot] |
Insert an error message from the scripting system at printCursor.
After insertion, the text cursor will have the error message selected, allowing the user to delete it and fix the error.
References d_error, and printCursor.
Referenced by customEvent(), and ScriptEdit().
void ScriptEdit::insertFunction | ( | QAction * | action | ) | [slot] |
References insertFunction(), ScriptingEnv::mathFunctions(), and scripted::scriptEnv.
void ScriptEdit::insertFunction | ( | const QString & | fname | ) | [slot] |
Referenced by SetColValuesDialog::insertFunction(), insertFunction(), MatrixValuesDialog::insertFunction(), and ScriptEdit().
void ScriptEdit::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
References d_completer, textUnderCursor(), and updateIndentation().
int ScriptEdit::lineNumber | ( | int | pos | ) | const |
Map cursor positions to line numbers.
Referenced by evaluate(), execute(), and scriptPrint().
void ScriptEdit::print | ( | ) | [slot] |
Referenced by customEvent(), Note::print(), and ScriptEdit().
void ScriptEdit::scriptPrint | ( | const QString & | text | ) | [slot] |
References lineNumber(), and printCursor.
Referenced by customEvent(), and ScriptEdit().
void ScriptEdit::setCompleter | ( | QCompleter * | c | ) |
void ScriptEdit::setContext | ( | QObject * | context | ) | [inline, slot] |
References myScript, and Script::setContext().
Referenced by Note::init(), ScriptWindow::ScriptWindow(), MatrixValuesDialog::setMatrix(), and SetColValuesDialog::setTable().
void ScriptEdit::setDirPath | ( | const QString & | path | ) | [slot] |
References scriptsDirPath.
Referenced by ScriptWindow::ScriptWindow(), and Note::setDirPath().
QString ScriptEdit::textUnderCursor | ( | ) | const [private] |
Referenced by keyPressEvent().
void ScriptEdit::updateIndentation | ( | ) | [slot] |
Referenced by keyPressEvent().
QAction * ScriptEdit::actionEval [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction* ScriptEdit::actionExecute [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionExecuteAll [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionExport [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionImport [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionPrint [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
bool ScriptEdit::d_changing_fmt [private] |
True if the text is programmatically changed and handleContentsChange() should do nothing.
Referenced by evaluate(), execute(), and handleContentsChange().
QCompleter* ScriptEdit::d_completer [private] |
Referenced by focusInEvent(), insertCompletion(), keyPressEvent(), and setCompleter().
bool ScriptEdit::d_error [private] |
True if we are inside evaluate(), execute() or executeAll() there were errors.
Referenced by error(), evaluate(), execute(), and insertErrorMsg().
QTextBlockFormat ScriptEdit::d_fmt_default [private] |
Format used for resetting success/failure markers.
Referenced by evaluate(), handleContentsChange(), and ScriptEdit().
QTextBlockFormat ScriptEdit::d_fmt_failure [private] |
Format used for marking code that resulted in an error.
Referenced by evaluate(), execute(), and ScriptEdit().
QTextBlockFormat ScriptEdit::d_fmt_success [private] |
Format used for marking code that was executed or evaluated successfully.
Referenced by evaluate(), execute(), and ScriptEdit().
QMenu* ScriptEdit::functionsMenu [private] |
Submenu of context menu with mathematical functions.
Referenced by contextMenuEvent(), and ScriptEdit().
Script* ScriptEdit::myScript [private] |
Referenced by customEvent(), evaluate(), execute(), executeAll(), ScriptEdit(), and setContext().
QTextCursor ScriptEdit::printCursor [private] |
Cursor used for output of evaluation results and error messages.
Referenced by evaluate(), execute(), executeAll(), insertErrorMsg(), ScriptEdit(), and scriptPrint().
QString ScriptEdit::scriptsDirPath [private] |
Referenced by exportASCII(), importASCII(), ScriptEdit(), and setDirPath().