mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-26 19:32:06 -05:00
TextEditor: Rename "file_name" => "filename"
This commit is contained in:
parent
f3091d89aa
commit
297a2762cd
3 changed files with 9 additions and 11 deletions
|
@ -17,7 +17,7 @@ FileArgument::FileArgument(String file_argument)
|
|||
|
||||
if (Core::File::exists(file_argument)) {
|
||||
// A file exists with the full specified name, don't attempt to parse it.
|
||||
m_file_name = file_argument;
|
||||
m_filename = file_argument;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -32,28 +32,26 @@ FileArgument::FileArgument(String file_argument)
|
|||
|
||||
if (groups.size() > 3) {
|
||||
// Both a line and column number were specified.
|
||||
auto file_name = groups.at(0).view.to_string();
|
||||
auto filename = groups.at(0).view.to_string();
|
||||
auto initial_line_number = groups.at(1).view.to_string().to_int();
|
||||
auto initial_column_number = groups.at(2).view.to_string().to_int();
|
||||
|
||||
m_file_name = file_name;
|
||||
m_filename = filename;
|
||||
if (initial_line_number.has_value() && initial_line_number.value() > 0)
|
||||
m_line = initial_line_number.value();
|
||||
if (initial_column_number.has_value())
|
||||
m_column = initial_column_number.value();
|
||||
} else if (groups.size() == 3) {
|
||||
// Only a line number was specified.
|
||||
auto file_name = groups.at(0).view.to_string();
|
||||
auto filename = groups.at(0).view.to_string();
|
||||
auto initial_line_number = groups.at(1).view.to_string().to_int();
|
||||
|
||||
m_file_name = file_name;
|
||||
m_filename = filename;
|
||||
if (initial_line_number.has_value() && initial_line_number.value() > 0)
|
||||
m_line = initial_line_number.value();
|
||||
} else {
|
||||
// A colon was found at the end of the file name but no values were found after it.
|
||||
auto file_name = groups.at(0).view.to_string();
|
||||
|
||||
m_file_name = file_name;
|
||||
m_filename = groups.at(0).view.to_string();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@ public:
|
|||
FileArgument(String);
|
||||
~FileArgument();
|
||||
|
||||
String file_name() { return m_file_name; }
|
||||
String filename() { return m_filename; }
|
||||
Optional<size_t> line() { return m_line; }
|
||||
Optional<size_t> column() { return m_column; }
|
||||
|
||||
private:
|
||||
String m_file_name;
|
||||
String m_filename;
|
||||
Optional<size_t> m_line;
|
||||
Optional<size_t> m_column;
|
||||
};
|
||||
|
|
|
@ -72,7 +72,7 @@ int main(int argc, char** argv)
|
|||
if (file_to_edit) {
|
||||
// A file name was passed, parse any possible line and column numbers included.
|
||||
FileArgument parsed_argument(file_to_edit);
|
||||
if (!text_widget.open_file(parsed_argument.file_name()))
|
||||
if (!text_widget.open_file(parsed_argument.filename()))
|
||||
return 1;
|
||||
text_widget.editor().set_cursor_and_focus_line(parsed_argument.line().value_or(1) - 1, parsed_argument.column().value_or(0));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue