Mercurial > octave-dspies
annotate libgui/src/m-editor/octave-qscintilla.cc @ 19002:00b1d60500bd gui-release
improved finding a function file for editing in gui (case 1 in bug #41509)
* octave-qscintilla.cc (contextmenu_edit): call F__which__ to get the
correct path of a function file even it is a class function
author | Torsten <ttl@justmail.de> |
---|---|
date | Sun, 10 Aug 2014 19:31:42 +0200 |
parents | c6b89c4a9e63 |
children | e87e65bc71ae |
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> |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
32 #include <Qsci/qscicommandset.h> |
18560
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
33 #include <QShortcut> |
19002
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
34 #include <QMessageBox> |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
35 #include <oct-map.h> |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
36 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
37 #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
|
38 #include "file-editor-tab.h" |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
39 #include "shortcut-manager.h" |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
40 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
41 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
|
42 : QsciScintilla (p) |
18560
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
43 { |
18689
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
44 connect (this, SIGNAL (textChanged ()), this, SLOT (text_changed ())); |
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
45 |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
46 // clear scintilla edit shortcuts that are handled by the editor |
18675
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
47 QsciCommandSet *cmd_set = standardCommands (); |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
48 |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
49 #ifdef HAVE_QSCI_VERSION_2_6_0 |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
50 // find () was added in QScintilla 2.6 |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
51 cmd_set->find (QsciCommand::SelectionCopy)->setKey (0); |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
52 cmd_set->find (QsciCommand::SelectionCut)->setKey (0); |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
53 cmd_set->find (QsciCommand::Paste)->setKey (0); |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
54 cmd_set->find (QsciCommand::SelectAll)->setKey (0); |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
55 cmd_set->find (QsciCommand::SelectionDuplicate)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
56 cmd_set->find (QsciCommand::LineTranspose)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
57 cmd_set->find (QsciCommand::Undo)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
58 cmd_set->find (QsciCommand::Redo)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
59 cmd_set->find (QsciCommand::SelectionUpperCase)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
60 cmd_set->find (QsciCommand::SelectionLowerCase)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
61 cmd_set->find (QsciCommand::ZoomIn)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
62 cmd_set->find (QsciCommand::ZoomOut)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
63 cmd_set->find (QsciCommand::DeleteWordLeft)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
64 cmd_set->find (QsciCommand::DeleteWordRight)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
65 cmd_set->find (QsciCommand::DeleteLineLeft)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
66 cmd_set->find (QsciCommand::DeleteLineRight)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
67 cmd_set->find (QsciCommand::LineDelete)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
68 cmd_set->find (QsciCommand::LineCut)->setKey (0); |
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
69 cmd_set->find (QsciCommand::LineCopy)->setKey (0); |
18675
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
70 #else |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
71 // find commands via its default key (tricky way without find ()) |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
72 QList< QsciCommand * > cmd_list = cmd_set->commands (); |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
73 for (int i = 0; i < cmd_list.length (); i++) |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
74 { |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
75 int cmd_key = cmd_list.at (i)->key (); |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
76 switch (cmd_key) |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
77 { |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
78 case Qt::Key_C | Qt::CTRL : // SelectionCopy |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
79 case Qt::Key_X | Qt::CTRL : // SelectionCut |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
80 case Qt::Key_V | Qt::CTRL : // Paste |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
81 case Qt::Key_A | Qt::CTRL : // SelectAll |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
82 case Qt::Key_D | Qt::CTRL : // SelectionDuplicate |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
83 case Qt::Key_T | Qt::CTRL : // LineTranspose |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
84 case Qt::Key_Z | Qt::CTRL : // Undo |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
85 case Qt::Key_Y | Qt::CTRL : // Redo |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
86 case Qt::Key_Z | Qt::CTRL | Qt::SHIFT : // Redo |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
87 case Qt::Key_U | Qt::CTRL : // SelectionLowerCase |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
88 case Qt::Key_U | Qt::CTRL | Qt::SHIFT : // SelectionUpperCase |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
89 case Qt::Key_Plus | Qt::CTRL : // ZoomIn |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
90 case Qt::Key_Minus | Qt::CTRL : // ZoomOut |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
91 case Qt::Key_Backspace | Qt::CTRL | Qt::SHIFT : // DeleteLineLeft |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
92 case Qt::Key_Delete | Qt::CTRL | Qt::SHIFT : // DeleteLineRight |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
93 case Qt::Key_K | Qt::META : // DeleteLineRight |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
94 case Qt::Key_Backspace | Qt::CTRL : // DeleteWordLeft |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
95 case Qt::Key_Delete | Qt::CTRL : // DeleteWordRight |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
96 case Qt::Key_L | Qt::CTRL | Qt::SHIFT : // LineDelete |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
97 case Qt::Key_L | Qt::CTRL : // LineCut |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
98 case Qt::Key_T | Qt::CTRL | Qt::SHIFT : // LineCopy |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
99 cmd_list.at (i)->setKey (0); |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
100 } |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
101 } |
c199304dfb2a
handling qscintilla internal shortcuts and commands depending on qsci version
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
102 #endif |
18954
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
103 |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
104 #if defined (Q_OS_MAC) |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
105 // Octave interprets Cmd key as Meta whereas Qscintilla interprets it |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
106 // as Ctrl. We thus invert Meta/Ctrl in Qscintilla's shortcuts list. |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
107 QList< QsciCommand * > cmd_list_mac = cmd_set->commands (); |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
108 for (int i = 0; i < cmd_list_mac.length (); i++) |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
109 { |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
110 // Primary key |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
111 int key = cmd_list_mac.at (i)->key (); |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
112 |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
113 if (static_cast<int> (key | Qt::META) == key && |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
114 static_cast<int> (key | Qt::CTRL) != key) |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
115 key = (key ^ Qt::META) | Qt::CTRL; |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
116 else if (static_cast<int> (key | Qt::CTRL) == key) |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
117 key = (key ^ Qt::CTRL) | Qt::META; |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
118 |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
119 cmd_list_mac.at (i)->setKey (key); |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
120 |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
121 // Alternate key |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
122 key = cmd_list_mac.at (i)->alternateKey (); |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
123 |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
124 if (static_cast<int> (key | Qt::META) == key && |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
125 static_cast<int> (key | Qt::CTRL) != key) |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
126 key = (key ^ Qt::META) | Qt::CTRL; |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
127 else if (static_cast<int> (key | Qt::CTRL) == key) |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
128 key = (key ^ Qt::CTRL) | Qt::META; |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
129 |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
130 cmd_list_mac.at (i)->setAlternateKey (key); |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
131 } |
c6b89c4a9e63
Swap Ctrl and Meta in Qscintilla shortcut list for mac (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18767
diff
changeset
|
132 #endif |
18560
26d15a57f45b
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
Torsten <ttl@justmail.de>
parents:
18460
diff
changeset
|
133 } |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
134 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
135 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
|
136 { } |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
137 |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
138 void |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
139 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
|
140 QPoint *local_pos) |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
141 { |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
142 long position = SendScintilla (SCI_GETCURRENTPOS); |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
143 long point_x = SendScintilla |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
144 (SCI_POINTXFROMPOSITION,0,position); |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
145 long point_y = SendScintilla |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18560
diff
changeset
|
146 (SCI_POINTYFROMPOSITION,0,position); |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
147 *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
|
148 *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
|
149 } |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
150 |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
151 // 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
|
152 bool |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
153 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
|
154 { |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
155 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
|
156 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
|
157 _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
|
158 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
|
159 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
|
160 && !_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
|
161 } |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
162 |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
163 // 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
|
164 void |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
165 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
|
166 { |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
167 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
|
168 contextmenu_help_doc (documentation); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
169 } |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
170 |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
171 // 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
|
172 void |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
173 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
|
174 { |
17655
b4783277bd11
*octave-qscintilla.cc: fix edit function at cursor by shortcut Ctrl-E
Torsten <ttl@justmail.de>
parents:
17635
diff
changeset
|
175 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
|
176 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
|
177 } |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
178 |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
179 // 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
|
180 void |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
181 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
|
182 { |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
183 if (hasSelectedText ()) |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
184 contextmenu_run (true); |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
185 } |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
186 |
16733
2723d1144f11
added test for qscintilla version 2.6.0
Torsten <ttl@justmail.de>
parents:
16731
diff
changeset
|
187 #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
|
188 // 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
|
189 void |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
190 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
|
191 { |
18687
99e26cb0f87f
use the actions from the editor for the context menu
Torsten <ttl@justmail.de>
parents:
18684
diff
changeset
|
192 QPoint global_pos, local_pos; // the menu's position |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
193 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
|
194 |
18687
99e26cb0f87f
use the actions from the editor for the context menu
Torsten <ttl@justmail.de>
parents:
18684
diff
changeset
|
195 // fill context menu with editor's standard actions |
99e26cb0f87f
use the actions from the editor for the context menu
Torsten <ttl@justmail.de>
parents:
18684
diff
changeset
|
196 emit create_context_menu_signal (context_menu); |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
197 |
18687
99e26cb0f87f
use the actions from the editor for the context menu
Torsten <ttl@justmail.de>
parents:
18684
diff
changeset
|
198 // determine position depending on mouse or keyboard event |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
199 if (e->reason () == QContextMenuEvent::Mouse) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
200 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
201 // 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
|
202 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
|
203 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
|
204 } |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
205 else |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
206 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
207 // 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
|
208 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
|
209 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
|
210 editor_rect.moveTopLeft |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
211 (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
|
212 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
|
213 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
|
214 } |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
215 |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
216 // 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
|
217 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
|
218 |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
219 // 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
|
220 // (only for octave files) |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
221 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
|
222 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
|
223 { |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
224 _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
|
225 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
|
226 { |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
227 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
|
228 this, SLOT (contextmenu_help (bool))); |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
229 context_menu->addAction (tr ("Documentation on") |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
230 + " " + _word_at_cursor, |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
231 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
|
232 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
|
233 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
|
234 } |
16735
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
235 } |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
236 |
cee305c91e91
show help menu in editors context menu only for octave files
Torsten <ttl@justmail.de>
parents:
16733
diff
changeset
|
237 // 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
|
238 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
|
239 } |
16733
2723d1144f11
added test for qscintilla version 2.6.0
Torsten <ttl@justmail.de>
parents:
16731
diff
changeset
|
240 #endif |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
241 |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
242 |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
243 // 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
|
244 void |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
245 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
|
246 { |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
247 contextmenu_help_doc (true); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
248 } |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
249 void |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
250 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
|
251 { |
17627
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
252 contextmenu_help_doc (false); |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
253 } |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
254 |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
255 // 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
|
256 void |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
257 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
|
258 { |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
259 QString command; |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
260 if (documentation) |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
261 command = "doc "; |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
262 else |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
263 command = "help "; |
811019b9ef57
Add help and documentation on actual keyword to the editor menu
Torsten <ttl@justmail.de>
parents:
16768
diff
changeset
|
264 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
|
265 } |
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
266 |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
267 void |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
268 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
|
269 { |
19002
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
270 octave_value_list fct = F__which__ (ovl (_word_at_cursor.toStdString ()),0); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
271 octave_map map = fct(0).map_value (); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
272 |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
273 QString type = QString::fromStdString ( |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
274 map.contents ("type").data ()[0].string_value ()); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
275 QString name = QString::fromStdString ( |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
276 map.contents ("name").data ()[0].string_value ()); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
277 |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
278 QString message = QString (); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
279 |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
280 if (type.isEmpty ()) |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
281 message = tr ("Can not find function %1"); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
282 else if (type == QString("built-in function")) |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
283 message = tr ("%1 is a built-in function"); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
284 |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
285 if (! message.isEmpty ()) |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
286 { |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
287 QMessageBox *msgBox |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
288 = new QMessageBox (QMessageBox::Critical, |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
289 tr ("Octave Editor"), |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
290 message.arg (name), |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
291 QMessageBox::Ok, this); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
292 |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
293 msgBox->setWindowModality (Qt::NonModal); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
294 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
295 msgBox->show (); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
296 return; |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
297 } |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
298 |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
299 QString filename = QString::fromStdString ( |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
300 map.contents ("file").data ()[0].string_value ()); |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
301 |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
302 emit execute_command_in_terminal_signal (QString("edit ") |
00b1d60500bd
improved finding a function file for editing in gui (case 1 in bug #41509)
Torsten <ttl@justmail.de>
parents:
18954
diff
changeset
|
303 + "\""+filename+"\""); |
17628
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
304 } |
99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
Torsten <ttl@justmail.de>
parents:
17627
diff
changeset
|
305 |
17635
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
306 void |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
307 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
|
308 { |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17669
diff
changeset
|
309 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
|
310 QString::SkipEmptyParts); |
17669
b7670c05731b
*octave-qscintilla.cc(contextmenu_run): split selection into single commands
Torsten <ttl@justmail.de>
parents:
17655
diff
changeset
|
311 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
|
312 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
|
313 } |
7945344506ae
Add possibility to run selected text of the editor in the terminal
Torsten <ttl@justmail.de>
parents:
17628
diff
changeset
|
314 |
18684
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
315 void |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
316 octave_qscintilla::focusInEvent (QFocusEvent *focusEvent) |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
317 { |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
318 emit qsci_has_focus_signal (true); |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
319 QsciScintilla::focusInEvent(focusEvent); |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
320 } |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
321 |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
322 void |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
323 octave_qscintilla::focusOutEvent (QFocusEvent *focusEvent) |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
324 { |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
325 emit qsci_has_focus_signal (false); |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
326 QsciScintilla::focusOutEvent(focusEvent); |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
327 } |
86eca5d178a6
disable some global shortcuts when editor gets focus to prevent conflicts
Torsten <ttl@justmail.de>
parents:
18675
diff
changeset
|
328 |
18689
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
329 void |
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
330 octave_qscintilla::text_changed () |
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
331 { |
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
332 emit status_update (isUndoAvailable (), isRedoAvailable ()); |
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
333 } |
fac35875f6eb
update enabled status of undo/redo actions in the editor
Torsten <ttl@justmail.de>
parents:
18687
diff
changeset
|
334 |
16731
01d523d5f796
add help for word at mouse or text cursor to the editors context menu
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
335 #endif |