diff libgui/src/m-editor/file-editor-tab.cc @ 19382:c364b9a44580 gui-release

provide an editor lexer for text or unknown files (bug #43572) * default-qt-settings.in: fix color for numbers in bash files, add defaults for the new text lexer * file-editor-tab.cc (update_lexer): only select the bash lexer for .sh-files, select the new text lexer for .m-files or unnamed files if octave and matlab lexer is not available as well as for files with no or unknown extension * octave-txt-lexer.h: new lexer class derived from QsciLexer just providing the default style for text or unknown files * octave-txt-lexer.cc (language, description): implemented functions * module.mk: added new files octave-txt-lexer.cc/.h * settings-dialog.cc (constructor): read the settings for the new text lexer; (write-changed-settings): write settings for the new lexer into the files
author Torsten <ttl@justmail.de>
date Sun, 23 Nov 2014 13:13:35 +0100
parents cd2a75e5cd6e
children ed0df431631b
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Sat Nov 22 20:19:23 2014 -0800
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sun Nov 23 13:13:35 2014 +0100
@@ -52,6 +52,7 @@
 
 #include "file-editor-tab.h"
 #include "file-editor.h"
+#include "octave-txt-lexer.h"
 
 #include "file-ops.h"
 
@@ -396,6 +397,8 @@
       lexer = new QsciLexerOctave ();
 #elif defined (HAVE_LEXER_MATLAB)
       lexer = new QsciLexerMatlab ();
+#else
+      lexer = new octave_txt_lexer ();
 #endif
       _is_octave_file = true;
     }
@@ -426,6 +429,10 @@
         {
           lexer = new QsciLexerDiff ();
         }
+      else if (_file_name.endsWith (".sh"))
+        {
+          lexer = new QsciLexerBash ();
+        }
       else if (! valid_file_name ())
         {
           // new, no yet named file: let us assume it is octave
@@ -436,13 +443,13 @@
           lexer = new QsciLexerMatlab ();
           _is_octave_file = true;
 #else
-          lexer = new QsciLexerBash ();
+          lexer = new octave_txt_lexer ();
 #endif
         }
       else
         {
           // other or no extension
-          lexer = new QsciLexerBash ();
+          lexer = new octave_txt_lexer ();
         }
     }