GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
file-editor.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2015 Jacob Dawid
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifndef FILEEDITORMDISUBWINDOW_H
24 #define FILEEDITORMDISUBWINDOW_H
25 
26 #include <QToolBar>
27 #include <QAction>
28 #include <QMenuBar>
29 #include <QStatusBar>
30 #include <QCloseEvent>
31 #include <QTabWidget>
32 #include <QStackedWidget>
33 
34 #include <QDragEnterEvent>
35 #include <QDropEvent>
36 
37 #include <map>
38 
39 #include "file-editor-interface.h"
40 #include "file-editor-tab.h"
41 
43 {
44  Q_OBJECT
45 
46 public:
47 
48  typedef std::map<QString, QWidget *>::iterator editor_tab_map_iterator;
49  typedef std::map<QString, QWidget *>::const_iterator editor_tab_map_const_iterator;
50 
51  file_editor (QWidget *p);
52  ~file_editor (void);
53 
54  void loadFile (const QString& fileName);
55 
56  QMenu *get_mru_menu (void) { return _mru_file_menu; }
57  QMenu *debug_menu (void);
58  QToolBar *toolbar (void);
59  void insert_new_open_actions (QAction*,QAction*,QAction*);
60 
61  void handle_enter_debug_mode (void);
62  void handle_exit_debug_mode (void);
63 
64  void check_actions (void);
65  void empty_script (bool startup, bool visible);
66 
67 signals:
68 
69  void fetab_settings_changed (const QSettings *settings);
70  void fetab_change_request (const QWidget* ID);
71  void fetab_file_name_query (const QWidget* ID);
72  // Save is a ping-pong type of communication
73  void fetab_save_file (const QWidget* ID, const QString& fileName,
74  bool remove_on_success);
75  // No fetab_open, functionality in editor
76  // No fetab_new, functionality in editor
77  void fetab_context_help (const QWidget* ID, bool);
78  void fetab_context_edit (const QWidget* ID);
79  void fetab_check_modified_file (void);
80  void fetab_save_file (const QWidget* ID);
81  void fetab_save_file_as (const QWidget* ID);
82  void fetab_print_file (const QWidget* ID);
83  void fetab_run_file (const QWidget* ID);
84  void fetab_context_run (const QWidget* ID);
85  void fetab_toggle_bookmark (const QWidget* ID);
86  void fetab_next_bookmark (const QWidget* ID);
87  void fetab_previous_bookmark (const QWidget* ID);
88  void fetab_remove_bookmark (const QWidget* ID);
89  void fetab_toggle_breakpoint (const QWidget* ID);
90  void fetab_next_breakpoint (const QWidget* ID);
91  void fetab_previous_breakpoint (const QWidget* ID);
92  void fetab_remove_all_breakpoints (const QWidget* ID);
93  void fetab_comment_selected_text (const QWidget* ID);
94  void fetab_uncomment_selected_text (const QWidget* ID);
95  void fetab_indent_selected_text (const QWidget* ID);
96  void fetab_unindent_selected_text (const QWidget* ID);
97  void fetab_convert_eol (const QWidget* ID, QsciScintilla::EolMode eol_mode);
98  void fetab_find (const QWidget* ID);
99  void fetab_goto_line (const QWidget* ID, int line = -1);
100  void fetab_move_match_brace (const QWidget* ID, bool select);
101  void fetab_completion (const QWidget*);
102  void fetab_insert_debugger_pointer (const QWidget* ID, int line = -1);
103  void fetab_delete_debugger_pointer (const QWidget* ID, int line = -1);
104  void fetab_do_breakpoint_marker (bool insert, const QWidget* ID,
105  int line = -1);
106  void fetab_set_focus (const QWidget* ID);
107  void fetab_scintilla_command (const QWidget* ID, unsigned int sci_msg);
108 
109  void fetab_zoom_in (const QWidget* ID);
110  void fetab_zoom_out (const QWidget* ID);
111  void fetab_zoom_normal (const QWidget* ID);
112 
113  void fetab_set_directory (const QString& dir);
114 
115  void request_settings_dialog (const QString&);
116  void execute_command_in_terminal_signal (const QString&);
117  void file_loaded_signal ();
118 
119 public slots:
120 
121  void focus (void);
122  void enable_menu_shortcuts (bool);
123  bool check_closing (void);
124 
125  void request_new_file (const QString& commands);
126  void request_new_script (const QString& commands);
127  void request_new_function (bool triggered = true);
128  void request_open_file (void);
129  void request_close_file (bool);
130  void request_close_all_files (bool);
131  void request_close_other_files (bool);
132  void request_mru_open_file (QAction *action);
133  void request_print_file (bool);
134 
135  void request_undo (bool);
136  void request_redo (bool);
137  void request_copy (bool);
138  void request_cut (bool);
139  void request_paste (bool);
140  void request_selectall (bool);
141  void request_context_help (bool);
142  void request_context_doc (bool);
143  void request_context_edit (bool);
144  void request_save_file (bool);
145  void request_save_file_as (bool);
146  void request_run_file (bool);
147  void request_context_run (bool);
148  void request_toggle_bookmark (bool);
149  void request_next_bookmark (bool);
150  void request_previous_bookmark (bool);
151  void request_remove_bookmark (bool);
152 
153  void request_move_match_brace (bool);
154  void request_sel_match_brace (bool);
155  void request_toggle_breakpoint (bool);
156  void request_next_breakpoint (bool);
157  void request_previous_breakpoint (bool);
158  void request_remove_breakpoint (bool);
159 
160  void request_delete_start_word (bool);
161  void request_delete_end_word (bool);
162  void request_delete_start_line (bool);
163  void request_delete_end_line (bool);
164  void request_delete_line (bool);
165  void request_copy_line (bool);
166  void request_cut_line (bool);
167  void request_duplicate_selection (bool);
168  void request_transpose_line (bool);
169 
170  void request_comment_selected_text (bool);
172 
173  void request_upper_case (bool);
174  void request_lower_case (bool);
175  void request_indent_selected_text (bool);
176  void request_unindent_selected_text (bool);
177  void request_conv_eol_windows (bool);
178  void request_conv_eol_unix (bool);
179  void request_conv_eol_mac (bool);
180 
181  void request_find (bool);
182 
183  void request_goto_line (bool);
184  void request_completion (bool);
185 
186  void handle_file_name_changed (const QString& fileName,
187  const QString& toolTip);
188  void handle_tab_close_request (int index);
189  void handle_tab_remove_request (void);
190  void handle_add_filename_to_list (const QString& fileName, QWidget *ID);
191  void active_tab_changed (int index);
192  void handle_editor_state_changed (bool enableCopy, bool is_octave_file);
193  void handle_mru_add_file (const QString& file_name);
194  void check_conflict_save (const QString& fileName, bool remove_on_success);
195 
196  void handle_insert_debugger_pointer_request (const QString& file, int line);
197  void handle_delete_debugger_pointer_request (const QString& file, int line);
198  void handle_update_breakpoint_marker_request (bool insert,
199  const QString& file, int line);
200 
201  void handle_edit_file_request (const QString& file);
202 
203  // Tells the editor to react on changed settings.
204  void notice_settings (const QSettings *settings);
205 
206  void set_shortcuts ();
207 
208  void handle_visibility (bool visible);
209 
210  void update_octave_directory (const QString& dir);
211 
212 protected slots:
213  void copyClipboard ();
214  void pasteClipboard ();
215  void selectAll ();
216  void do_undo ();
217 
218 private slots:
219 
220  void request_open_files (const QStringList&);
221  void request_open_file (const QString& fileName, int line = -1,
222  bool debug_pointer = false,
223  bool breakpoint_marker = false, bool insert = true);
224  void request_preferences (bool);
225  void request_styles_preferences (bool);
227 
228  void show_line_numbers (bool);
229  void show_white_space (bool);
230  void show_eol_chars (bool);
231  void show_indent_guides (bool);
232  void show_long_line (bool);
233  void zoom_in (bool);
234  void zoom_out (bool);
235  void zoom_normal (bool);
236 
237  void create_context_menu (QMenu *);
238  void edit_status_update (bool, bool);
239 
240 protected:
241 
242  void dragEnterEvent(QDragEnterEvent *event);
243  void dropEvent(QDropEvent *event);
244 
245 private:
246 
247  bool is_editor_console_tabbed ();
248  void construct (void);
249  void add_file_editor_tab (file_editor_tab *f, const QString& fn);
250  void save_file_as (QWidget *fetabID = 0);
251  void mru_menu_update (void);
252  bool call_custom_editor (const QString& file_name = QString (), int line = -1);
253 
254  void toggle_preference (const QString& preference, bool def);
255 
256  bool editor_tab_has_focus ();
257 
258  QWidget *find_tab_widget (const QString& openFileName) const;
259  QAction *add_action (QMenu *menu, const QIcon &icon, const QString &text,
260  const char *member);
261 
262  QMenu* m_add_menu (QMenuBar *p, QString text);
263 
264  std::map<QString, QWidget *> editor_tab_map;
265  QHash<QMenu*, QStringList> _hash_menu_text;
266 
267  QString ced;
268 
270  QToolBar *_tool_bar;
271  QMenu *_debug_menu;
272 
273  QAction *_new_action;
275  QAction *_open_action;
276 
286 
287  QAction *_copy_action;
288  QAction *_cut_action;
289  QAction *_paste_action;
293 
299  QAction *_zoom_in_action;
302 
312 
313  QAction *_find_action;
316 
323 
324  QAction *_print_action;
325  QAction *_run_action;
327 
329  QAction *_save_action;
330  QAction *_save_as_action;
331  QAction *_close_action;
334 
335  QAction *_redo_action;
336  QAction *_undo_action;
337 
340 
345 
349  QMenu *_fileMenu;
351 
352  QTabWidget *_tab_widget;
353 
355 
356  enum { MaxMRUFiles = 10 };
359  QStringList _mru_files;
360 };
361 
362 #endif // FILEEDITORMDISUBWINDOW_H
QAction * _delete_end_line_action
Definition: file-editor.h:306
void fetab_save_file(const QWidget *ID, const QString &fileName, bool remove_on_success)
void fetab_set_focus(const QWidget *ID)
void request_save_file(bool)
void dragEnterEvent(QDragEnterEvent *event)
QMenu * _edit_nav_menu
Definition: file-editor.h:348
QAction * _redo_action
Definition: file-editor.h:335
void request_close_file(bool)
void request_delete_start_word(bool)
QMenuBar * _menu_bar
Definition: file-editor.h:269
QAction * _print_action
Definition: file-editor.h:324
void request_save_file_as(bool)
QAction * _toggle_bookmark_action
Definition: file-editor.h:321
~file_editor(void)
void request_delete_start_line(bool)
void fetab_context_run(const QWidget *ID)
void set_shortcuts()
QAction * _show_eol_action
Definition: file-editor.h:296
QAction * _delete_start_word_action
Definition: file-editor.h:303
QAction * _remove_all_breakpoints_action
Definition: file-editor.h:344
void fetab_run_file(const QWidget *ID)
QAction * _goto_line_action
Definition: file-editor.h:314
void request_uncomment_selected_text(bool)
QAction * _next_bookmark_action
Definition: file-editor.h:319
QAction * _sel_to_matching_brace
Definition: file-editor.h:318
void request_selectall(bool)
QAction * _delete_line_action
Definition: file-editor.h:307
void request_delete_line(bool)
void show_white_space(bool)
void fetab_context_edit(const QWidget *ID)
void do_undo()
void fetab_find(const QWidget *ID)
void restore_create_file_setting()
bool is_editor_console_tabbed()
void request_new_file(const QString &commands)
void handle_edit_file_request(const QString &file)
void handle_enter_debug_mode(void)
void fetab_change_request(const QWidget *ID)
void request_duplicate_selection(bool)
void zoom_out(bool)
void fetab_completion(const QWidget *)
void request_indent_selected_text(bool)
void pasteClipboard()
void request_unindent_selected_text(bool)
void fetab_unindent_selected_text(const QWidget *ID)
QAction * _copy_action
Definition: file-editor.h:287
QAction * _new_function_action
Definition: file-editor.h:274
void update_octave_directory(const QString &dir)
QAction * _conv_eol_windows_action
Definition: file-editor.h:283
bool editor_tab_has_focus()
QAction * _conv_eol_unix_action
Definition: file-editor.h:284
QAction * _delete_start_line_action
Definition: file-editor.h:305
QAction * _context_doc_action
Definition: file-editor.h:292
std::map< QString, QWidget * >::iterator editor_tab_map_iterator
Definition: file-editor.h:48
QAction * _delete_end_word_action
Definition: file-editor.h:304
QAction * _undo_action
Definition: file-editor.h:336
void request_new_function(bool triggered=true)
QToolBar * _tool_bar
Definition: file-editor.h:270
void request_delete_end_word(bool)
void request_preferences(bool)
void fetab_delete_debugger_pointer(const QWidget *ID, int line=-1)
void fetab_scintilla_command(const QWidget *ID, unsigned int sci_msg)
void request_find(bool)
void handle_add_filename_to_list(const QString &fileName, QWidget *ID)
void fetab_toggle_bookmark(const QWidget *ID)
QAction * _previous_bookmark_action
Definition: file-editor.h:320
void request_comment_selected_text(bool)
void request_conv_eol_unix(bool)
QAction * _save_action
Definition: file-editor.h:329
void request_completion(bool)
void fetab_zoom_in(const QWidget *ID)
void request_next_breakpoint(bool)
void focus(void)
QAction * _conv_eol_mac_action
Definition: file-editor.h:285
QMenu * _fileMenu
Definition: file-editor.h:349
QAction * _show_whitespace_action
Definition: file-editor.h:295
bool call_custom_editor(const QString &file_name=QString(), int line=-1)
QAction * _open_action
Definition: file-editor.h:275
void show_indent_guides(bool)
QAction * _selectall_action
Definition: file-editor.h:290
QAction * _close_all_action
Definition: file-editor.h:332
void fetab_move_match_brace(const QWidget *ID, bool select)
QAction * _indent_selection_action
Definition: file-editor.h:281
void fetab_uncomment_selected_text(const QWidget *ID)
void check_actions(void)
void request_upper_case(bool)
QAction * _paste_action
Definition: file-editor.h:289
std::map< QString, QWidget * >::const_iterator editor_tab_map_const_iterator
Definition: file-editor.h:49
QAction * _close_others_action
Definition: file-editor.h:333
void empty_script(bool startup, bool visible)
QAction * _show_linenum_action
Definition: file-editor.h:294
QAction * _cut_action
Definition: file-editor.h:288
void handle_update_breakpoint_marker_request(bool insert, const QString &file, int line)
QAction * _move_to_matching_brace
Definition: file-editor.h:317
QAction * add_action(QMenu *menu, const QIcon &icon, const QString &text, const char *member)
void fetab_context_help(const QWidget *ID, bool)
QMenu * _edit_cmd_menu
Definition: file-editor.h:346
void fetab_remove_bookmark(const QWidget *ID)
void handle_insert_debugger_pointer_request(const QString &file, int line)
QAction * _show_longline_action
Definition: file-editor.h:298
QAction * _edit_function_action
Definition: file-editor.h:328
void fetab_save_file_as(const QWidget *ID)
void execute_command_in_terminal_signal(const QString &)
void request_remove_breakpoint(bool)
void request_mru_open_file(QAction *action)
QAction * _run_action
Definition: file-editor.h:325
void fetab_zoom_out(const QWidget *ID)
F77_RET_T const double const double * f
void fetab_convert_eol(const QWidget *ID, QsciScintilla::EolMode eol_mode)
QAction * _cut_line_action
Definition: file-editor.h:309
void fetab_indent_selected_text(const QWidget *ID)
QAction * _previous_breakpoint_action
Definition: file-editor.h:343
void enable_menu_shortcuts(bool)
QString ced
Definition: file-editor.h:267
void request_styles_preferences(bool)
QAction * _show_indguide_action
Definition: file-editor.h:297
void fetab_next_breakpoint(const QWidget *ID)
void request_delete_end_line(bool)
void request_context_doc(bool)
void copyClipboard()
void request_context_edit(bool)
void request_cut(bool)
QAction * _context_help_action
Definition: file-editor.h:291
QAction * _lower_case_action
Definition: file-editor.h:278
QAction * _styles_preferences_action
Definition: file-editor.h:339
QAction * _preferences_action
Definition: file-editor.h:338
void request_next_bookmark(bool)
QAction * _duplicate_selection_action
Definition: file-editor.h:310
bool check_closing(void)
void file_loaded_signal()
QAction * _zoom_normal_action
Definition: file-editor.h:301
QAction * _uncomment_selection_action
Definition: file-editor.h:280
void fetab_zoom_normal(const QWidget *ID)
void check_conflict_save(const QString &fileName, bool remove_on_success)
void request_goto_line(bool)
void show_long_line(bool)
void insert_new_open_actions(QAction *, QAction *, QAction *)
void selectAll()
QAction * _completion_action
Definition: file-editor.h:315
void handle_tab_remove_request(void)
void request_open_files(const QStringList &)
QHash< QMenu *, QStringList > _hash_menu_text
Definition: file-editor.h:265
QAction * _transpose_line_action
Definition: file-editor.h:311
void toggle_preference(const QString &preference, bool def)
void fetab_next_bookmark(const QWidget *ID)
QAction * _unindent_selection_action
Definition: file-editor.h:282
void request_copy(bool)
void request_conv_eol_windows(bool)
QToolBar * toolbar(void)
void request_paste(bool)
void fetab_check_modified_file(void)
void handle_editor_state_changed(bool enableCopy, bool is_octave_file)
QAction * _close_action
Definition: file-editor.h:331
void request_settings_dialog(const QString &)
void request_context_run(bool)
void fetab_settings_changed(const QSettings *settings)
QAction * _next_breakpoint_action
Definition: file-editor.h:342
void handle_exit_debug_mode(void)
QMenu * _mru_file_menu
Definition: file-editor.h:357
void mru_menu_update(void)
void fetab_file_name_query(const QWidget *ID)
void show_eol_chars(bool)
QMenu * debug_menu(void)
void handle_tab_close_request(int index)
void notice_settings(const QSettings *settings)
QAction * _save_as_action
Definition: file-editor.h:330
void request_cut_line(bool)
void request_previous_breakpoint(bool)
void handle_delete_debugger_pointer_request(const QString &file, int line)
int _marker_breakpoint
Definition: file-editor.h:354
void request_context_help(bool)
void request_toggle_breakpoint(bool)
void request_remove_bookmark(bool)
void request_sel_match_brace(bool)
void request_run_file(bool)
QStringList _mru_files
Definition: file-editor.h:359
void fetab_print_file(const QWidget *ID)
QMenu * _edit_fmt_menu
Definition: file-editor.h:347
QTabWidget * _tab_widget
Definition: file-editor.h:352
void handle_mru_add_file(const QString &file_name)
void loadFile(const QString &fileName)
QMenu * get_mru_menu(void)
Definition: file-editor.h:56
void request_conv_eol_mac(bool)
void request_open_file(void)
void request_new_script(const QString &commands)
QMenu * m_add_menu(QMenuBar *p, QString text)
void create_context_menu(QMenu *)
void request_move_match_brace(bool)
QAction * _find_action
Definition: file-editor.h:313
void request_close_other_files(bool)
void zoom_normal(bool)
void zoom_in(bool)
void fetab_comment_selected_text(const QWidget *ID)
QWidget * find_tab_widget(const QString &openFileName) const
void edit_status_update(bool, bool)
void request_redo(bool)
void fetab_set_directory(const QString &dir)
QAction * _new_action
Definition: file-editor.h:273
void fetab_goto_line(const QWidget *ID, int line=-1)
void request_print_file(bool)
QAction * _mru_file_actions[MaxMRUFiles]
Definition: file-editor.h:358
QAction * _upper_case_action
Definition: file-editor.h:277
QAction * _toggle_breakpoint_action
Definition: file-editor.h:341
void handle_visibility(bool visible)
void request_copy_line(bool)
QMenu * _debug_menu
Definition: file-editor.h:271
QAction * _run_selection_action
Definition: file-editor.h:326
void active_tab_changed(int index)
void fetab_remove_all_breakpoints(const QWidget *ID)
void fetab_toggle_breakpoint(const QWidget *ID)
QAction * _zoom_in_action
Definition: file-editor.h:299
void handle_file_name_changed(const QString &fileName, const QString &toolTip)
void request_previous_bookmark(bool)
void request_close_all_files(bool)
QAction * _copy_line_action
Definition: file-editor.h:308
void fetab_previous_breakpoint(const QWidget *ID)
void fetab_insert_debugger_pointer(const QWidget *ID, int line=-1)
void add_file_editor_tab(file_editor_tab *f, const QString &fn)
void construct(void)
void fetab_do_breakpoint_marker(bool insert, const QWidget *ID, int line=-1)
QAction * _remove_bookmark_action
Definition: file-editor.h:322
QAction * _comment_selection_action
Definition: file-editor.h:279
QAction * _zoom_out_action
Definition: file-editor.h:300
void save_file_as(QWidget *fetabID=0)
void dropEvent(QDropEvent *event)
std::map< QString, QWidget * > editor_tab_map
Definition: file-editor.h:264
void request_lower_case(bool)
file_editor(QWidget *p)
void request_toggle_bookmark(bool)
void request_transpose_line(bool)
void request_undo(bool)
QMenu * _view_editor_menu
Definition: file-editor.h:350
void fetab_previous_bookmark(const QWidget *ID)
void show_line_numbers(bool)