1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00
serenity/Userland/Applications/TextEditor/FileArgument.h
ry755 8af7cda17a TextEditor: Specify the starting line and column number using colons
This allows the user to specify a specific line and column number to
start at when opening a file in TextEditor through the terminal, by
adding a colon after the file name.

For example, `TextEditor ReadMe.md:10:5` will open ReadMe.md and put
the cursor on line 10 at column 5.

To ensure that the user isn't trying to open a file that actually has
colons in its name, it checks if the file exists before parsing.

Replaces the feature added in b474f49164
Closes #5589
2021-05-02 10:25:51 +02:00

25 lines
491 B
C++

/*
* Copyright (c) 2021, ry755 <ryanst755@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Optional.h>
#include <AK/String.h>
class FileArgument final {
public:
FileArgument(String);
~FileArgument();
String file_name() { return m_file_name; }
Optional<size_t> line() { return m_line; }
Optional<size_t> column() { return m_column; }
private:
String m_file_name;
Optional<size_t> m_line;
Optional<size_t> m_column;
};