GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
octave-qscintilla.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2013-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_octave_qscintilla_h)
27 #define octave_octave_qscintilla_h 1
28 
29 #include <QContextMenuEvent>
30 #include <QKeyEvent>
31 #include <QLabel>
32 #include <QMenu>
33 #include <Qsci/qsciscintilla.h>
34 #include <QTemporaryFile>
35 
36 #include "gui-settings.h"
37 #include "qt-interpreter-events.h"
38 
40 
41 class base_qobject;
42 
44 {
45  Q_OBJECT
46 
47 public:
48 
49  octave_qscintilla (QWidget *p, base_qobject& oct_qobj);
50 
51  ~octave_qscintilla (void) = default;
52 
53  enum
54  {
55  ST_NONE = 0,
58  };
59 
60  virtual void contextMenuEvent (QContextMenuEvent *e);
61  virtual void setCursorPosition (int line, int col);
62 
63  void context_help_doc (bool);
64  void context_edit (void);
65  void context_run (void);
66  void get_global_textcursor_pos (QPoint *global_pos, QPoint *local_pos);
67  bool get_actual_word (void);
68  void clear_selection_markers (void);
69  QString eol_string (void);
70  void get_current_position (int *pos, int *line, int *col);
71  QStringList comment_string (bool comment = true);
72  int get_style (int pos = -1);
73  int is_style_comment (int pos = -1);
74  void smart_indent (bool do_smart_indent, int do_auto_close,
75  int line, int ind_char_width);
76 
77  void smart_indent_line_or_selected_text (int lineFrom, int lineTo);
78 
79  void set_word_selection (const QString& word = QString ());
80 
81  void show_selection_markers (int l1, int c1, int l2, int c2);
82 
83  void set_selection_marker_color (const QColor& c);
84 
85  void replace_all (const QString& o_str, const QString& n_str,
86  bool re, bool cs, bool wo);
87 
88 signals:
89 
90  void update_rowcol_indicator_signal (int line, int col);
91  void execute_command_in_terminal_signal (const QString&);
93  void context_menu_edit_signal (const QString&);
94  void qsci_has_focus_signal (bool);
95  void status_update (bool, bool);
96  void show_doc_signal (const QString&);
99  void ctx_menu_run_finished_signal (bool, int, QTemporaryFile *,
100  QTemporaryFile *, bool, bool);
102 
103  void interpreter_event (const fcn_callback& fcn);
104  void interpreter_event (const meth_callback& meth);
105 
106 public slots:
107 
108  void handle_enter_debug_mode (void);
109  void handle_exit_debug_mode (void);
110 
111 private slots:
112 
113  void ctx_menu_run_finished (bool, int, QTemporaryFile *, QTemporaryFile *,
114  bool, bool);
115 
116  void contextmenu_help (bool);
117  void contextmenu_doc (bool);
118  void contextmenu_help_doc (bool);
119  void contextmenu_edit (bool);
120  void contextmenu_run (bool);
121  void contextmenu_run_temp_error (void);
122 
123  void contextmenu_break_condition (bool);
124  void contextmenu_break_once (const QPoint&);
125 
126  void text_changed (void);
127  void cursor_position_changed (int, int);
128 
129 protected:
130 
131  void focusInEvent (QFocusEvent *focusEvent);
132 
133  void show_replace_action_tooltip (void);
134 
135  bool event (QEvent *e);
136 
137  void keyPressEvent (QKeyEvent *e);
138 
139  void dragEnterEvent (QDragEnterEvent *e);
140 
141 private:
142 
143  void auto_close (int auto_endif, int l,
144  const QString& line, QString& first_word);
145 
147 
149 
151 
152  QString m_selection;
157 };
158 
160 
161 #endif
OCTAVE_END_NAMESPACE(octave)
Base class for Octave interfaces that use Qt.
void get_current_position(int *pos, int *line, int *col)
void contextmenu_break_once(const QPoint &)
void ctx_menu_run_finished_signal(bool, int, QTemporaryFile *, QTemporaryFile *, bool, bool)
void show_replace_action_tooltip(void)
void auto_close(int auto_endif, int l, const QString &line, QString &first_word)
void ctx_menu_run_finished(bool, int, QTemporaryFile *, QTemporaryFile *, bool, bool)
octave_qscintilla(QWidget *p, base_qobject &oct_qobj)
void smart_indent(bool do_smart_indent, int do_auto_close, int line, int ind_char_width)
void context_menu_break_once(int)
QString eol_string(void)
void focus_console_after_command_signal(void)
void set_word_selection(const QString &word=QString())
void show_selection_markers(int l1, int c1, int l2, int c2)
void contextmenu_break_condition(bool)
void context_menu_break_condition_signal(int)
void smart_indent_line_or_selected_text(int lineFrom, int lineTo)
base_qobject & m_octave_qobj
void cursor_position_changed(int, int)
void dragEnterEvent(QDragEnterEvent *e)
virtual void setCursorPosition(int line, int col)
void qsci_has_focus_signal(bool)
virtual void contextMenuEvent(QContextMenuEvent *e)
void status_update(bool, bool)
void contextmenu_help_doc(bool)
void execute_command_in_terminal_signal(const QString &)
void context_menu_edit_signal(const QString &)
void set_selection_marker_color(const QColor &c)
void focusInEvent(QFocusEvent *focusEvent)
void handle_exit_debug_mode(void)
void show_doc_signal(const QString &)
void interpreter_event(const fcn_callback &fcn)
void clear_selection_markers(void)
void handle_enter_debug_mode(void)
void get_global_textcursor_pos(QPoint *global_pos, QPoint *local_pos)
void create_context_menu_signal(QMenu *)
bool event(QEvent *e)
void interpreter_event(const meth_callback &meth)
~octave_qscintilla(void)=default
QStringList comment_string(bool comment=true)
int get_style(int pos=-1)
void contextmenu_run_temp_error(void)
int is_style_comment(int pos=-1)
void keyPressEvent(QKeyEvent *e)
void replace_all(const QString &o_str, const QString &n_str, bool re, bool cs, bool wo)
void update_rowcol_indicator_signal(int line, int col)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::function< void(void)> fcn_callback
Definition: event-manager.h:43
std::function< void(interpreter &)> meth_callback
Definition: event-manager.h:48