Mercurial > hg > octave-shane
changeset 16704:e38a0fa08368
fix restoring editor files from previous session and speedup lexer preparation
* file-editor-tab.h: new slot save_apis_info, class variable for lexer's apis
* file-editor-tab.cc(update_lexer): cancel any existing apis preparation,
try to load prepared apis information or prepare and save it
(save_apis_info): new slot for saving apis info when preparation is finished
(constructor): initialize class variable for apis to zero
author | Torsten <ttl@justmail.de> |
---|---|
date | Mon, 27 May 2013 21:41:57 +0200 |
parents | 5cf19370011d |
children | 122d3f62e179 |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h |
diffstat | 2 files changed, 25 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -26,7 +26,6 @@ #ifdef HAVE_QSCINTILLA -#include <Qsci/qsciapis.h> #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) #define HAVE_LEXER_OCTAVE #include <Qsci/qscilexeroctave.h> @@ -60,7 +59,7 @@ file_editor_tab::file_editor_tab (const QString& directory_arg) { QString directory = directory_arg; - + _lexer_apis = 0; _app_closing = false; // Make sure there is a slash at the end of the directory name @@ -209,6 +208,9 @@ void file_editor_tab::update_lexer () { + if (_lexer_apis) + _lexer_apis->cancelPreparation (); // stop preparing if apis exists + QsciLexer *lexer = _edit_area->lexer (); delete lexer; lexer = 0; @@ -258,8 +260,8 @@ if (lexer) { - QsciAPIs *apis = new QsciAPIs(lexer); - if (apis) + _lexer_apis = new QsciAPIs(lexer); + if (_lexer_apis) { QString keyword; QStringList keyword_list; @@ -269,9 +271,14 @@ keyword = QString(lexer->keywords (i)); // get list keyword_list = keyword.split (QRegExp ("\\s+")); // split for (i = 0; i < keyword_list.size (); i++) // add to API - apis->add (keyword_list.at (i)); + _lexer_apis->add (keyword_list.at (i)); } - apis->prepare (); + if (!_lexer_apis->loadPrepared ()) + { + connect (_lexer_apis, SIGNAL (apiPreparationFinished ()), + this, SLOT (save_apis_info ())); + _lexer_apis->prepare (); + } } } @@ -283,6 +290,12 @@ } +void +file_editor_tab::save_apis_info () +{ + _lexer_apis->savePrepared (); +} + // slot for fetab_set_focus: sets the focus to the current edit area void file_editor_tab::set_focus (const QWidget *ID)
--- a/libgui/src/m-editor/file-editor-tab.h +++ b/libgui/src/m-editor/file-editor-tab.h @@ -29,6 +29,7 @@ #include <QSettings> #include <QFileInfo> #include <Qsci/qsciscintilla.h> +#include <Qsci/qsciapis.h> #include "find-dialog.h" @@ -137,6 +138,9 @@ void handle_save_file_as_answer_close (const QString& fileName); void handle_save_file_as_answer_cancel (); + // When apis preparation has finished and is ready to save + void save_apis_info (); + private: enum editor_markers @@ -189,6 +193,8 @@ find_dialog *_find_dialog; bool _find_dialog_is_visible; QRect _find_dialog_geometry; + + QsciAPIs *_lexer_apis; }; #endif