changeset 16715:96ed7ab44e2e

save prepared apis info for qscintilla into a path depending on octave version * file-editor-tab.h: new private class variable _prep_apis_file * file-editor-tab.cc: include version.h (update_lexer): create path to load from or save to the prepared apis info (save_apis_info): save prepared apis info in file _prep_apis_file
author Torsten <ttl@justmail.de>
date Sat, 01 Jun 2013 15:10:35 +0200
parents fbf4b4ff4548
children 23b5dde25367
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h
diffstat 2 files changed, 23 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Sat Jun 01 10:32:25 2013 +0200
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sat Jun 01 15:10:35 2013 +0200
@@ -53,6 +53,7 @@
 
 #include "debug.h"
 #include "octave-qt-link.h"
+#include "version.h"
 
 // Make parent null for the file editor tab so that warning
 // WindowModal messages don't affect grandparents.
@@ -263,6 +264,7 @@
       _lexer_apis = new QsciAPIs(lexer);
       if (_lexer_apis)
         {
+          // create raw apis info
           QString keyword;
           QStringList keyword_list;
           int i;
@@ -273,12 +275,26 @@
               for (i = 0; i < keyword_list.size (); i++)        // add to API
                 _lexer_apis->add (keyword_list.at (i));
             }
-          if (!_lexer_apis->loadPrepared ())
-            {
-              connect (_lexer_apis, SIGNAL (apiPreparationFinished ()),
-                       this, SLOT (save_apis_info ()));
-              _lexer_apis->prepare ();
+
+          // get path where to store prepared api info
+          QDesktopServices desktopServices;
+          QString prep_apis_path
+            = desktopServices.storageLocation (QDesktopServices::HomeLocation)
+                + "/.config/octave/"  + QString(OCTAVE_VERSION) + "/qsci/";
+
+          // check whether path exists or can be created
+          if (QDir("/").mkpath (prep_apis_path))
+            { // path exists, apis info can be saved there
+              _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap";
+              if (!_lexer_apis->loadPrepared (_prep_apis_file))
+                { // no prepared info loaded, prepare and save
+                  connect (_lexer_apis, SIGNAL (apiPreparationFinished ()),
+                           this, SLOT (save_apis_info ()));
+                  _lexer_apis->prepare ();  // prepare apis info and save
+                }
             }
+          else
+            _lexer_apis->prepare ();  // prepare apis info wihtout saving
         }
     }
 
@@ -293,7 +309,7 @@
 void
 file_editor_tab::save_apis_info ()
 {
-  _lexer_apis->savePrepared ();
+  _lexer_apis->savePrepared (_prep_apis_file);
 }
 
 // slot for fetab_set_focus: sets the focus to the current edit area
--- a/libgui/src/m-editor/file-editor-tab.h	Sat Jun 01 10:32:25 2013 +0200
+++ b/libgui/src/m-editor/file-editor-tab.h	Sat Jun 01 15:10:35 2013 +0200
@@ -195,6 +195,7 @@
   QRect _find_dialog_geometry;
 
   QsciAPIs *_lexer_apis;
+  QString _prep_apis_file;
 };
 
 #endif