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) |
bool | find (const QString &searchString, QTextDocument::FindFlags flags, bool previous=false) |
void | findNext () |
void | findPrevious () |
QString | importASCII (const QString &file=QString::null) |
void | insertFunction (QAction *action) |
void | insertFunction (const QString &) |
void | print (QPrinter *) |
void | print () |
void | replace () |
QString | save () |
void | scriptPrint (const QString &) |
void | setContext (QObject *context) |
void | setDirPath (const QString &path) |
void | showFindDialog (bool replace=false) |
void | updateIndentation () |
Signals | |
void | dirPathChanged (const QString &path) |
void | error (const QString &, const QString &, int) |
Public Member Functions | |
void | customEvent (QEvent *) |
Handle changing of scripting environment. | |
bool | error () |
int | lineNumber (int pos) const |
Map cursor positions to line numbers. | |
void | redirectOutputTo (QTextEdit *) |
void | rehighlight () |
ScriptEdit (ScriptingEnv *env, QWidget *parent=0, const char *name=0) | |
void | setCompleter (QCompleter *c) |
void | setFileName (const QString &fn) |
~ScriptEdit () | |
Protected Member Functions | |
virtual void | contextMenuEvent (QContextMenuEvent *e) |
void | focusInEvent (QFocusEvent *e) |
virtual void | keyPressEvent (QKeyEvent *e) |
Private Slots | |
void | insertCompletion (const QString &completion) |
void | insertErrorMsg (const QString &message) |
Insert an error message from the scripting system at printCursor. | |
void | matchParentheses () |
Private Member Functions | |
void | clearErrorHighlighting () |
void | createParenthesisSelection (int pos) |
void | highlightErrorLine (int offset) |
bool | matchLeftParenthesis (QTextBlock currentBlock, int index, int numRightParentheses) |
bool | matchRightParenthesis (QTextBlock currentBlock, int index, int numLeftParentheses) |
QString | textUnderCursor () const |
Private Attributes | |
QAction * | actionEval |
QAction * | actionExecute |
QAction * | actionExecuteAll |
QAction * | actionExport |
QAction * | actionFind |
QAction * | actionFindNext |
QAction * | actionFindPrevious |
QAction * | actionImport |
QAction * | actionPrint |
QAction * | actionReplace |
QAction * | actionSave |
QCompleter * | d_completer |
QString | d_err_message |
bool | d_error |
True if we are inside evaluate(), execute() or executeAll() there were errors. | |
QString | d_file_name |
QTextBlockFormat | d_fmt_default |
Format used for resetting success/failure markers. | |
SyntaxHighlighter * | d_highlighter |
QTextEdit * | d_output_widget |
QTextDocument::FindFlags | d_search_flags |
QString | d_search_string |
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, actionFind, actionFindNext, actionFindPrevious, actionImport, actionPrint, actionReplace, actionSave, d_fmt_default, error(), evaluate(), execute(), executeAll(), exportASCII(), findNext(), findPrevious(), functionsMenu, importASCII(), insertErrorMsg(), insertFunction(), matchParentheses(), myScript, ScriptingEnv::newScript(), print(), printCursor, rehighlight(), replace(), save(), scripted::scriptEnv, scriptPrint(), scriptsDirPath, and showFindDialog().
ScriptEdit::~ScriptEdit | ( | ) |
References d_highlighter.
void ScriptEdit::clearErrorHighlighting | ( | ) | [private] |
References d_fmt_default, and d_output_widget.
Referenced by evaluate(), execute(), and executeAll().
void ScriptEdit::contextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
References actionEval, actionExecute, actionExecuteAll, actionExport, actionFind, actionFindNext, actionFindPrevious, actionImport, actionPrint, actionReplace, actionSave, Note::autoexec(), Script::context(), delete_xpm, functionsMenu, ScriptingEnv::mathFunctionDoc(), ScriptingEnv::mathFunctions(), myScript, scripted::scriptEnv, and Note::tabs().
void ScriptEdit::createParenthesisSelection | ( | int | pos | ) | [private] |
Referenced by matchLeftParenthesis(), matchParentheses(), and matchRightParenthesis().
void ScriptEdit::customEvent | ( | QEvent * | e | ) |
Handle changing of scripting environment.
References error(), insertErrorMsg(), myScript, ScriptingEnv::newScript(), print(), rehighlight(), scripted::scriptEnv, SCRIPTING_CHANGE_EVENT, scripted::scriptingChangeEvent(), and scriptPrint().
void ScriptEdit::dirPathChanged | ( | const QString & | path | ) | [signal] |
Referenced by importASCII().
void ScriptEdit::error | ( | const QString & | , | |
const QString & | , | |||
int | ||||
) | [signal] |
bool ScriptEdit::error | ( | ) | [inline] |
References d_error.
Referenced by customEvent(), ApplicationWindow::loadScript(), and ScriptEdit().
void ScriptEdit::evaluate | ( | ) | [slot] |
References clearErrorHighlighting(), Script::code(), d_error, d_fmt_default, Script::eval(), highlightErrorLine(), lineNumber(), myScript, printCursor, Script::setCode(), and Script::setName().
Referenced by Note::evaluate(), and ScriptEdit().
void ScriptEdit::execute | ( | ) | [slot] |
References clearErrorHighlighting(), d_error, Script::exec(), highlightErrorLine(), lineNumber(), myScript, printCursor, Script::setCode(), and Script::setName().
Referenced by Note::execute(), and ScriptEdit().
void ScriptEdit::executeAll | ( | ) | [slot] |
QString ScriptEdit::exportASCII | ( | const QString & | file = QString::null |
) | [slot] |
References ScriptingEnv::fileFilter(), ApplicationWindow::getFileName(), scripted::scriptEnv, scriptsDirPath, and setFileName().
Referenced by Note::exportASCII(), save(), ScriptWindow::saveAs(), and ScriptEdit().
void ScriptEdit::exportPDF | ( | const QString & | fileName | ) | [slot] |
Referenced by Note::exportPDF().
bool ScriptEdit::find | ( | const QString & | searchString, | |
QTextDocument::FindFlags | flags, | |||
bool | previous = false | |||
) | [slot] |
References d_search_flags, and d_search_string.
Referenced by FindReplaceDialog::find(), findNext(), and findPrevious().
void ScriptEdit::findNext | ( | ) | [slot] |
References d_search_flags, d_search_string, find(), and showFindDialog().
Referenced by ScriptWindow::findNext(), ApplicationWindow::noteFindNext(), and ScriptEdit().
void ScriptEdit::findPrevious | ( | ) | [slot] |
References d_search_flags, d_search_string, find(), and showFindDialog().
Referenced by ScriptWindow::findPrevious(), ApplicationWindow::noteFindPrev(), and ScriptEdit().
void ScriptEdit::focusInEvent | ( | QFocusEvent * | e | ) | [protected] |
References d_completer.
void ScriptEdit::highlightErrorLine | ( | int | offset | ) | [private] |
References d_err_message, d_error, lineNumber(), and scripted::scriptEnv.
Referenced by evaluate(), execute(), and executeAll().
QString ScriptEdit::importASCII | ( | const QString & | file = QString::null |
) | [slot] |
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 ScriptingEnv::application(), d_err_message, d_error, printCursor, and scripted::scriptEnv.
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(), highlightErrorLine(), and scriptPrint().
bool ScriptEdit::matchLeftParenthesis | ( | QTextBlock | currentBlock, | |
int | index, | |||
int | numRightParentheses | |||
) | [private] |
References ParenthesisInfo::character, createParenthesisSelection(), TextBlockData::parentheses(), and ParenthesisInfo::position.
Referenced by matchParentheses().
void ScriptEdit::matchParentheses | ( | ) | [private, slot] |
References ParenthesisInfo::character, createParenthesisSelection(), matchLeftParenthesis(), matchRightParenthesis(), TextBlockData::parentheses(), and ParenthesisInfo::position.
Referenced by ScriptEdit().
bool ScriptEdit::matchRightParenthesis | ( | QTextBlock | currentBlock, | |
int | index, | |||
int | numLeftParentheses | |||
) | [private] |
References ParenthesisInfo::character, createParenthesisSelection(), TextBlockData::parentheses(), and ParenthesisInfo::position.
Referenced by matchParentheses().
void ScriptEdit::print | ( | QPrinter * | printer | ) | [slot] |
void ScriptEdit::print | ( | ) | [slot] |
Referenced by customEvent(), Note::print(), and ScriptEdit().
void ScriptEdit::redirectOutputTo | ( | QTextEdit * | te | ) |
References d_output_widget, and printCursor.
Referenced by ScriptWindow::redirectOutput().
void ScriptEdit::rehighlight | ( | ) |
References d_highlighter, and scripted::scriptEnv.
Referenced by customEvent(), ConfigDialog::rehighlight(), and ScriptEdit().
void ScriptEdit::replace | ( | ) | [inline, slot] |
References showFindDialog().
Referenced by ScriptEdit().
QString ScriptEdit::save | ( | ) | [slot] |
References d_file_name, and exportASCII().
Referenced by 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::addTab(), ScriptWindow::ScriptWindow(), MatrixValuesDialog::setMatrix(), and SetColValuesDialog::setTable().
void ScriptEdit::setDirPath | ( | const QString & | path | ) | [slot] |
References scriptsDirPath.
Referenced by Note::addTab(), ScriptWindow::ScriptWindow(), and Note::setDirPath().
void ScriptEdit::setFileName | ( | const QString & | fn | ) |
References Script::context(), d_file_name, Note::indexOf(), myScript, and Note::renameTab().
Referenced by exportASCII(), and importASCII().
void ScriptEdit::showFindDialog | ( | bool | replace = false |
) | [slot] |
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::actionFind [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionFindNext [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionFindPrevious [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionImport [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionPrint [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionReplace [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QAction * ScriptEdit::actionSave [private] |
Referenced by contextMenuEvent(), and ScriptEdit().
QCompleter* ScriptEdit::d_completer [private] |
Referenced by focusInEvent(), insertCompletion(), keyPressEvent(), and setCompleter().
QString ScriptEdit::d_err_message [private] |
Referenced by highlightErrorLine(), and insertErrorMsg().
bool ScriptEdit::d_error [private] |
True if we are inside evaluate(), execute() or executeAll() there were errors.
Referenced by error(), evaluate(), execute(), executeAll(), highlightErrorLine(), and insertErrorMsg().
QString ScriptEdit::d_file_name [private] |
Referenced by save(), and setFileName().
QTextBlockFormat ScriptEdit::d_fmt_default [private] |
Format used for resetting success/failure markers.
Referenced by clearErrorHighlighting(), evaluate(), and ScriptEdit().
SyntaxHighlighter* ScriptEdit::d_highlighter [private] |
Referenced by rehighlight(), and ~ScriptEdit().
QTextEdit* ScriptEdit::d_output_widget [private] |
Referenced by clearErrorHighlighting(), and redirectOutputTo().
QTextDocument::FindFlags ScriptEdit::d_search_flags [private] |
Referenced by find(), findNext(), and findPrevious().
QString ScriptEdit::d_search_string [private] |
Referenced by find(), findNext(), and findPrevious().
QMenu* ScriptEdit::functionsMenu [private] |
Submenu of context menu with mathematical functions.
Referenced by contextMenuEvent(), and ScriptEdit().
Script* ScriptEdit::myScript [private] |
Referenced by contextMenuEvent(), customEvent(), evaluate(), execute(), executeAll(), ScriptEdit(), setContext(), and setFileName().
QTextCursor ScriptEdit::printCursor [private] |
Cursor used for output of evaluation results and error messages.
Referenced by evaluate(), execute(), insertErrorMsg(), redirectOutputTo(), ScriptEdit(), and scriptPrint().
QString ScriptEdit::scriptsDirPath [private] |
Referenced by exportASCII(), importASCII(), ScriptEdit(), and setDirPath().