Explorar el Código

HackStudio: Show line numbers in the text editor by default

Andreas Kling hace 5 años
padre
commit
c1f72e0bbf
Se han modificado 1 ficheros con 15 adiciones y 0 borrados
  1. 15 0
      DevTools/HackStudio/main.cpp

+ 15 - 0
DevTools/HackStudio/main.cpp

@@ -1,7 +1,9 @@
 #include "Project.h"
 #include "Project.h"
 #include <LibCore/CFile.h>
 #include <LibCore/CFile.h>
+#include <LibGUI/GAction.h>
 #include <LibGUI/GApplication.h>
 #include <LibGUI/GApplication.h>
 #include <LibGUI/GBoxLayout.h>
 #include <LibGUI/GBoxLayout.h>
+#include <LibGUI/GInputBox.h>
 #include <LibGUI/GListView.h>
 #include <LibGUI/GListView.h>
 #include <LibGUI/GMessageBox.h>
 #include <LibGUI/GMessageBox.h>
 #include <LibGUI/GSplitter.h>
 #include <LibGUI/GSplitter.h>
@@ -44,6 +46,7 @@ int main(int argc, char** argv)
     project_list_view->set_preferred_size(200, 0);
     project_list_view->set_preferred_size(200, 0);
 
 
     auto text_editor = GTextEditor::construct(GTextEditor::MultiLine, splitter);
     auto text_editor = GTextEditor::construct(GTextEditor::MultiLine, splitter);
+    text_editor->set_ruler_visible(true);
 
 
     project_list_view->on_activation = [&](auto& index) {
     project_list_view->on_activation = [&](auto& index) {
         auto filename = project_list_view->model()->data(index).to_string();
         auto filename = project_list_view->model()->data(index).to_string();
@@ -61,6 +64,18 @@ int main(int argc, char** argv)
         statusbar->set_text(String::format("Line: %d, Column: %d", text_editor->cursor().line(), text_editor->cursor().column()));
         statusbar->set_text(String::format("Line: %d, Column: %d", text_editor->cursor().line(), text_editor->cursor().column()));
     };
     };
 
 
+    text_editor->add_custom_context_menu_action(GAction::create("Go to line...", { Mod_Ctrl, Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [&](auto&) {
+        auto input_box = GInputBox::construct("Line:", "Go to line", window);
+        auto result = input_box->exec();
+        if (result == GInputBox::ExecOK) {
+            bool ok;
+            auto line_number = input_box->text_value().to_uint(ok);
+            if (ok) {
+                text_editor->set_cursor(line_number, 0);
+            }
+        }
+    }));
+
     window->show();
     window->show();
     return app.exec();
     return app.exec();
 }
 }