Mercurial > octave-nkf
annotate libgui/src/m-editor/octave-qscintilla.cc @ 18459:f01ac1bb8a5d gui-release
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
* file-editor.cc (zoom_in): slot for zoom-in action, triggering signal for tab;
(zoom_out): slot for zoom-out action, triggering signal for tab;
(zoom_normal): slot for zoom-to-normal action, triggering signal for tab;
(construct): new View-menu with zoom-in, zoom-out and zoom-normal entries;
(add_file_editor_tab): connect zoom-signal to newly created tabs;
(set_shortcuts): set shortcuts for new zoom actions;
(check_actions): disable zoom action when no editor tab is open
* file-editor.h: zoom-in, zoom-out and zoom-normal actions, related slots
and related signals to the actual tab
* file-editor-tab.cc (zoom_in): new slot for signal from file_editor;
(zoom_out): new slot for signal from file_editor;
(zoom_normal): new slot for signal from file_editor
* file-editor-tab.h: new slots zoom_in, zoom_out, zoom_normal
* octave-qscintilla.cc (eventFilter): event filter for overriding qscintilla
internal shortcuts;
(constructor): install event filter
* octave-qscintilla.h: event filter
author | Torsten <ttl@justmail.de> |
---|---|
date | Thu, 13 Feb 2014 20:39:09 +0100 |
parents | 86c6ae5f969e |
children | f959c63934e6 |
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 |
16768 | 3 Copyright (C) 2013 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 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
10 option) any later version. |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
11 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See 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
|
15 for more details. |
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 | |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
25 #ifdef HAVE_CONFIG_H |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
26 #include <config.h> |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
27 #endif |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
28 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
29 #ifdef HAVE_QSCINTILLA |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
30 |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
31 #include <Qsci/qscilexer.h> |
18459
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
32 #include <QShortcut> |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
33 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
34 #include "octave-qscintilla.h" |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
35 #include "file-editor-tab.h" |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
36 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
37 octave_qscintilla::octave_qscintilla (QWidget *p) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
38 : QsciScintilla (p) |
18459
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
39 { |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
40 installEventFilter (this); |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
41 } |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
42 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
43 octave_qscintilla::~octave_qscintilla () |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
44 { } |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
45 |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
46 void |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
47 octave_qscintilla::get_global_textcursor_pos (QPoint *global_pos, |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
48 QPoint *local_pos) |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
49 { |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
50 long position = SendScintilla (QsciScintillaBase::SCI_GETCURRENTPOS); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
51 long point_x = SendScintilla |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
52 (QsciScintillaBase::SCI_POINTXFROMPOSITION,0,position); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
53 long point_y = SendScintilla |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
54 (QsciScintillaBase::SCI_POINTYFROMPOSITION,0,position); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
55 *local_pos = QPoint (point_x,point_y); // local cursor position |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
56 *global_pos = mapToGlobal (*local_pos); // global position of cursor |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
57 } |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
58 |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
59 // determine the actual word and whether we are in an octave or matlab script |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
60 bool |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
61 octave_qscintilla::get_actual_word () |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
62 { |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
63 QPoint global_pos, local_pos; |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
64 get_global_textcursor_pos (&global_pos, &local_pos); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
65 _word_at_cursor = wordAtPoint (local_pos); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
66 QString lexer_name = lexer ()->lexer (); |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
67 return ((lexer_name == "octave" || lexer_name == "matlab") |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
68 && !_word_at_cursor.isEmpty ()); |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
69 } |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
70 |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
71 // call documentation or help on the current word |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
72 void |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
73 octave_qscintilla::context_help_doc (bool documentation) |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
74 { |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
75 if (get_actual_word ()) |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
76 contextmenu_help_doc (documentation); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
77 } |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
78 |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
79 // call edit the function related to the current word |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
80 void |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
81 octave_qscintilla::context_edit () |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
82 { |
17655
b4783277bd11
*octave-qscintilla.cc: fix edit function at cursor by shortcut Ctrl-E
Torsten <ttl@justmail.de>
parents:
17635
diff
changeset
|
83 if (get_actual_word ()) |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
84 contextmenu_edit (true); |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
85 } |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
86 |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
87 // call edit the function related to the current word |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
88 void |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
89 octave_qscintilla::context_run () |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
90 { |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
91 if (hasSelectedText ()) |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
92 contextmenu_run (true); |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
93 } |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
94 |
16733
2723d1144f11
added test for qscintilla version 2.6.0
Torsten <ttl@justmail.de>
parents:
16731
diff
changeset
|
95 #ifdef HAVE_QSCI_VERSION_2_6_0 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
96 // context menu requested |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
97 void |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
98 octave_qscintilla::contextMenuEvent (QContextMenuEvent *e) |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
99 { |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
100 QMenu *context_menu = createStandardContextMenu ( ); // standard menu |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
101 |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
102 // the menu's position |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
103 QPoint global_pos, local_pos; |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
104 |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
105 if (e->reason () == QContextMenuEvent::Mouse) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
106 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
107 // context menu by mouse |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
108 global_pos = e->globalPos (); // global mouse position |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
109 local_pos = e->pos (); // local mouse position |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
110 } |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
111 else |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
112 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
113 // context menu by keyboard or other: get point of text cursor |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
114 get_global_textcursor_pos (&global_pos, &local_pos); |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
115 QRect editor_rect = geometry (); // editor rect mapped to global |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
116 editor_rect.moveTopLeft |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
117 (parentWidget ()->mapToGlobal (editor_rect.topLeft ())); |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
118 if (!editor_rect.contains (global_pos)) // is cursor outside editor? |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
119 global_pos = editor_rect.topLeft (); // yes, take top left corner |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
120 } |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
121 |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
122 // additional custom entries of the context menu |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
123 context_menu->addSeparator (); // separator before custom entries |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
124 |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
125 // help menu: get the position of the mouse or the text cursor |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
126 // (only for octave files) |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
127 QString lexer_name = lexer ()->lexer (); |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
128 if (lexer_name == "octave" || lexer_name == "matlab") |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
129 { |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
130 _word_at_cursor = wordAtPoint (local_pos); |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
131 if (!_word_at_cursor.isEmpty ()) |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
132 { |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
133 context_menu->addAction (tr ("Help on") + " " + _word_at_cursor, |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
134 this, SLOT (contextmenu_help (bool))); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
135 context_menu->addAction (tr ("Documentation on") |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
136 + " " + _word_at_cursor, |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
137 this, SLOT (contextmenu_doc (bool))); |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
138 context_menu->addAction (tr ("Edit") + " " + _word_at_cursor, |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
139 this, SLOT (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
|
140 } |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
141 context_menu->addSeparator (); // separator before custom entries |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
142 if (hasSelectedText ()) |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
143 context_menu->addAction (tr ("&Run Selection"), |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
144 this, SLOT (contextmenu_run (bool))); |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
145 } |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
146 |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
147 // finaly show the menu |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
148 context_menu->exec (global_pos); |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
149 } |
16733
2723d1144f11
added test for qscintilla version 2.6.0
Torsten <ttl@justmail.de>
parents:
16731
diff
changeset
|
150 #endif |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
151 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
152 |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
153 // handle the menu entry for calling help or doc |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
154 void |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
155 octave_qscintilla::contextmenu_doc (bool) |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
156 { |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
157 contextmenu_help_doc (true); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
158 } |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
159 void |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
160 octave_qscintilla::contextmenu_help (bool) |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
161 { |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
162 contextmenu_help_doc (false); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
163 } |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
164 |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
165 // common function with flag for documentation |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
166 void |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
167 octave_qscintilla::contextmenu_help_doc (bool documentation) |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
168 { |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
169 QString command; |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
170 if (documentation) |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
171 command = "doc "; |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
172 else |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
173 command = "help "; |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
174 emit execute_command_in_terminal_signal (command + _word_at_cursor); |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
175 } |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
176 |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
177 void |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
178 octave_qscintilla::contextmenu_edit (bool) |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
179 { |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
180 emit execute_command_in_terminal_signal (QString("edit ") + _word_at_cursor); |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
181 } |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
182 |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
183 void |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
184 octave_qscintilla::contextmenu_run (bool) |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
185 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
186 QStringList commands = selectedText ().split (QRegExp("[\r\n]"), |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
187 QString::SkipEmptyParts); |
17669
b7670c05731b
*octave-qscintilla.cc(contextmenu_run): split selection into single commands
Torsten <ttl@justmail.de>
parents:
17655
diff
changeset
|
188 for (int i = 0; i < commands.size (); i++ ) |
b7670c05731b
*octave-qscintilla.cc(contextmenu_run): split selection into single commands
Torsten <ttl@justmail.de>
parents:
17655
diff
changeset
|
189 emit execute_command_in_terminal_signal (commands.at (i)); |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
190 } |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
191 |
18459
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
192 bool |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
193 octave_qscintilla::eventFilter(QObject *obj, QEvent *e) |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
194 { |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
195 if (e->type() == QEvent::ShortcutOverride) |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
196 return true; |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
197 else |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
198 return QObject::eventFilter(obj, e); |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
199 } |
f01ac1bb8a5d
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
200 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
201 #endif |