Skip to content

Commit

Permalink
TextEditor: Add a command line option to jump to a specific line number
Browse files Browse the repository at this point in the history
  • Loading branch information
ry755 authored and awesomekling committed Mar 1, 2021
1 parent e60d394 commit b474f49
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Userland/Applications/TextEditor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit b474f49

Please sign in to comment.