# HG changeset patch # User Torsten # Date 1424373996 -3600 # Node ID 35a8e1beac8d477a4947fc38b1c2b48f6aaddafc # Parent 70911df8ad280ca424984228b5cb7b2f26d1617b fix some oddities updating lexer and api-files for auto completion * file-editor-tab.cc (file_editor_tab): call notice_settings with flag that updating the lexer is not necessary since it is done while loading the file; (update_lexer): fix some binary operators; (new_file): call update_lexer since it is not called during initialization; (notice_settings): new flag for indicating initialization phase where update_lexer should not be called * file-editor-tab.h: notice_settings has an additional input parameter which is set to false by default * octave-txt-lexer.cc (lexer): new function returning the name of the lexer * octave-txt-lexer.h: new function returning the name of the lexer diff --git a/libgui/src/m-editor/file-editor-tab.cc b/libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -163,7 +163,7 @@ QSettings *settings = resource_manager::get_settings (); if (settings) - notice_settings (settings); + notice_settings (settings, true); } file_editor_tab::~file_editor_tab (void) @@ -477,7 +477,7 @@ update_apis_file = ! apis_file.exists (); // flag whether apis file needs update // function list depends on installed packages: check mod. date - if (! update_apis_file & octave_functions) + if (! update_apis_file && octave_functions) { // check whether package file is newer than apis_file QDateTime apis_date = apis_file.lastModified (); @@ -497,7 +497,7 @@ QString::fromStdString (Voctave_home) + "/share/octave/octave_packages"); if (global_pkg_list.exists () - & (apis_date < global_pkg_list.lastModified ()) ) + && (apis_date < global_pkg_list.lastModified ()) ) update_apis_file = true; } } @@ -506,7 +506,7 @@ _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap"; } - if (update_apis_file | !_lexer_apis->loadPrepared (_prep_apis_file)) + if (update_apis_file || !_lexer_apis->loadPrepared (_prep_apis_file)) { // no prepared info loaded, prepare and save if possible @@ -1432,6 +1432,8 @@ update_eol_indicator (); + update_lexer (); + _edit_area->setText (commands); _edit_area->setModified (false); // new file is not modified yet } @@ -1783,11 +1785,12 @@ } void -file_editor_tab::notice_settings (const QSettings *settings) +file_editor_tab::notice_settings (const QSettings *settings, bool init) { // QSettings pointer is checked before emitting. - update_lexer (); + if (! init) + update_lexer (); // code folding if (settings->value ("editor/code_folding",true).toBool ()) diff --git a/libgui/src/m-editor/file-editor-tab.h b/libgui/src/m-editor/file-editor-tab.h --- a/libgui/src/m-editor/file-editor-tab.h +++ b/libgui/src/m-editor/file-editor-tab.h @@ -65,7 +65,7 @@ Qt::KeyboardModifiers state); // Tells the editor tab to react on changed settings. - void notice_settings (const QSettings *settings); + void notice_settings (const QSettings *settings, bool init = false); // Change to a different editor tab by identifier tag. void change_editor_state (const QWidget *ID); diff --git a/libgui/src/m-editor/octave-txt-lexer.cc b/libgui/src/m-editor/octave-txt-lexer.cc --- a/libgui/src/m-editor/octave-txt-lexer.cc +++ b/libgui/src/m-editor/octave-txt-lexer.cc @@ -49,4 +49,11 @@ } +const char* +octave_txt_lexer::lexer () const +{ + return "text"; +} + + #endif diff --git a/libgui/src/m-editor/octave-txt-lexer.h b/libgui/src/m-editor/octave-txt-lexer.h --- a/libgui/src/m-editor/octave-txt-lexer.h +++ b/libgui/src/m-editor/octave-txt-lexer.h @@ -36,6 +36,7 @@ public: virtual const char *language () const; + virtual const char *lexer () const; virtual QString description (int style) const; };