Mercurial > hg > octave-lojdl
changeset 14825:eae0e9f2a8c6 gui
Added menus, markers and methods to visualize debugging in the editor and add, remove and navigate breakpoints* .
* arrow_right.png: Icon to indicate debugger position.
* redled.png: Icon for a breakpoint.
* file-editor-tab: Added methods to add/remove breakpoints and menu entries.
* file-editor: Added methods to add/remove breakpoints and menu entries.
* resource.qrc: Added new icons to resource file.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 02 Jul 2012 09:31:30 +0200 |
parents | 9c0959a1dc7b |
children | ed0f820c7ce0 |
files | gui/src/icons/arrow_right.png gui/src/icons/redled.png gui/src/m-editor/file-editor-tab.cc gui/src/m-editor/file-editor-tab.h gui/src/m-editor/file-editor.cc gui/src/m-editor/file-editor.h gui/src/resource.qrc |
diffstat | 7 files changed, 157 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5587ddee1c2a3b144104b36b6165d7f571ae4136 GIT binary patch literal 3324 zc$@+J3<L9tP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV000V4X+uL$P-t&- zZ*ypGa3D!TLm+T+Z)Rz1WdHzp+MQEpR8#2|J@?-9LQ9B%luK_?6$l_wLW_VDktQl3 z2@pz%A)(n7QNa;KMFbnjpojyGj)066Q7jCK3fKqaA)=0hqlk*i`{8?|Yu3E?=FR@K z*FNX0^PRKL2fzpnmPj*EHGmAMLLL#|gU7_i;p8qrfeIvW01ybXWFd3?BLM*Temp!Y zBESc}00DT@3kU$fO`E_l9Ebl8>Oz@Z0f2-7z;ux~O9+4z06=<<LZ$#fMgf4Gm?l#I zpacM5%VT2W08lLeU?+d((*S^-_?deF09%wH6#<};03Z`(h(rKrI{>WDR*FRcSTFz- zW=q650N5=6FiBTtNC2?60Km==3$g$R3;-}uh=nNt1bYBr$Ri_o0EC$U6h`t_Jn<{8 z5a%iY0C<_QJh>z}MS)ugEpZ1|S1ukX&Pf+56gFW3VVXcL!g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x>%#@U6O7+t%6n%_h>z z{{H_DbjFMY=T@@cWV!Z*Ggg@6e}cfj-+c!oTB8|WiLx~?G-dKISn|6HbJRPh{Z9yZ z{P!foS9@j$hK&xUTn>M}FlU_B*D-T4(0?q?7O{YlMS$C;W`Aw7*0F^jzspZ~!N8#~ zBiJ73Ox}0$Jj<O-|Ni3cmjj!6r{MJ=<0%IkZg-?yKD%9Ds{)fkLxPmF<Hs-GjHOo@ zPc+&4_uPSkca}G{xe3TCG#Cgo7@W9TQD^YM=x?hve~Pfj<@5VHSQrEx3VN5QSvD{v gshCe>W|3g97rDFIe2w@bVB9cxy85}Sb4q9e07w(HNB{r;
--- a/gui/src/m-editor/file-editor-tab.cc +++ b/gui/src/m-editor/file-editor-tab.cc @@ -30,10 +30,14 @@ _edit_area = new QsciScintilla (this); _edit_area->setLexer (fileEditor->lexer ()); - // markers + // symbols _edit_area->setMarginType (1, QsciScintilla::SymbolMargin); _edit_area->setMarginSensitivity (1, true); - _edit_area->markerDefine (QsciScintilla::RightTriangle, MARKER_BOOKMARK); + _edit_area->markerDefine (QsciScintilla::RightTriangle, bookmark); + _edit_area->markerDefine (QImage (":/actions/icons/redled.png"), breakpoint); + _edit_area->markerDefine (QImage (":/actions/icons/arrow_right.png"), + debugger_position); + connect (_edit_area, SIGNAL (marginClicked (int, int, Qt::KeyboardModifiers)), this, SLOT (handle_margin_clicked (int, int, Qt::KeyboardModifiers))); @@ -47,8 +51,8 @@ _edit_area->setMarginsFont( marginFont ); QFontMetrics metrics(marginFont); _edit_area->setMarginType (2, QsciScintilla::TextMargin); - _edit_area->setMarginWidth(2, metrics.width("99999")); - _edit_area->setMarginLineNumbers(2, true); + _edit_area->setMarginWidth(2, metrics.width("9999")); + _edit_area->setMarginLineNumbers (2, true); } // code folding @@ -150,13 +154,24 @@ file_editor_tab::handle_margin_clicked(int margin, int line, Qt::KeyboardModifiers state) { Q_UNUSED (state); - if (margin == 1) // marker margin + if (margin == 1) { unsigned int mask = _edit_area->markersAtLine (line); - if (mask && (1 << MARKER_BOOKMARK)) - _edit_area->markerDelete(line,MARKER_BOOKMARK); + + if (state & Qt::ControlModifier) + { + if (mask && (1 << bookmark)) + _edit_area->markerDelete(line,bookmark); + else + _edit_area->markerAdd(line,bookmark); + } else - _edit_area->markerAdd(line,MARKER_BOOKMARK); + { + if (mask && (1 << breakpoint)) + _edit_area->markerDelete(line,breakpoint); + else + _edit_area->markerAdd(line,breakpoint); + } } } @@ -271,40 +286,79 @@ void file_editor_tab::remove_bookmark () { - _edit_area->markerDeleteAll(MARKER_BOOKMARK); + _edit_area->markerDeleteAll (bookmark); } void file_editor_tab::toggle_bookmark () { - int line,cur; - _edit_area->getCursorPosition(&line,&cur); - if ( _edit_area->markersAtLine (line) && (1 << MARKER_BOOKMARK) ) - _edit_area->markerDelete(line,MARKER_BOOKMARK); + int line, cur; + _edit_area->getCursorPosition (&line,&cur); + if ( _edit_area->markersAtLine (line) && (1 << bookmark) ) + _edit_area->markerDelete (line, bookmark); else - _edit_area->markerAdd(line,MARKER_BOOKMARK); + _edit_area->markerAdd (line, bookmark); } void -file_editor_tab::next_bookmark () +file_editor_tab::next_bookmark() { - int line,cur,nextline; - _edit_area->getCursorPosition(&line,&cur); - if ( _edit_area->markersAtLine(line) && (1 << MARKER_BOOKMARK) ) - line++; // we have a bookmark here, so start search from next line - nextline = _edit_area->markerFindNext(line,(1 << MARKER_BOOKMARK)); - _edit_area->setCursorPosition(nextline,0); + int line, cur, nextline; + _edit_area->getCursorPosition (&line, &cur); + if ( _edit_area->markersAtLine (line) && (1 << bookmark) ) + line++; // we have a breakpoint here, so start search from next line + nextline = _edit_area->markerFindNext (line, (1 << bookmark)); + _edit_area->setCursorPosition (nextline, 0); } void file_editor_tab::previous_bookmark () { - int line,cur,prevline; - _edit_area->getCursorPosition(&line,&cur); - if ( _edit_area->markersAtLine(line) && (1 << MARKER_BOOKMARK) ) - line--; // we have a bookmark here, so start search from prev line - prevline = _edit_area->markerFindPrevious(line,(1 << MARKER_BOOKMARK)); - _edit_area->setCursorPosition(prevline,0); + int line, cur, prevline; + _edit_area->getCursorPosition (&line, &cur); + if ( _edit_area->markersAtLine (line) && (1 << bookmark) ) + line--; // we have a breakpoint here, so start search from prev line + prevline = _edit_area->markerFindPrevious (line, (1 << bookmark)); + _edit_area->setCursorPosition (prevline, 0); +} + +void +file_editor_tab::remove_breakpoint () +{ + _edit_area->markerDeleteAll (breakpoint); +} + +void +file_editor_tab::toggle_breakpoint () +{ + int line, cur; + _edit_area->getCursorPosition (&line,&cur); + if ( _edit_area->markersAtLine (line) && (1 << breakpoint) ) + _edit_area->markerDelete (line, breakpoint); + else + _edit_area->markerAdd (line, breakpoint); +} + +void +file_editor_tab::next_breakpoint () +{ + int line, cur, nextline; + _edit_area->getCursorPosition (&line, &cur); + if ( _edit_area->markersAtLine (line) && (1 << breakpoint) ) + line++; // we have a breakpoint here, so start search from next line + nextline = _edit_area->markerFindNext (line, (1 << breakpoint)); + _edit_area->setCursorPosition (nextline, 0); +} + +void +file_editor_tab::previous_breakpoint () +{ + int line, cur, prevline; + _edit_area->getCursorPosition (&line, &cur); + if ( _edit_area->markersAtLine (line) && (1 << breakpoint) ) + line--; // we have a breakpoint here, so start search from prev line + prevline = _edit_area->markerFindPrevious (line, (1 << breakpoint)); + _edit_area->setCursorPosition (prevline, 0); } void @@ -338,6 +392,16 @@ } void +file_editor_tab::set_debugger_position (int line) +{ + _edit_area->markerDeleteAll (debugger_position); + if (line > 0) + { + _edit_area->markerAdd (line, debugger_position); + } +} + +void file_editor_tab::set_modified (bool modified) { _edit_area->setModified (modified);
--- a/gui/src/m-editor/file-editor-tab.h +++ b/gui/src/m-editor/file-editor-tab.h @@ -46,11 +46,16 @@ void toggle_bookmark (); void next_bookmark (); void previous_bookmark (); + void remove_breakpoint (); + void toggle_breakpoint (); + void next_breakpoint (); + void previous_breakpoint (); void cut (); void copy (); void paste (); void undo (); void redo (); + void set_debugger_position (int line); void set_modified (bool modified = true);
--- a/gui/src/m-editor/file-editor.cc +++ b/gui/src/m-editor/file-editor.cc @@ -202,6 +202,38 @@ } void +file_editor::request_toggle_breakpoint () +{ + file_editor_tab *activeFileEditorTab = active_editor_tab (); + if (activeFileEditorTab) + activeFileEditorTab->toggle_breakpoint (); +} + +void +file_editor::request_next_breakpoint () +{ + file_editor_tab *activeFileEditorTab = active_editor_tab (); + if (activeFileEditorTab) + activeFileEditorTab->next_breakpoint (); +} + +void +file_editor::request_previous_breakpoint () +{ + file_editor_tab *activeFileEditorTab = active_editor_tab (); + if (activeFileEditorTab) + activeFileEditorTab->previous_breakpoint (); +} + +void +file_editor::request_remove_breakpoint () +{ + file_editor_tab *activeFileEditorTab = active_editor_tab (); + if (activeFileEditorTab) + activeFileEditorTab->remove_breakpoint (); +} + +void file_editor::request_comment_selected_text () { file_editor_tab *activeFileEditorTab = active_editor_tab (); @@ -319,6 +351,12 @@ QAction *previous_bookmark_action = new QAction (tr ("Pre&vious Bookmark"),_tool_bar); QAction *toggle_bookmark_action = new QAction (tr ("Toggle &Bookmark"),_tool_bar); QAction *remove_bookmark_action = new QAction (tr ("&Remove All Bookmarks"),_tool_bar); + + QAction *next_breakpoint_action = new QAction (tr ("&Next breakpoint"),_tool_bar); + QAction *previous_breakpoint_action = new QAction (tr ("Pre&vious breakpoint"),_tool_bar); + QAction *toggle_breakpoint_action = new QAction (tr ("Toggle &breakpoint"),_tool_bar); + QAction *remove_breakpoint_action = new QAction (tr ("&Remove All breakpoints"),_tool_bar); + QAction *comment_selection_action = new QAction (tr ("&Comment Selected Text"),_tool_bar); QAction *uncomment_selection_action = new QAction (tr ("&Uncomment Selected Text"),_tool_bar); @@ -403,6 +441,12 @@ _menu_bar->addMenu (editMenu); _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); + _debug_menu->addAction (toggle_breakpoint_action); + _debug_menu->addAction (next_breakpoint_action); + _debug_menu->addAction (previous_breakpoint_action); + _debug_menu->addAction (remove_breakpoint_action); + _debug_menu->addSeparator (); + // The other debug actions will be added by the main window. _menu_bar->addMenu (_debug_menu); QMenu *runMenu = new QMenu (tr ("&Run"), _menu_bar); @@ -431,6 +475,10 @@ connect (next_bookmark_action, SIGNAL (triggered ()), this, SLOT (request_next_bookmark ())); connect (previous_bookmark_action, SIGNAL (triggered ()), this, SLOT (request_previous_bookmark ())); connect (remove_bookmark_action, SIGNAL (triggered ()), this, SLOT (request_remove_bookmark ())); + connect (toggle_breakpoint_action, SIGNAL (triggered ()), this, SLOT (request_toggle_breakpoint ())); + connect (next_breakpoint_action, SIGNAL (triggered ()), this, SLOT (request_next_breakpoint ())); + connect (previous_breakpoint_action, SIGNAL (triggered ()), this, SLOT (request_previous_breakpoint ())); + connect (remove_breakpoint_action, SIGNAL (triggered ()), this, SLOT (request_remove_breakpoint ())); connect (comment_selection_action, SIGNAL (triggered ()), this, SLOT (request_comment_selected_text ())); connect (uncomment_selection_action, SIGNAL (triggered ()), this, SLOT (request_uncomment_selected_text ())); connect (_tab_widget, SIGNAL (tabCloseRequested (int)), this, SLOT (handle_tab_close_request (int)));
--- a/gui/src/m-editor/file-editor.h +++ b/gui/src/m-editor/file-editor.h @@ -35,10 +35,11 @@ const char UNNAMED_FILE[] = "<unnamed>"; const char SAVE_FILE_FILTER[] = "Octave Files (*.m);;All Files (*.*)"; -enum MARKER +enum editor_markers { - MARKER_BOOKMARK, - MARKER_BREAKPOINT + bookmark, + breakpoint, + debugger_position }; class file_editor : public file_editor_interface @@ -73,6 +74,12 @@ void request_next_bookmark (); void request_previous_bookmark (); void request_remove_bookmark (); + + void request_toggle_breakpoint (); + void request_next_breakpoint (); + void request_previous_breakpoint (); + void request_remove_breakpoint (); + void request_comment_selected_text (); void request_uncomment_selected_text (); @@ -93,7 +100,7 @@ QAction* _copy_action; QAction* _cut_action; QTabWidget * _tab_widget; - int _marker_bookmark; + int _marker_breakpoint; lexer_octave_gui *_lexer; QsciAPIs * _lexer_api; };