diff libgui/src/m-editor/file-editor-tab.cc @ 16375:f482302d81c9

editor goto line menu item (bug #38590) * file-editor-tab.h,file_editor_tab.cc (file_editor_tab::goto_line): New function. * file-editor.h, file-editor.cc (file-editor::request_goto_line): New function. (file_editor::request_goto_line): New function. (file_editor::construct): New goto_line_action QAction. Include it in edit menu.
author John Donoghue <john.donoghue@ieee.org>
date Wed, 27 Mar 2013 00:44:04 -0400
parents e0df71fbe39b
children 8430ea8c1594
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Tue Mar 26 13:52:03 2013 -0400
+++ b/libgui/src/m-editor/file-editor-tab.cc	Wed Mar 27 00:44:04 2013 -0400
@@ -41,6 +41,7 @@
 #include <QMessageBox>
 #include <QTextStream>
 #include <QVBoxLayout>
+#include <QInputDialog>
 
 #include "file-editor-tab.h"
 #include "file-editor.h"
@@ -628,6 +629,25 @@
 }
 
 void
+file_editor_tab::goto_line (const QWidget* ID)
+{
+  if (ID != this)
+    return;
+
+  int line, index;
+
+  _edit_area->getCursorPosition(&line, &index);
+
+  bool ok = false;
+
+  line = QInputDialog::getInt (_edit_area, "Goto line", "Line number", 
+                               line+1, 1, _edit_area->lines(), 1, &ok);
+  if (ok)
+    _edit_area->setCursorPosition (line-1, 0);
+}
+
+
+void
 file_editor_tab::do_comment_selected_text (bool comment)
 {
   if ( _edit_area->hasSelectedText() )