Mercurial > octave
diff libgui/src/m-editor/octave-qscintilla.cc @ 23234:aaf20024db6f
function providing comment strings uses lexer number and not lexer names
* file-editor-tab.cc (comment_string): move function to octave-qscintilla.cc;
(do_comment_selected_text): update the call to the function
* file-editor-tab.h: remove declaration of comment_string
* octave-qscintilla.cc (comment_string): this funtion moved here from
file_editor_tab.cc, the current lexer is detected and not given by the
caller via the name of the lexer
* octave-qscintilla.h: new function comment_string
author | Torsten <mttl@mailbox.org> |
---|---|
date | Sat, 25 Feb 2017 17:57:01 +0100 |
parents | f7fdc9ef3971 |
children | 4cd5f975d26c |
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc Sat Feb 25 12:27:47 2017 +0100 +++ b/libgui/src/m-editor/octave-qscintilla.cc Sat Feb 25 17:57:01 2017 +0100 @@ -28,6 +28,12 @@ #if defined (HAVE_QSCINTILLA) +#if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) +# define HAVE_LEXER_OCTAVE 1 +#elif defined (HAVE_QSCI_QSCILEXERMATLAB_H) +# define HAVE_LEXER_MATLAB 1 +#endif + #include <Qsci/qscilexer.h> #include <Qsci/qscicommandset.h> #include <QShortcut> @@ -36,6 +42,7 @@ #include "octave-qscintilla.h" #include "file-editor-tab.h" #include "shortcut-manager.h" +#include "resource-manager.h" octave_qscintilla::octave_qscintilla (QWidget *p) : QsciScintilla (p) @@ -342,6 +349,47 @@ QsciScintilla::focusInEvent (focusEvent); } +// Function returning the comment string of the current lexer +QString +octave_qscintilla::comment_string () +{ + int lexer = SendScintilla (SCI_GETLEXER); + + switch (lexer) + { +#if defined (HAVE_LEXER_MATLAB) + case SCLEX_MATLAB: +#if defined (HAVE_LEXER_OCTAVE) + case SCLEX_OCTAVE: +#endif + { + QSettings *settings = resource_manager::get_settings (); + int comment_index + = settings->value ("editor/octave_comment_string", 0).toInt (); + if (comment_index == 1) + return QString ("#"); + else if (comment_index == 2) + return QString ("%"); + else + return QString ("##"); // default and for index 0 + } +#endif + + case SCLEX_PERL: + case SCLEX_BASH: + case SCLEX_DIFF: + return QString ("#"); + + case SCLEX_CPP: + return QString ("//"); + + case SCLEX_BATCH: + return QString ("REM "); + } + + return QString ("%"); // should never happen +} + // helper function for clearing all indicators of a specific style void octave_qscintilla::clear_indicator (int indicator_style)