# HG changeset patch # User John W. Eaton # Date 1368595816 14400 # Node ID 72665c4ae25b566a44095d65b94962ecbd84fd6c # Parent 8291109ac3fd68c079bcf582f57b8764db5da150 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. diff --git a/configure.ac b/configure.ac --- 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], [], diff --git a/libgui/src/m-editor/file-editor-tab.cc b/libgui/src/m-editor/file-editor-tab.cc --- 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 +#if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) +#define HAVE_LEXER_OCTAVE #include +#elif defined (HAVE_QSCI_QSCILEXERMATLAB_H) +#define HAVE_LEXER_MATLAB +#include +#endif #include #include #include @@ -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); }