view libgui/src/m-editor/lexer-octave-gui.h @ 15425:8ae34ffe5c1b

Retain QsciAPIs lexer_api as part of lexer_octave_gui object (bug #37359) This way, it may be deleted upon deconstruction and not cause segmentation fault at startup * file-editor-tab.cc, file-editor-tab.h (file_editor_tab::update_tracked_file): Delete. (file_editor_tab::set_file_name): Rather than clear whole list, just subtract out the old file name then add the new name. (file_editor_tab::load_file): Remove update_tracked_file, it's part of set_file_name. (file_editor_tab::file_has_changed): Remove update_tracked_file, it's part of set_file_name. (file_editor_tab::save_file): Move file close before set_file_name so watcher doesn't notice. Remove inelegant code that solved this by clearing watcher files. * lexer-octave-gui.cc, file-editor-tab.cc (file_editor_tab::update_lexer, lexer_octave_gui::lexer_octave_gui, lexer_octave_gui : public QsciLexer): Move all the lexer preparatory code to the constructor so that lexer_api can be retained as part of object. (lexer_octave_gui::~lexer_octave_gui): Make destructor non-virtual and delete lexer_gui when done. * octave-gui.cc, main-window-h, main-window.cc, file-editor.cc (octave_start_gui, file_editor::construct): Move read_settings from constructor to after construction in octave_start_gui so that no signal occur referencing a partially constructed object. * file-editor.cc (file_editor::construct): Tidy code.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Thu, 20 Sep 2012 04:08:53 -0500
parents 501a9cc2c68f
children d07aeecb2d22
line wrap: on
line source

/*

Copyright (C) 2011-2012 Jacob Dawid

This file is part of Octave.

Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

Octave is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING.  If not, see
<http://www.gnu.org/licenses/>.

*/

#ifndef LEXEROCTAVE_H
#define LEXEROCTAVE_H

#include "resource-manager.h"
#include <QObject>
#include <Qsci/qsciglobal.h>
#include <Qsci/qscilexer.h>
#include <Qsci/qsciapis.h>

class lexer_octave_gui : public QsciLexer
{
  Q_OBJECT

  public:
  // the used styles
  enum
    {
      Default = 0,
      Comment = 1,
      Command = 2,
      Number = 3,
      Keyword = 4,
      SingleQuotedString = 5,
      Operator = 6,
      Identifier = 7,
      DoubleQuotedString = 8
    };

  lexer_octave_gui (QObject *parent = 0);
  ~lexer_octave_gui ();
  const char *language () const;
  const char *lexer () const;
  QColor defaultColor (int style) const;
  QFont defaultFont (int style) const;
  const char *keywords (int set) const;
  QString description (int style) const;

private:
  lexer_octave_gui (const lexer_octave_gui &);
  lexer_octave_gui &operator= (const lexer_octave_gui &);
  QsciAPIs *lexer_api;
};

#endif