diff options
author | ry755 <ryanst755@gmail.com> | 2021-02-28 17:58:26 -0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-01 11:18:14 +0100 |
commit | b474f4916479fbf64e6fb5a66cb25b8496e153b3 (patch) | |
tree | 1f0d1146a1f086dee55d22ca730b07c0d87ca970 /Userland | |
parent | e60d394b32a5862e6961ea143957de63897b3cf0 (diff) | |
download | serenity-b474f4916479fbf64e6fb5a66cb25b8496e153b3.zip |
TextEditor: Add a command line option to jump to a specific line number
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/TextEditor/main.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Applications/TextEditor/main.cpp b/Userland/Applications/TextEditor/main.cpp index 0844f10232..f549c0564a 100644 --- a/Userland/Applications/TextEditor/main.cpp +++ b/Userland/Applications/TextEditor/main.cpp @@ -45,9 +45,11 @@ int main(int argc, char** argv) } const char* preview_mode = "auto"; + int initial_line_number = 0; const char* file_to_edit = nullptr; Core::ArgsParser parser; parser.add_option(preview_mode, "Preview mode, one of 'none', 'html', 'markdown', 'auto'", "preview-mode", '\0', "mode"); + parser.add_option(initial_line_number, "Start at line number", "line-number", 'l', "line"); parser.add_positional_argument(file_to_edit, "File to edit", "file", Core::ArgsParser::Required::No); parser.parse(argc, argv); @@ -91,6 +93,9 @@ int main(int argc, char** argv) else text_widget.update_title(); + if (initial_line_number != 0) + text_widget.editor().set_cursor_and_focus_line(initial_line_number - 1, 0); + window->show(); window->set_icon(app_icon.bitmap_for_size(16)); |