diff libgui/src/m-editor/file-editor-tab.cc @ 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 86c6ae5f969e
children 6925dca34807
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Tue Nov 19 21:40:04 2013 +0100
+++ b/libgui/src/m-editor/file-editor-tab.cc	Tue Nov 19 22:19:41 2013 -0500
@@ -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