annotate libgui/src/m-editor/octave-qscintilla.cc @ 17655:b4783277bd11

*octave-qscintilla.cc: fix edit function at cursor by shortcut Ctrl-E
author Torsten <ttl@justmail.de>
date Mon, 14 Oct 2013 22:27:07 +0200
parents 7945344506ae
children b7670c05731b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16735
diff changeset
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
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16735
diff changeset
23 // Author: Torsten <ttl@justmail.de>
e2de3c8882be copyright notice fixes
John W. Eaton <jwe@octave.org>
parents: 16735
diff changeset
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>
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
32
16731
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
33 #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
34 #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
35
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
36 octave_qscintilla::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
37 : QsciScintilla (p)
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
38 { }
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
39
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
40 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
41 { }
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
42
17627
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
43 void
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
44 octave_qscintilla::get_global_textcursor_pos (QPoint *global_pos, QPoint *local_pos)
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
45 {
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
46 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
47 long point_x = SendScintilla
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
48 (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
49 long point_y = SendScintilla
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
50 (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
51 *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
52 *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
53 }
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
54
17628
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
55 // 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
56 bool
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
57 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
58 {
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
59 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
60 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
61 _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
62 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
63 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
64 && !_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
65 }
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
66
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
67 // 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
68 void
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
69 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
70 {
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
71 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
72 contextmenu_help_doc (documentation);
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
73 }
16731
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
74
17628
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
75 // 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
76 void
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
77 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
78 {
17655
b4783277bd11 *octave-qscintilla.cc: fix edit function at cursor by shortcut Ctrl-E
Torsten <ttl@justmail.de>
parents: 17635
diff changeset
79 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
80 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
81 }
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
82
17635
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
83 // 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
84 void
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
85 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
86 {
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
87 if (hasSelectedText ())
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
88 contextmenu_run (true);
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
89 }
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
90
16733
2723d1144f11 added test for qscintilla version 2.6.0
Torsten <ttl@justmail.de>
parents: 16731
diff changeset
91 #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
92 // 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
93 void
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
94 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
95 {
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
96 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
97
16735
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
98 // the menu's position
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
99 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
100
16735
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
101 if (e->reason () == QContextMenuEvent::Mouse)
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
102 { // context menu by mouse
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
103 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
104 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
105 }
16731
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
106 else
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
107 { // 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
108 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
109 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
110 editor_rect.moveTopLeft
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
111 (parentWidget ()->mapToGlobal (editor_rect.topLeft ()));
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
112 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
113 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
114 }
16735
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
115
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
116 // 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
117 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
118
16735
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
119 // 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
120 // (only for octave files)
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
121 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
122 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
123 {
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
124 _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
125 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
126 {
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
127 context_menu->addAction (tr ("Help on") + " " + _word_at_cursor,
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
128 this, SLOT (contextmenu_help (bool)));
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
129 context_menu->addAction (tr ("Documentation on") + " " + _word_at_cursor,
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
130 this, SLOT (contextmenu_doc (bool)));
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
131 context_menu->addAction (tr ("Edit") + " " + _word_at_cursor,
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
132 this, SLOT (contextmenu_edit (bool)));
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
133 }
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
134 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
135 if (hasSelectedText ())
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
136 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
137 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
138 }
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
139
cee305c91e91 show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents: 16733
diff changeset
140 // 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
141 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
142 }
16733
2723d1144f11 added test for qscintilla version 2.6.0
Torsten <ttl@justmail.de>
parents: 16731
diff changeset
143 #endif
16731
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
144
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
145
17627
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
146 // 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
147 void
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
148 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
149 {
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
150 contextmenu_help_doc (true);
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
151 }
16731
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
152 void
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
153 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
154 {
17627
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
155 contextmenu_help_doc (false);
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
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
158 // 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
159 void
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
160 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
161 {
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
162 QString command;
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
163 if (documentation)
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
164 command = "doc ";
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
165 else
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
166 command = "help ";
811019b9ef57 Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents: 16768
diff changeset
167 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
168 }
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
169
17628
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
170 void
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
171 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
172 {
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
173 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
174 }
99ffa521ecec Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents: 17627
diff changeset
175
17635
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
176 void
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
177 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
178 {
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
179 QString command = selectedText ();
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
180 emit execute_command_in_terminal_signal (command);
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
181 }
7945344506ae Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents: 17628
diff changeset
182
16731
01d523d5f796 add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff changeset
183 #endif