Mercurial > hg > octave-nkf
changeset 17962:4a53bcc1a4ae
GUI: Add statusbar with line/col indicator to editor window (Bug #40626)
* libgui/src/m-editor/file-editor-tab.h
(class file_editor_tab): Add _status_bar and row/col_indicator variables, add handle_cursor_moved slot.
* libgui/src/m-editor/file-editor-tab.cc
(file_editor_tab::file_editor_tab): create statusbar and row / col indicator, connect edit cursorPosChange to handle_cursor_moved.
(file_editor_tab::handle_cursor_moved): New slot.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Tue, 19 Nov 2013 22:19:41 -0500 |
parents | 774409d18794 |
children | 2ca3a2f46d93 |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h |
diffstat | 2 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -80,6 +80,25 @@ this, SLOT (execute_command_in_terminal (const QString&))); + connect (_edit_area, + SIGNAL (cursorPositionChanged (int, int)), + this, + SLOT (handle_cursor_moved (int,int))); + + // create statusbar for row/col indicator + _status_bar = new QStatusBar (this); + + _row_indicator = new QLabel ("", this); + _row_indicator->setMinimumSize (30,0); + QLabel *row_label = new QLabel (tr ("Line:"), this); + _col_indicator = new QLabel ("", this); + _col_indicator->setMinimumSize (25,0); + QLabel *col_label = new QLabel (tr ("Col:"), this); + _status_bar->addPermanentWidget (row_label, 0); + _status_bar->addPermanentWidget (_row_indicator, 0); + _status_bar->addPermanentWidget (col_label, 0); + _status_bar->addPermanentWidget (_col_indicator, 0); + // Leave the find dialog box out of memory until requested. _find_dialog = 0; _find_dialog_is_visible = false; @@ -121,6 +140,7 @@ QVBoxLayout *edit_area_layout = new QVBoxLayout (); edit_area_layout->addWidget (_edit_area); + edit_area_layout->addWidget (_status_bar); edit_area_layout->setMargin (0); setLayout (edit_area_layout); @@ -1454,4 +1474,11 @@ } } +void +file_editor_tab::handle_cursor_moved (int line, int col) +{ + _row_indicator->setNum (line+1); + _col_indicator->setNum (col+1); +} + #endif
--- a/libgui/src/m-editor/file-editor-tab.h +++ b/libgui/src/m-editor/file-editor-tab.h @@ -29,6 +29,8 @@ #include <QSettings> #include <QFileInfo> #include <Qsci/qsciapis.h> +#include <QStatusBar> +#include <QLabel> #include "find-dialog.h" #include "octave-qscintilla.h" @@ -150,6 +152,8 @@ // When the numer of lines changes -> adapt width of margin void auto_margin_width (); + void handle_cursor_moved (int line, int col); + private: enum editor_markers @@ -191,6 +195,10 @@ octave_qscintilla *_edit_area; + QStatusBar *_status_bar; + QLabel *_row_indicator; + QLabel *_col_indicator; + QString _file_name; QString _file_name_short;