comparison 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
comparison
equal deleted inserted replaced
19379:2a790328fc50 19382:c364b9a44580
50 #include <QPrintDialog> 50 #include <QPrintDialog>
51 #include <QDateTime> 51 #include <QDateTime>
52 52
53 #include "file-editor-tab.h" 53 #include "file-editor-tab.h"
54 #include "file-editor.h" 54 #include "file-editor.h"
55 #include "octave-txt-lexer.h"
55 56
56 #include "file-ops.h" 57 #include "file-ops.h"
57 58
58 #include "debug.h" 59 #include "debug.h"
59 #include "octave-qt-link.h" 60 #include "octave-qt-link.h"
394 { 395 {
395 #if defined (HAVE_LEXER_OCTAVE) 396 #if defined (HAVE_LEXER_OCTAVE)
396 lexer = new QsciLexerOctave (); 397 lexer = new QsciLexerOctave ();
397 #elif defined (HAVE_LEXER_MATLAB) 398 #elif defined (HAVE_LEXER_MATLAB)
398 lexer = new QsciLexerMatlab (); 399 lexer = new QsciLexerMatlab ();
400 #else
401 lexer = new octave_txt_lexer ();
399 #endif 402 #endif
400 _is_octave_file = true; 403 _is_octave_file = true;
401 } 404 }
402 405
403 if (! lexer) 406 if (! lexer)
424 } 427 }
425 else if (_file_name.endsWith (".diff")) 428 else if (_file_name.endsWith (".diff"))
426 { 429 {
427 lexer = new QsciLexerDiff (); 430 lexer = new QsciLexerDiff ();
428 } 431 }
432 else if (_file_name.endsWith (".sh"))
433 {
434 lexer = new QsciLexerBash ();
435 }
429 else if (! valid_file_name ()) 436 else if (! valid_file_name ())
430 { 437 {
431 // new, no yet named file: let us assume it is octave 438 // new, no yet named file: let us assume it is octave
432 #if defined (HAVE_LEXER_OCTAVE) 439 #if defined (HAVE_LEXER_OCTAVE)
433 lexer = new QsciLexerOctave (); 440 lexer = new QsciLexerOctave ();
434 _is_octave_file = true; 441 _is_octave_file = true;
435 #elif defined (HAVE_LEXER_MATLAB) 442 #elif defined (HAVE_LEXER_MATLAB)
436 lexer = new QsciLexerMatlab (); 443 lexer = new QsciLexerMatlab ();
437 _is_octave_file = true; 444 _is_octave_file = true;
438 #else 445 #else
439 lexer = new QsciLexerBash (); 446 lexer = new octave_txt_lexer ();
440 #endif 447 #endif
441 } 448 }
442 else 449 else
443 { 450 {
444 // other or no extension 451 // other or no extension
445 lexer = new QsciLexerBash (); 452 lexer = new octave_txt_lexer ();
446 } 453 }
447 } 454 }
448 455
449 QSettings *settings = resource_manager::get_settings (); 456 QSettings *settings = resource_manager::get_settings ();
450 457