comparison libgui/src/m-editor/file-editor.cc @ 17635:7945344506ae

Add possibility to run selected text of the editor in the terminal * octave-qscintilla.cc(contextMenuEvent): new context menu for running selection (context_run): function for run selection action in editor file menu; (contextmenu_run): new slot for context menu run selection; * octave-qscintilla.h: new functions context_run, contextmenu_run * file-editor-tab.cc(context_run): new slot for run menu action * file-editor-tab.h: new slot context_run * file-editor.cc(request_context_run): new slot for run menu entry; (construct): new entry in run menu for running the selection in editor (add_file_editor_tab): connect new signal fetab_context_run to the new slot context_run 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_run, new slot request_context_edit, new run action
author Torsten <ttl@justmail.de>
date Fri, 11 Oct 2013 22:46:32 +0200
parents 99ffa521ecec
children 230ffaf80ac9
comparison
equal deleted inserted replaced
17634:bdbf91c0a1a4 17635:7945344506ae
504 504
505 void 505 void
506 file_editor::request_run_file (void) 506 file_editor::request_run_file (void)
507 { 507 {
508 emit fetab_run_file (_tab_widget->currentWidget ()); 508 emit fetab_run_file (_tab_widget->currentWidget ());
509 }
510
511 void
512 file_editor::request_context_run (bool)
513 {
514 emit fetab_context_run (_tab_widget->currentWidget ());
509 } 515 }
510 516
511 void 517 void
512 file_editor::request_toggle_bookmark (void) 518 file_editor::request_toggle_bookmark (void)
513 { 519 {
943 // The other debug actions will be added by the main window. 949 // The other debug actions will be added by the main window.
944 _menu_bar->addMenu (_debug_menu); 950 _menu_bar->addMenu (_debug_menu);
945 951
946 QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); 952 QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar);
947 _run_menu->addAction (_run_action); 953 _run_menu->addAction (_run_action);
954 _context_run_action =
955 _run_menu->addAction (QIcon (), tr ("Run &Selection"),
956 this, SLOT (request_context_run (bool)));
948 _menu_bar->addMenu (_run_menu); 957 _menu_bar->addMenu (_run_menu);
949 958
950 QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar); 959 QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar);
951 _context_help_action = 960 _context_help_action =
952 _help_menu->addAction (QIcon (), tr ("&Help on Keyword"), 961 _help_menu->addAction (QIcon (), tr ("&Help on Keyword"),
1152 f, SLOT (print_file (const QWidget*))); 1161 f, SLOT (print_file (const QWidget*)));
1153 1162
1154 connect (this, SIGNAL (fetab_run_file (const QWidget*)), 1163 connect (this, SIGNAL (fetab_run_file (const QWidget*)),
1155 f, SLOT (run_file (const QWidget*))); 1164 f, SLOT (run_file (const QWidget*)));
1156 1165
1166 connect (this, SIGNAL (fetab_context_run (const QWidget*)),
1167 f, SLOT (context_run (const QWidget*)));
1168
1157 connect (this, SIGNAL (fetab_toggle_bookmark (const QWidget*)), 1169 connect (this, SIGNAL (fetab_toggle_bookmark (const QWidget*)),
1158 f, SLOT (toggle_bookmark (const QWidget*))); 1170 f, SLOT (toggle_bookmark (const QWidget*)));
1159 1171
1160 connect (this, SIGNAL (fetab_next_bookmark (const QWidget*)), 1172 connect (this, SIGNAL (fetab_next_bookmark (const QWidget*)),
1161 f, SLOT (next_bookmark (const QWidget*))); 1173 f, SLOT (next_bookmark (const QWidget*)));
1250 _previous_bookmark_action->setShortcut (Qt::SHIFT + Qt::Key_F2); 1262 _previous_bookmark_action->setShortcut (Qt::SHIFT + Qt::Key_F2);
1251 _toggle_bookmark_action->setShortcut (Qt::Key_F7); 1263 _toggle_bookmark_action->setShortcut (Qt::Key_F7);
1252 1264
1253 _print_action->setShortcut (QKeySequence::Print); 1265 _print_action->setShortcut (QKeySequence::Print);
1254 _run_action->setShortcut (Qt::ControlModifier+ Qt::Key_R); 1266 _run_action->setShortcut (Qt::ControlModifier+ Qt::Key_R);
1267 _context_run_action->setShortcut (Qt::Key_F9);
1255 1268
1256 _context_edit_action->setShortcut (Qt::ControlModifier + Qt::Key_E); 1269 _context_edit_action->setShortcut (Qt::ControlModifier + Qt::Key_E);
1257 _save_action->setShortcut (QKeySequence::Save); 1270 _save_action->setShortcut (QKeySequence::Save);
1258 _save_as_action->setShortcut (QKeySequence::SaveAs); 1271 _save_as_action->setShortcut (QKeySequence::SaveAs);
1259 _close_action->setShortcut (QKeySequence::Close); 1272 _close_action->setShortcut (QKeySequence::Close);
1280 _previous_bookmark_action->setShortcut (no_key); 1293 _previous_bookmark_action->setShortcut (no_key);
1281 _toggle_bookmark_action->setShortcut (no_key); 1294 _toggle_bookmark_action->setShortcut (no_key);
1282 1295
1283 _print_action->setShortcut (no_key); 1296 _print_action->setShortcut (no_key);
1284 _run_action->setShortcut (no_key); 1297 _run_action->setShortcut (no_key);
1298 _context_run_action->setShortcut (no_key);
1285 1299
1286 _context_edit_action->setShortcut (no_key); 1300 _context_edit_action->setShortcut (no_key);
1287 _save_action->setShortcut (no_key); 1301 _save_action->setShortcut (no_key);
1288 _save_as_action->setShortcut (no_key); 1302 _save_as_action->setShortcut (no_key);
1289 _close_action->setShortcut (no_key); 1303 _close_action->setShortcut (no_key);
1314 _previous_bookmark_action->setEnabled (have_tabs); 1328 _previous_bookmark_action->setEnabled (have_tabs);
1315 _toggle_bookmark_action->setEnabled (have_tabs); 1329 _toggle_bookmark_action->setEnabled (have_tabs);
1316 1330
1317 _print_action->setEnabled (have_tabs); 1331 _print_action->setEnabled (have_tabs);
1318 _run_action->setEnabled (have_tabs); 1332 _run_action->setEnabled (have_tabs);
1333 _context_run_action->setEnabled (have_tabs);
1319 1334
1320 _context_edit_action->setEnabled (have_tabs); 1335 _context_edit_action->setEnabled (have_tabs);
1321 _save_action->setEnabled (have_tabs); 1336 _save_action->setEnabled (have_tabs);
1322 _save_as_action->setEnabled (have_tabs); 1337 _save_as_action->setEnabled (have_tabs);
1323 _close_action->setEnabled (have_tabs); 1338 _close_action->setEnabled (have_tabs);