# HG changeset patch # User Torsten # Date 1422135980 -3600 # Node ID 8ef79bc61d8a2377e0760f64ba7866ce249c9b1f # Parent 9803fd881504b0327d83e24136472fb8343e1622 add actions for moving/selecting to matching brace * file-editor-tab.cc (move_match_brace): new slot for signal from editor for moving or selecting to the matching brace * file-editor-tab.h: new slot move_match_brace * file-editor.cc (request_move_match_brace): new slot for new action; (request_sel_match_brace): new slot for new action; (construct): add new action for moving/selecting to matching brace into edit/navigation menu; (add_file_editor_tab): connect new signal to new slot in file_editor_tab; (set_shortcuts): set the shortcuts from the settings for the new actions * file-editor.h: new actions, new related slots, new signals for editor tabs * shortcut-manager.cc (do_init_data): initialize shortcuts for new actions from settings or with default values diff -r 9803fd881504 -r 8ef79bc61d8a libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Fri Jan 23 16:39:32 2015 -0500 +++ b/libgui/src/m-editor/file-editor-tab.cc Sat Jan 24 22:46:20 2015 +0100 @@ -1048,6 +1048,18 @@ } void +file_editor_tab::move_match_brace (const QWidget *ID, bool select) +{ + if (ID != this) + return; + + if (select) + _edit_area->selectToMatchingBrace (); + else + _edit_area->moveToMatchingBrace (); +} + +void file_editor_tab::show_auto_completion (const QWidget *ID) { if (ID != this) diff -r 9803fd881504 -r 8ef79bc61d8a libgui/src/m-editor/file-editor-tab.h --- a/libgui/src/m-editor/file-editor-tab.h Fri Jan 23 16:39:32 2015 -0500 +++ b/libgui/src/m-editor/file-editor-tab.h Sat Jan 24 22:46:20 2015 +0100 @@ -106,6 +106,7 @@ void find (const QWidget *ID); void goto_line (const QWidget *ID, int line = -1); + void move_match_brace (const QWidget *ID, bool select); void show_auto_completion (const QWidget *ID); void insert_debugger_pointer (const QWidget *ID, int line = -1); diff -r 9803fd881504 -r 8ef79bc61d8a libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc Fri Jan 23 16:39:32 2015 -0500 +++ b/libgui/src/m-editor/file-editor.cc Sat Jan 24 22:46:20 2015 +0100 @@ -860,6 +860,17 @@ emit fetab_goto_line (_tab_widget->currentWidget ()); } +void +file_editor::request_move_match_brace (bool) +{ + emit fetab_move_match_brace (_tab_widget->currentWidget (), false); +} + +void +file_editor::request_sel_match_brace (bool) +{ + emit fetab_move_match_brace (_tab_widget->currentWidget (), true); +} void file_editor::request_completion (bool) @@ -1402,6 +1413,13 @@ _goto_line_action = add_action (_edit_nav_menu, QIcon (), tr ("Go &to Line..."), SLOT (request_goto_line (bool))); + _edit_cmd_menu->addSeparator (); + + _move_to_matching_brace = add_action (_edit_nav_menu, QIcon (), + tr ("Move to Matching Brace"), SLOT (request_move_match_brace (bool))); + _sel_to_matching_brace = add_action (_edit_nav_menu, QIcon (), + tr ("Select to Matching Brace"), SLOT (request_sel_match_brace (bool))); + _edit_nav_menu->addSeparator (); _next_bookmark_action = add_action (_edit_nav_menu, QIcon (), @@ -1715,6 +1733,9 @@ connect (this, SIGNAL (fetab_goto_line (const QWidget*, int)), f, SLOT (goto_line (const QWidget*, int))); + connect (this, SIGNAL (fetab_move_match_brace (const QWidget*, bool)), + f, SLOT (move_match_brace (const QWidget*, bool))); + connect (this, SIGNAL (fetab_completion (const QWidget*)), f, SLOT (show_auto_completion (const QWidget*))); @@ -1806,6 +1827,8 @@ shortcut_manager::set_shortcut (_unindent_selection_action, "editor_edit:unindent_selection"); shortcut_manager::set_shortcut (_completion_action, "editor_edit:completion_list"); shortcut_manager::set_shortcut (_goto_line_action, "editor_edit:goto_line"); + shortcut_manager::set_shortcut (_move_to_matching_brace, "editor_edit:move_to_brace"); + shortcut_manager::set_shortcut (_sel_to_matching_brace, "editor_edit:select_to_brace"); shortcut_manager::set_shortcut (_toggle_bookmark_action, "editor_edit:toggle_bookmark"); shortcut_manager::set_shortcut (_next_bookmark_action, "editor_edit:next_bookmark"); shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_edit:previous_bookmark"); diff -r 9803fd881504 -r 8ef79bc61d8a libgui/src/m-editor/file-editor.h --- a/libgui/src/m-editor/file-editor.h Fri Jan 23 16:39:32 2015 -0500 +++ b/libgui/src/m-editor/file-editor.h Sat Jan 24 22:46:20 2015 +0100 @@ -96,6 +96,7 @@ void fetab_convert_eol (const QWidget* ID, QsciScintilla::EolMode eol_mode); void fetab_find (const QWidget* ID); void fetab_goto_line (const QWidget* ID, int line = -1); + void fetab_move_match_brace (const QWidget* ID, bool select); void fetab_completion (const QWidget*); void fetab_insert_debugger_pointer (const QWidget* ID, int line = -1); void fetab_delete_debugger_pointer (const QWidget* ID, int line = -1); @@ -146,6 +147,8 @@ void request_previous_bookmark (bool); void request_remove_bookmark (bool); + void request_move_match_brace (bool); + void request_sel_match_brace (bool); void request_toggle_breakpoint (bool); void request_next_breakpoint (bool); void request_previous_breakpoint (bool); @@ -305,6 +308,8 @@ QAction *_goto_line_action; QAction *_completion_action; + QAction *_move_to_matching_brace; + QAction *_sel_to_matching_brace; QAction *_next_bookmark_action; QAction *_previous_bookmark_action; QAction *_toggle_bookmark_action; diff -r 9803fd881504 -r 8ef79bc61d8a libgui/src/shortcut-manager.cc --- a/libgui/src/shortcut-manager.cc Fri Jan 23 16:39:32 2015 -0500 +++ b/libgui/src/shortcut-manager.cc Sat Jan 24 22:46:20 2015 +0100 @@ -255,6 +255,10 @@ init (tr ("Goto Line"), "editor_edit:goto_line", QKeySequence (ctrl + Qt::Key_G)); + init (tr ("Move to Matching Brace"), "editor_edit:move_to_brace", + QKeySequence (ctrl + Qt::Key_M)); + init (tr ("Select to Matching Brace"), "editor_edit:select_to_brace", + QKeySequence (ctrl_shift + Qt::Key_M)); init (tr ("Toggle Bookmark"), "editor_edit:toggle_bookmark", QKeySequence (prefix + Qt::Key_F7)); init (tr ("Next Bookmark"), "editor_edit:next_bookmark",