1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:17:34 +00:00

TextEditor: Rename "file_name" => "filename"

This commit is contained in:
Andreas Kling 2021-05-06 12:32:50 +02:00
parent f3091d89aa
commit 297a2762cd
3 changed files with 9 additions and 11 deletions

View file

@ -17,7 +17,7 @@ FileArgument::FileArgument(String file_argument)
if (Core::File::exists(file_argument)) { if (Core::File::exists(file_argument)) {
// A file exists with the full specified name, don't attempt to parse it. // A file exists with the full specified name, don't attempt to parse it.
m_file_name = file_argument; m_filename = file_argument;
return; return;
} }
@ -32,28 +32,26 @@ FileArgument::FileArgument(String file_argument)
if (groups.size() > 3) { if (groups.size() > 3) {
// Both a line and column number were specified. // 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_line_number = groups.at(1).view.to_string().to_int();
auto initial_column_number = groups.at(2).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) if (initial_line_number.has_value() && initial_line_number.value() > 0)
m_line = initial_line_number.value(); m_line = initial_line_number.value();
if (initial_column_number.has_value()) if (initial_column_number.has_value())
m_column = initial_column_number.value(); m_column = initial_column_number.value();
} else if (groups.size() == 3) { } else if (groups.size() == 3) {
// Only a line number was specified. // 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(); 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) if (initial_line_number.has_value() && initial_line_number.value() > 0)
m_line = initial_line_number.value(); m_line = initial_line_number.value();
} else { } else {
// A colon was found at the end of the file name but no values were found after it. // 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_filename = groups.at(0).view.to_string();
m_file_name = file_name;
} }
} }

View file

@ -14,12 +14,12 @@ public:
FileArgument(String); FileArgument(String);
~FileArgument(); ~FileArgument();
String file_name() { return m_file_name; } String filename() { return m_filename; }
Optional<size_t> line() { return m_line; } Optional<size_t> line() { return m_line; }
Optional<size_t> column() { return m_column; } Optional<size_t> column() { return m_column; }
private: private:
String m_file_name; String m_filename;
Optional<size_t> m_line; Optional<size_t> m_line;
Optional<size_t> m_column; Optional<size_t> m_column;
}; };

View file

@ -72,7 +72,7 @@ int main(int argc, char** argv)
if (file_to_edit) { if (file_to_edit) {
// A file name was passed, parse any possible line and column numbers included. // A file name was passed, parse any possible line and column numbers included.
FileArgument parsed_argument(file_to_edit); 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; return 1;
text_widget.editor().set_cursor_and_focus_line(parsed_argument.line().value_or(1) - 1, parsed_argument.column().value_or(0)); text_widget.editor().set_cursor_and_focus_line(parsed_argument.line().value_or(1) - 1, parsed_argument.column().value_or(0));
} }