Mercurial > octave
annotate libgui/src/m-editor/octave-qscintilla.h @ 23771:ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
* file-editor-tab.cc (notice_settings): _auto_endif is stored in
file_editor_tab, not in octave_qscintilla;
(handle_cursor_moved): new paramters for octave_qscintilla::smart_indent
* file-editor-tab.h: _auto_endif is stored in this class
* octave-qscintilla.cc (octave_qscintilla): no initializaiton of _auto_endif;
(is_end): declare parameters as const QString&;
(keyPressEvent): removed, no key-press event required anymore;
(auto_close): new function instead, which is called by smart_indent, where
some of the analysis from keyPressEvent was already made;
(smart_indent): new parameters, it is called even if smart indentation is
not desired, but auto close is, calls auto close if required;
* octave-qscintilla.h: removed set_auto_endif, new parameters for smart_indent,
removed keyPressEvent, removed variable _auto_endif, new function auto_close
instead of keyPressEvent
author | Torsten <mttl@mailbox.org> |
---|---|
date | Wed, 19 Jul 2017 22:02:30 +0200 |
parents | b729e97aa8d1 |
children | 387be1a6c3dc |
rev | line source |
---|---|
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
1 /* |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
2 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2013-2017 Torsten |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
4 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
5 This file is part of Octave. |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
6 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
10 (at your option) any later version. |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
15 GNU General Public License for more details. |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
16 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
20 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
21 */ |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
22 |
16768 | 23 // Author: Torsten <ttl@justmail.de> |
24 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20277
diff
changeset
|
25 #if ! defined (octave_octave_qscintilla_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17635
diff
changeset
|
26 #define octave_octave_qscintilla_h 1 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
27 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
28 #include <Qsci/qsciscintilla.h> |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
29 #include <QMenu> |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
30 #include <QContextMenuEvent> |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
31 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
32 class octave_qscintilla : public QsciScintilla |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
33 { |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
34 Q_OBJECT |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
35 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
36 public: |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
37 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
38 octave_qscintilla (QWidget *p); |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
39 ~octave_qscintilla (); |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
40 |
23236
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
41 enum |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
42 { |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
43 ST_NONE = 0, |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
44 ST_LINE_COMMENT, |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
45 ST_BLOCK_COMMENT |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
46 }; |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
47 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
48 virtual void contextMenuEvent (QContextMenuEvent *e); |
20277
48d9001bdee3
Avoid HAVE_ macros in header file.
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
49 |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
50 void context_help_doc (bool); |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
51 void context_edit (); |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
52 void context_run (); |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
53 void get_global_textcursor_pos (QPoint *global_pos, QPoint *local_pos); |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
54 bool get_actual_word (); |
23190
4a2c42792d6c
highlight all occurrences of a selected word in the editor (bug #41470)
Torsten <mttl@mailbox.org>
parents:
23084
diff
changeset
|
55 void clear_indicator (int indicator_style); |
23230
f7fdc9ef3971
improve line breaking in the editor
Torsten <mttl@mailbox.org>
parents:
23220
diff
changeset
|
56 void get_current_position (int *pos, int *line, int *col); |
23234
aaf20024db6f
function providing comment strings uses lexer number and not lexer names
Torsten <mttl@mailbox.org>
parents:
23230
diff
changeset
|
57 QString comment_string (); |
23236
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
58 int get_style (int pos = -1); |
4cd5f975d26c
automatically add a comment string when line breaking in line comments
Torsten <mttl@mailbox.org>
parents:
23234
diff
changeset
|
59 int is_style_comment (int pos = -1); |
23771
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23689
diff
changeset
|
60 void smart_indent (bool do_smart_indent, int do_auto_close, int line); |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
61 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
62 signals: |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
63 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
64 void execute_command_in_terminal_signal (const QString&); |
18687
99e26cb0f87f
use the actions from the editor for the context menu
Torsten <ttl@justmail.de>
parents:
18684
diff
changeset
|
65 void create_context_menu_signal (QMenu*); |
19004
e87e65bc71ae
improved finding a function file for editing in gui (bug #41509)
Torsten <ttl@justmail.de>
parents:
18689
diff
changeset
|
66 void context_menu_edit_signal (const QString&); |
18684
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
67 void qsci_has_focus_signal (bool); |
18689
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
68 void status_update (bool,bool); |
19606
3156773fcc80
open a doc page from editor directly without command window
Torsten <ttl@justmail.de>
parents:
19426
diff
changeset
|
69 void show_doc_signal (const QString&); |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20986
diff
changeset
|
70 void context_menu_break_condition_signal (int); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20986
diff
changeset
|
71 void context_menu_break_once (int); |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
72 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
73 private slots: |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
74 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
75 void contextmenu_help (bool); |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
76 void contextmenu_doc (bool); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
77 void contextmenu_help_doc (bool); |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
78 void contextmenu_edit (bool); |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
79 void contextmenu_run (bool); |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
80 |
21158
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20986
diff
changeset
|
81 void contextmenu_break_condition (bool); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20986
diff
changeset
|
82 void contextmenu_break_once (const QPoint&); |
65827e9cccb8
Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20986
diff
changeset
|
83 |
18689
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
84 void text_changed (void); |
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
85 |
18684
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
86 protected: |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
87 |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
88 void focusInEvent (QFocusEvent *focusEvent); |
20986
00835323fb44
prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents:
20791
diff
changeset
|
89 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
90 private: |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
91 |
23771
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23689
diff
changeset
|
92 void auto_close (int auto_endif, int l, |
ed492a5a47fd
eliminate duplicate code in editor smart indentation and auto close
Torsten <mttl@mailbox.org>
parents:
23689
diff
changeset
|
93 const QString& line, QString& first_word); |
23688
cb36684b7a33
In the GUI editor, automatically add "endif" for "if" etc.
Lachlan Andrew <lachlanbis@gmail.com>
parents:
23236
diff
changeset
|
94 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
95 QString _word_at_cursor; |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
96 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
97 }; |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
98 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
99 #endif |