Mercurial > jwe > octave
diff libgui/src/m-editor/octave-qscintilla.cc @ 21158:65827e9cccb8
Gui support for enhancement of dbstop.
* octave-qscintilla.cc (contextMenuEvent): Capture right-click in the
left margins to show a context menu for "dbstop if...".
* octave-qscintilla.{cc,h} (contextmenu_break_condition): new function
* file-editor-interface.h: pass condition to
handle_update_breakpoint_marker_request
* file-editor-tab.{cc,h}: (file_editor_tab, bp_info,
handle_request_add_breakpoint, next_breakpoint,
previous_breakpoint, do_breakpoint_marker,
add_breakpoint_callback):
Allow conditional breakpoint markers
* file-editor-tab.cc (handle_context_menu_break_condition): new function
* file-editor.{cc,h} (request_open_file, add_file_editor_tab,
handle_delete_debugger_pointer_request): pass bp conditions.
* marker.{cc,h} (marker, construct, handle_report_editor_linenr):
pass breakpoint conditions
* main-window.{cc,h} (handle_update_breakpoint_marker_request):
pass breakpoint condition.
* octave-link.h (update_breakpoint): pass breakpoint condition.
* octave-qt-link.{cc,h} (do_update_breakpoint): pass breakpoint condition.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Sat, 30 Jan 2016 10:13:34 +1100 |
parents | 00835323fb44 |
children | 710e700cdd7f |
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc Sun Jan 24 11:02:30 2016 +1100 +++ b/libgui/src/m-editor/octave-qscintilla.cc Sat Jan 30 10:13:34 2016 +1100 @@ -194,8 +194,7 @@ QPoint global_pos, local_pos; // the menu's position QMenu *context_menu = createStandardContextMenu (); // standard menu - // fill context menu with editor's standard actions - emit create_context_menu_signal (context_menu); + bool in_left_margin = false; // determine position depending on mouse or keyboard event if (e->reason () == QContextMenuEvent::Mouse) @@ -203,6 +202,8 @@ // context menu by mouse global_pos = e->globalPos (); // global mouse position local_pos = e->pos (); // local mouse position + if (e->x () < marginWidth (1) + marginWidth (2)) + in_left_margin = true; } else { @@ -215,26 +216,45 @@ global_pos = editor_rect.topLeft (); // yes, take top left corner } - // additional custom entries of the context menu - context_menu->addSeparator (); // separator before custom entries - - // help menu: get the position of the mouse or the text cursor - // (only for octave files) - QString lexer_name = lexer ()->lexer (); - if (lexer_name == "octave" || lexer_name == "matlab") + if (! in_left_margin) { - _word_at_cursor = wordAtPoint (local_pos); - if (! _word_at_cursor.isEmpty ()) + // fill context menu with editor's standard actions + emit create_context_menu_signal (context_menu); + + // additional custom entries of the context menu + context_menu->addSeparator (); // separator before custom entries + + // help menu: get the position of the mouse or the text cursor + // (only for octave files) + QString lexer_name = lexer ()->lexer (); + if (lexer_name == "octave" || lexer_name == "matlab") { - context_menu->addAction (tr ("Help on") + " " + _word_at_cursor, - this, SLOT (contextmenu_help (bool))); - context_menu->addAction (tr ("Documentation on") - + " " + _word_at_cursor, - this, SLOT (contextmenu_doc (bool))); - context_menu->addAction (tr ("Edit") + " " + _word_at_cursor, - this, SLOT (contextmenu_edit (bool))); + _word_at_cursor = wordAtPoint (local_pos); + if (! _word_at_cursor.isEmpty ()) + { + context_menu->addAction (tr ("Help on") + " " + _word_at_cursor, + this, SLOT (contextmenu_help (bool))); + context_menu->addAction (tr ("Documentation on") + + " " + _word_at_cursor, + this, SLOT (contextmenu_doc (bool))); + context_menu->addAction (tr ("Edit") + " " + _word_at_cursor, + this, SLOT (contextmenu_edit (bool))); + } } - } + } + else + { + // remove all standard actions from scintilla + QList<QAction *> all_actions = context_menu->actions (); + QAction* a; + + foreach (a, all_actions) + context_menu->removeAction (a); + + a = context_menu->addAction (tr ("dbstop if ..."), this, + SLOT (contextmenu_break_condition (bool))); + a->setData (local_pos); + } // finaly show the menu context_menu->exec (global_pos); @@ -279,6 +299,38 @@ emit execute_command_in_terminal_signal (commands.at (i)); } +// wrappers for dbstop related context menu items + +#ifdef HAVE_QSCI_VERSION_2_6_0 +// FIXME Why can't the data be sent as the argument to the function??? +void +octave_qscintilla::contextmenu_break_condition (bool) +{ + QAction *action = qobject_cast<QAction *>(sender()); + QPoint local_pos = action->data ().value<QPoint> (); + + // pick point just right of margins, so lineAt doesn't give -1 + int margins = marginWidth (1) + marginWidth (2) + marginWidth (3); + local_pos = QPoint (margins + 1, local_pos.y ()); + + emit context_menu_break_condition_signal (lineAt (local_pos)); +} + +void +octave_qscintilla::contextmenu_break_once (const QPoint& local_pos) +{ + emit context_menu_break_once (lineAt (local_pos)); +} + +/* +void +octave_qscintilla::contextmenu_break_if_caught (bool) +{ + emit context_menu_break_if_caught +} +*/ +#endif // HAVE_QSCI_VERSION_2_6_0 + void octave_qscintilla::text_changed () {