From c1f72e0bbf0450630cb2e02c7479780af3267c4c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 21 Oct 2019 19:03:09 +0200 Subject: [PATCH] HackStudio: Show line numbers in the text editor by default --- DevTools/HackStudio/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 4243aaca3b..8f14f07a4f 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -1,7 +1,9 @@ #include "Project.h" #include +#include #include #include +#include #include #include #include @@ -44,6 +46,7 @@ int main(int argc, char** argv) project_list_view->set_preferred_size(200, 0); auto text_editor = GTextEditor::construct(GTextEditor::MultiLine, splitter); + text_editor->set_ruler_visible(true); project_list_view->on_activation = [&](auto& index) { 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())); }; + 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(); return app.exec(); }