Mercurial > octave-nkf
comparison libgui/src/m-editor/octave-qscintilla.cc @ 17628:99ffa521ecec
Add possibility to edit the function related to the actual keyword in editor
* octave-qscintilla.cc(get_actual_word): new internal function;
(context_help_doc): uses new function get_actual_word;
(contextMenuEvent): new context menu for editing function of actual keyword
(context_edit): function for edit action in editor file menu;
(contextmenu_edit): new slot for context menu;
* octave-qscintilla.h: new functions context_edit, contextmenu_edit,
get_actual_word
* file-editor-tab.cc(context_edit): new slot for editor menu action
* file-editor-tab.h: new slot context_edit
* file-editor.cc(request_context_edit): new slot for file menu entry;
(construct): new entry in file menu for editing function of actual keyword;
(add_file_editor_tab): connect new signal fetab_context_edit to the new
slot context_edit in file_editor_tab;
(set_shortcuts): enable/disable new shortcut when editor focus changes
(check_actions): enable/disable new action depending on existing tabs
* file-editor.h: new signal fetab_context_edit, new slot request_context_edit,
new edit function action
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 11 Oct 2013 14:12:37 +0200 |
parents | 811019b9ef57 |
children | 7945344506ae |
comparison
equal
deleted
inserted
replaced
17627:811019b9ef57 | 17628:99ffa521ecec |
---|---|
50 (QsciScintillaBase::SCI_POINTYFROMPOSITION,0,position); | 50 (QsciScintillaBase::SCI_POINTYFROMPOSITION,0,position); |
51 *local_pos = QPoint (point_x,point_y); // local cursor position | 51 *local_pos = QPoint (point_x,point_y); // local cursor position |
52 *global_pos = mapToGlobal (*local_pos); // global position of cursor | 52 *global_pos = mapToGlobal (*local_pos); // global position of cursor |
53 } | 53 } |
54 | 54 |
55 // call documentation or help on the current word | 55 // determine the actual word and whether we are in an octave or matlab script |
56 void | 56 bool |
57 octave_qscintilla::context_help_doc (bool documentation) | 57 octave_qscintilla::get_actual_word () |
58 { | 58 { |
59 QPoint global_pos, local_pos; | 59 QPoint global_pos, local_pos; |
60 get_global_textcursor_pos (&global_pos, &local_pos); | 60 get_global_textcursor_pos (&global_pos, &local_pos); |
61 _word_at_cursor = wordAtPoint (local_pos); | 61 _word_at_cursor = wordAtPoint (local_pos); |
62 QString lexer_name = lexer ()->lexer (); | 62 QString lexer_name = lexer ()->lexer (); |
63 if ((lexer_name == "octave" || lexer_name == "matlab") | 63 return ((lexer_name == "octave" || lexer_name == "matlab") |
64 && !_word_at_cursor.isEmpty ()) | 64 && !_word_at_cursor.isEmpty ()); |
65 } | |
66 | |
67 // call documentation or help on the current word | |
68 void | |
69 octave_qscintilla::context_help_doc (bool documentation) | |
70 { | |
71 if (get_actual_word ()) | |
65 contextmenu_help_doc (documentation); | 72 contextmenu_help_doc (documentation); |
73 } | |
74 | |
75 // call edit the function related to the current word | |
76 void | |
77 octave_qscintilla::context_edit () | |
78 { | |
79 if (get_actual_word ()) | |
80 contextmenu_edit (true); | |
66 } | 81 } |
67 | 82 |
68 #ifdef HAVE_QSCI_VERSION_2_6_0 | 83 #ifdef HAVE_QSCI_VERSION_2_6_0 |
69 // context menu requested | 84 // context menu requested |
70 void | 85 void |
102 if (!_word_at_cursor.isEmpty ()) | 117 if (!_word_at_cursor.isEmpty ()) |
103 context_menu->addAction (tr ("Help on") + " " + _word_at_cursor, | 118 context_menu->addAction (tr ("Help on") + " " + _word_at_cursor, |
104 this, SLOT (contextmenu_help (bool))); | 119 this, SLOT (contextmenu_help (bool))); |
105 context_menu->addAction (tr ("Documentation on") + " " + _word_at_cursor, | 120 context_menu->addAction (tr ("Documentation on") + " " + _word_at_cursor, |
106 this, SLOT (contextmenu_doc (bool))); | 121 this, SLOT (contextmenu_doc (bool))); |
122 context_menu->addAction (tr ("Edit") + " " + _word_at_cursor, | |
123 this, SLOT (contextmenu_edit (bool))); | |
107 } | 124 } |
108 | 125 |
109 // finaly show the menu | 126 // finaly show the menu |
110 context_menu->exec (global_pos); | 127 context_menu->exec (global_pos); |
111 } | 128 } |
134 else | 151 else |
135 command = "help "; | 152 command = "help "; |
136 emit execute_command_in_terminal_signal (command + _word_at_cursor); | 153 emit execute_command_in_terminal_signal (command + _word_at_cursor); |
137 } | 154 } |
138 | 155 |
156 void | |
157 octave_qscintilla::contextmenu_edit (bool) | |
158 { | |
159 emit execute_command_in_terminal_signal (QString("edit ") + _word_at_cursor); | |
160 } | |
161 | |
139 #endif | 162 #endif |