changeset 19804:35a8e1beac8d

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
author Torsten <ttl@justmail.de>
date Thu, 19 Feb 2015 20:26:36 +0100
parents 70911df8ad28
children 8cfb5dae134c
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/octave-txt-lexer.cc libgui/src/m-editor/octave-txt-lexer.h
diffstat 4 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Thu Feb 19 14:29:34 2015 +0000
+++ b/libgui/src/m-editor/file-editor-tab.cc	Thu Feb 19 20:26:36 2015 +0100
@@ -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 ())
--- a/libgui/src/m-editor/file-editor-tab.h	Thu Feb 19 14:29:34 2015 +0000
+++ b/libgui/src/m-editor/file-editor-tab.h	Thu Feb 19 20:26:36 2015 +0100
@@ -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);
--- a/libgui/src/m-editor/octave-txt-lexer.cc	Thu Feb 19 14:29:34 2015 +0000
+++ b/libgui/src/m-editor/octave-txt-lexer.cc	Thu Feb 19 20:26:36 2015 +0100
@@ -49,4 +49,11 @@
 }
 
 
+const char*
+octave_txt_lexer::lexer () const
+{
+  return "text";
+}
+
+
 #endif
--- a/libgui/src/m-editor/octave-txt-lexer.h	Thu Feb 19 14:29:34 2015 +0000
+++ b/libgui/src/m-editor/octave-txt-lexer.h	Thu Feb 19 20:26:36 2015 +0100
@@ -36,6 +36,7 @@
 public:
 
   virtual const char *language () const;
+  virtual const char *lexer () const;
   virtual QString description (int style) const;
 
 };