GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
file-editor-tab.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2011-2022 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_file_editor_tab_h)
27#define octave_file_editor_tab_h 1
28
29#include <QAbstractButton>
30#include <QCloseEvent>
31#include <QDateTime>
32#include <QFileInfo>
33#include <QFileSystemWatcher>
34#include <QLabel>
35#include <QStatusBar>
36#include <QWidget>
37#include <Qsci/qsciapis.h>
38
39#include "gui-settings.h"
40#include "marker.h"
41#include "octave-qscintilla.h"
43
45
46namespace octave
47{
48 class base_qobject;
49 class file_editor;
50
51 class file_editor_tab : public QWidget
52 {
53 Q_OBJECT
54
55 public:
56
57 file_editor_tab (base_qobject& oct_qobj, const QString& directory = "");
58
59 ~file_editor_tab (void);
60
62
63 // Will initiate close if associated with the identifier tag.
64 bool conditional_close (void);
65
66 void update_breakpoints ();
67
68 QString file_name (void) const { return m_file_name; }
69 QString encoding (void) const { return m_encoding; }
70
71 signals:
72
73 void tab_ready_to_close (void);
74 void file_name_changed (const QString& fileName,
75 const QString& toolTip,
76 bool modified);
77 void editor_state_changed (bool copy_available, bool is_octave_file,
78 bool is_modified);
81 void tab_remove_request (void);
82 void mru_add_file (const QString& file_name, const QString& encoding);
83 void editor_check_conflict_save (const QString& saveFileName,
84 bool remove_on_success);
85 void run_file_signal (const QFileInfo& info);
86 void request_open_file (const QString&, const QString& = QString ());
87 void edit_mfile_request (const QString&, const QString&,
88 const QString&, int);
89
90 void autoc_closed (void);
91
93
94 void remove_breakpoint_via_debugger_linenr (int debugger_linenr);
97 void find_translated_line_number (int original_linenr,
98 int& translated_linenr, marker*&);
99 void find_linenr_just_before (int linenr, int& original_linenr,
100 int& editor_linenr);
101 void report_marker_linenr (QIntList& lines, QStringList& conditions);
102 void remove_position_via_debugger_linenr (int debugger_linenr);
104
105 void debug_quit_signal (void);
106
109
110 void maybe_remove_next (int remove_line);
111
112 void dbstop_if (const QString& prompt, int line, const QString& cond);
113 void request_add_breakpoint (int line, const QString& cond);
114 void request_add_octave_apis (const QStringList&);
115 void api_entries_added (void);
116
117 void do_save_file_signal (const QString& file_to_save,
118 bool remove_on_success, bool restore_breakpoints);
119
120 void confirm_dbquit_and_save_signal (const QString& file_to_save,
121 const QString& base_name,
122 bool remove_on_success,
123 bool restore_breakpoints);
124
125 // FIXME: The following is similar to "process_octave_code" signal.
126 // However, currently that signal is connected to something that simply
127 // focuses a window and does not actually communicate with Octave.
128 //
129 // void evaluate_octave_command (const QString& command);
130
131 public slots:
132
133 void update_window_title (bool modified);
134 void handle_copy_available (bool enableCopy);
135 void handle_margin_clicked (int line, int margin,
136 Qt::KeyboardModifiers state);
137
138 // Tells the editor tab to react on changed settings.
139 void notice_settings (const gui_settings *settings, bool init = false);
140
141 // Change to a different editor tab by identifier tag.
142 void change_editor_state (const QWidget *ID);
143
144 void set_focus (const QWidget *ID);
145 void set_current_directory (const QString& dir);
146 void context_help (const QWidget *ID, bool);
147 void context_edit (const QWidget *ID);
148 void save_file (const QWidget *ID);
149 void save_file (const QWidget *ID, const QString& fileName,
150 bool remove_on_success);
151 void save_file_as (const QWidget *ID);
152 void print_file (const QWidget *ID);
153 void run_file (const QWidget *ID, bool step_into = false);
154 void context_run (const QWidget *ID);
155 void toggle_bookmark (const QWidget *ID);
156 void next_bookmark (const QWidget *ID);
157 void previous_bookmark (const QWidget *ID);
158 void remove_bookmark (const QWidget *ID);
159
160 void toggle_breakpoint (const QWidget *ID);
161 void next_breakpoint (const QWidget *ID);
162 void previous_breakpoint (const QWidget *ID);
163 void remove_all_breakpoints (const QWidget *ID);
164
165 void scintilla_command (const QWidget *, unsigned int);
166
167 void comment_selected_text (const QWidget *ID, bool input_str);
168 void uncomment_selected_text (const QWidget *ID);
169
170 void indent_selected_text (const QWidget *ID);
171 void unindent_selected_text (const QWidget *ID);
173 void convert_eol (const QWidget *ID, QsciScintilla::EolMode);
174
175 void zoom_in (const QWidget *ID);
176 void zoom_out (const QWidget *ID);
177 void zoom_normal (const QWidget *ID);
178
179 void goto_line (const QWidget *ID, int line = -1);
180 void move_match_brace (const QWidget *ID, bool select);
181 void show_auto_completion (const QWidget *ID);
182
183 void insert_debugger_pointer (const QWidget *ID, int line = -1);
184 void delete_debugger_pointer (const QWidget *ID, int line = -1);
185
186 void do_breakpoint_marker (bool insert, const QWidget *ID, int line = -1,
187 const QString& cond = "");
188
189 void recover_from_exit (void);
190 void set_modified (bool modified = true);
191
192 void set_encoding (const QString& new_encoding);
193
194 QString load_file (const QString& fileName);
195
196 void new_file (const QString& commands = QString ());
197
198 void file_has_changed (const QString& path, bool do_close = false);
199
200 void handle_context_menu_edit (const QString&);
201 void handle_context_menu_break_condition (int linenr);
202
203 void handle_request_add_breakpoint (int line, const QString& cond);
204 void handle_request_remove_breakpoint (int line);
205
207 void update_rowcol_indicator (int line, int col);
208 void update_lexer_settings (bool update_apis_only = false);
209
210 private slots:
211
212 // When user closes message box for decoding problems
213 void handle_decode_warning_answer (QAbstractButton *btn);
214
215 // When user closes message box for reload question.
216 void handle_file_reload_answer (int decision);
217
218 // When user closes message box for resave question.
219 void handle_file_resave_answer (int decision);
220
221 // When user closes QFileDialog box.
222 void handle_save_file_as_answer (const QString& fileName);
223 void handle_save_file_as_answer_close (const QString& fileName);
225 void handle_save_as_filter_selected (const QString& filter);
226
227 // When user changes encoding after decoding errors were found
228 void handle_current_enc_changed (const QString& enc);
229
230 // When apis preparation has finished and is ready to save
231 void save_apis_info (void);
232
233 // When the numer of lines changes -> adapt width of margin
234 void auto_margin_width (void);
235
236 void handle_cursor_moved (int line, int col);
237 void handle_char_added (int character);
238 void handle_double_click (int p, int l, int modifier);
239 void handle_lines_changed (void);
240
241 void handle_remove_next (int remove_line);
242 void handle_dbstop_if (const QString& prompt, int line,
243 const QString& cond);
244 void handle_add_octave_apis (const QStringList& api_entries);
245 void handle_api_entries_added (void);
246
247 void do_save_file (const QString& file_to_save, bool remove_on_success,
248 bool restore_breakpoints);
249
250 void confirm_dbquit_and_save (const QString& file_to_save,
251 const QString& base_name,
252 bool remove_on_success,
253 bool restore_breakpoints);
254
255 protected:
256
257 void closeEvent (QCloseEvent *event);
258 void set_file_name (const QString& fileName);
259
260 private:
261
263
264 void add_breakpoint_event (int line, const QString& cond);
265
266 bool valid_file_name (const QString& file = QString ());
267 void save_file (const QString& saveFileName, bool remove_on_success = false,
268 bool restore_breakpoints = true);
269 void save_file_as (bool remove_on_success = false);
270 bool check_valid_identifier (QString file_name);
271 QTextCodec * check_valid_codec (void);
272
273 bool unchanged_or_saved (void);
274
275 void update_lexer (void);
276
277 void show_dialog (QDialog *dlg, bool modal);
278 public:
279 int check_file_modified (bool remove = false);
280 private:
281 void do_comment_selected_text (bool comment, bool input_str = false);
282 void do_indent_selected_text (bool indent);
284
285 void check_restore_breakpoints (void);
286 void center_current_line (bool always=true);
287
288 QString get_function_name (void);
289
290 QsciScintilla::EolMode detect_eol_mode (void);
291 void update_eol_indicator (void);
292
294
295 QStatusBar *m_status_bar;
300
301 QsciScintilla::EolMode m_save_as_desired_eol;
302
303 QString m_file_name;
305 QString m_ced;
306 QString m_encoding;
309
317
318 QFileSystemWatcher m_file_system_watcher;
319
321 QStringList m_bp_conditions;
322
323 QsciAPIs *m_lexer_apis;
326
330 int m_col;
334
336 {
340 };
341
343 };
344}
345
346#endif
Base class for Octave interfaces that use Qt.
void set_encoding(const QString &new_encoding)
void confirm_dbquit_and_save_signal(const QString &file_to_save, const QString &base_name, bool remove_on_success, bool restore_breakpoints)
void set_file_name(const QString &fileName)
void goto_line(const QWidget *ID, int line=-1)
void report_marker_linenr(QIntList &lines, QStringList &conditions)
QsciScintilla::EolMode m_save_as_desired_eol
void toggle_breakpoint(const QWidget *ID)
void zoom_out(const QWidget *ID)
void delete_debugger_pointer(const QWidget *ID, int line=-1)
void run_file(const QWidget *ID, bool step_into=false)
void remove_breakpoint_via_debugger_linenr(int debugger_linenr)
void save_file_as(const QWidget *ID)
void tab_ready_to_close(void)
void set_current_directory(const QString &dir)
void handle_file_resave_answer(int decision)
file_editor_tab(base_qobject &oct_qobj, const QString &directory="")
A file_editor_tab object consists of a text area and three left margins.
void handle_margin_clicked(int line, int margin, Qt::KeyboardModifiers state)
void handle_save_as_filter_selected(const QString &filter)
void handle_double_click(int p, int l, int modifier)
octave_qscintilla * m_edit_area
void set_modified(bool modified=true)
void dbstop_if(const QString &prompt, int line, const QString &cond)
void handle_request_add_breakpoint(int line, const QString &cond)
void zoom_normal(const QWidget *ID)
void set_focus_editor_signal(QWidget *)
void editor_check_conflict_save(const QString &saveFileName, bool remove_on_success)
void interpreter_event(const fcn_callback &fcn)
bool check_valid_identifier(QString file_name)
QString load_file(const QString &fileName)
void next_bookmark(const QWidget *ID)
void previous_breakpoint(const QWidget *ID)
void update_lexer_settings(bool update_apis_only=false)
void convert_eol(const QWidget *ID, QsciScintilla::EolMode)
void save_file(const QWidget *ID)
void handle_save_file_as_answer(const QString &fileName)
void toggle_bookmark(const QWidget *ID)
void do_comment_selected_text(bool comment, bool input_str=false)
void handle_remove_next(int remove_line)
void handle_file_reload_answer(int decision)
octave_qscintilla * qsci_edit_area(void)
void notice_settings(const gui_settings *settings, bool init=false)
void set_focus(const QWidget *ID)
QFileSystemWatcher m_file_system_watcher
void unindent_selected_text(const QWidget *ID)
void update_window_title(bool modified)
void handle_cursor_moved(int line, int col)
void remove_all_breakpoints_signal(void)
void interpreter_event(const meth_callback &meth)
void update_rowcol_indicator(int line, int col)
void do_breakpoint_marker(bool insert, const QWidget *ID, int line=-1, const QString &cond="")
void request_remove_breakpoint_via_editor_linenr(int editor_linenr)
void update_breakpoints_signal(const octave_value_list &args)
void handle_save_file_as_answer_close(const QString &fileName)
void insert_debugger_pointer(const QWidget *ID, int line=-1)
void move_match_brace(const QWidget *ID, bool select)
void next_breakpoint(const QWidget *ID)
void find_linenr_just_before(int linenr, int &original_linenr, int &editor_linenr)
void show_dialog(QDialog *dlg, bool modal)
void edit_mfile_request(const QString &, const QString &, const QString &, int)
void do_indent_selected_text(bool indent)
void handle_context_menu_edit(const QString &)
void previous_bookmark(const QWidget *ID)
void request_add_breakpoint(int line, const QString &cond)
void editor_state_changed(bool copy_available, bool is_octave_file, bool is_modified)
void update_breakpoints_handler(const octave_value_list &argout)
void handle_save_file_as_answer_cancel(void)
void print_file(const QWidget *ID)
void do_save_file_signal(const QString &file_to_save, bool remove_on_success, bool restore_breakpoints)
void run_file_signal(const QFileInfo &info)
void indent_selected_text(const QWidget *ID)
bool valid_file_name(const QString &file=QString())
void file_name_changed(const QString &fileName, const QString &toolTip, bool modified)
void smart_indent_line_or_selected_text(const QWidget *ID)
void closeEvent(QCloseEvent *event)
base_qobject & m_octave_qobj
void add_breakpoint_event(int line, const QString &cond)
void do_save_file(const QString &file_to_save, bool remove_on_success, bool restore_breakpoints)
int check_file_modified(bool remove=false)
void context_edit(const QWidget *ID)
void uncomment_selected_text(const QWidget *ID)
void handle_current_enc_changed(const QString &enc)
void tab_remove_request(void)
void do_smart_indent_line_or_selected_text(void)
void handle_add_octave_apis(const QStringList &api_entries)
void context_help(const QWidget *ID, bool)
void remove_bookmark(const QWidget *ID)
void find_translated_line_number(int original_linenr, int &translated_linenr, marker *&)
void remove_all_breakpoints(const QWidget *ID)
void debug_quit_signal(void)
void context_run(const QWidget *ID)
void handle_decode_warning_answer(QAbstractButton *btn)
void confirm_dbquit_and_save(const QString &file_to_save, const QString &base_name, bool remove_on_success, bool restore_breakpoints)
void scintilla_command(const QWidget *, unsigned int)
void comment_selected_text(const QWidget *ID, bool input_str)
QsciScintilla::EolMode detect_eol_mode(void)
void change_editor_state(const QWidget *ID)
void maybe_remove_next(int remove_line)
void edit_area_changed(octave_qscintilla *edit_area)
void zoom_in(const QWidget *ID)
void remove_all_positions(void)
void handle_context_menu_break_condition(int linenr)
void handle_char_added(int character)
void file_has_changed(const QString &path, bool do_close=false)
void handle_request_remove_breakpoint(int line)
QString encoding(void) const
void mru_add_file(const QString &file_name, const QString &encoding)
void api_entries_added(void)
void request_open_file(const QString &, const QString &=QString())
void handle_dbstop_if(const QString &prompt, int line, const QString &cond)
void center_current_line(bool always=true)
void remove_position_via_debugger_linenr(int debugger_linenr)
QString file_name(void) const
QTextCodec * check_valid_codec(void)
void new_file(const QString &commands=QString())
void show_auto_completion(const QWidget *ID)
breakpoint_info m_breakpoint_info
void request_add_octave_apis(const QStringList &)
void handle_copy_available(bool enableCopy)
QList< int > QIntList
Definition: dialog.h:40
OCTAVE_NAMESPACE_BEGIN typedef std::function< void(void)> fcn_callback
Definition: event-manager.h:47
std::function< void(interpreter &)> meth_callback
Definition: event-manager.h:48
OCTAVE_NAMESPACE_BEGIN MArray< T > filter(MArray< T > &b, MArray< T > &a, MArray< T > &x, MArray< T > &si, int dim=0)
Definition: filter.cc:48
QString path
static uint32_t state[624]
Definition: randmtzig.cc:192