Mercurial > hg > octave-nkf
changeset 16662:72665c4ae25b
allow build to continue without QScintilla lexer for Octave
* configure.ac: Check for Qsci/qscilexeroctave.h and
Qsci/qscilexermatlab.h.
* file-editor-tab.cc: Include Qsci/qscilexeroctave.h if it is
available, otherwise include Qsci/qscilexermatlab.h if it is
available.
(file_editor_tab::update_lexer): For Octave files, use QsciLexerOctave
if it is available, otherwise use QsciLexerMatlab if it is available,
otherwise use default lexer.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 15 May 2013 01:30:16 -0400 |
parents | 8291109ac3fd |
children | e380d1317c72 |
files | configure.ac libgui/src/m-editor/file-editor-tab.cc |
diffstat | 2 files changed, 51 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac +++ b/configure.ac @@ -2648,6 +2648,13 @@ OCTAVE_CHECK_FUNC_FINDFIRST_MODERN AC_DEFINE(HAVE_QSCINTILLA, 1, [Define to 1 if the QScintilla library and header files are available]) + + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS" + AC_LANG_PUSH(C++) + AC_CHECK_HEADERS([Qsci/qscilexeroctave.h Qsci/qscilexermatlab.h]) + AC_LANG_POP(C++) + CPPFLAGS="$save_CPPFLAGS" fi AC_CHECK_FUNCS([setlocale], [],
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -27,7 +27,13 @@ #ifdef HAVE_QSCINTILLA #include <Qsci/qsciapis.h> +#if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) +#define HAVE_LEXER_OCTAVE #include <Qsci/qscilexeroctave.h> +#elif defined (HAVE_QSCI_QSCILEXERMATLAB_H) +#define HAVE_LEXER_MATLAB +#include <Qsci/qscilexermatlab.h> +#endif #include <Qsci/qscilexercpp.h> #include <Qsci/qscilexerbash.h> #include <Qsci/qscilexerperl.h> @@ -208,45 +214,56 @@ { QsciLexer *lexer = _edit_area->lexer (); delete lexer; + lexer = 0; if (_file_name.endsWith (".m") - || _file_name.endsWith (".M") || _file_name.endsWith ("octaverc")) { +#if defined (HAVE_LEXER_OCTAVE) lexer = new QsciLexerOctave (); - } - else if (_file_name.endsWith (".c") - || _file_name.endsWith (".cc") - || _file_name.endsWith (".cpp") - || _file_name.endsWith (".cxx") - || _file_name.endsWith (".c++") - || _file_name.endsWith (".h") - || _file_name.endsWith (".hh") - || _file_name.endsWith (".hpp") - || _file_name.endsWith (".h++")) - { - lexer = new QsciLexerCPP (); +#elif defined (HAVE_LEXER_MATLAB) + lexer = new QsciLexerMatlab (); +#endif } - else if (_file_name.endsWith (".pl")) - { - lexer = new QsciLexerPerl (); - } - else if (_file_name.endsWith (".bat")) + + if (! lexer) { - lexer = new QsciLexerBatch (); - } - else if (_file_name.endsWith (".diff")) - { - lexer = new QsciLexerDiff (); - } - else // Default to bash lexer. - { - lexer = new QsciLexerBash (); + if (_file_name.endsWith (".c") + || _file_name.endsWith (".cc") + || _file_name.endsWith (".cpp") + || _file_name.endsWith (".cxx") + || _file_name.endsWith (".c++") + || _file_name.endsWith (".h") + || _file_name.endsWith (".hh") + || _file_name.endsWith (".hpp") + || _file_name.endsWith (".h++")) + { + lexer = new QsciLexerCPP (); + } + else if (_file_name.endsWith (".pl")) + { + lexer = new QsciLexerPerl (); + } + else if (_file_name.endsWith (".bat")) + { + lexer = new QsciLexerBatch (); + } + else if (_file_name.endsWith (".diff")) + { + lexer = new QsciLexerDiff (); + } + else + { + // FIXME -- why should the bash lexer be the default? + lexer = new QsciLexerBash (); + } } QSettings *settings = resource_manager::get_settings (); + if (settings) lexer->readSettings (*settings); + _edit_area->setLexer (lexer); }