1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

TextEditor: Add a command line option to jump to a specific line number

This commit is contained in:
ry755 2021-02-28 17:58:26 -08:00 committed by Andreas Kling
parent e60d394b32
commit b474f49164

View file

@ -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));