mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:07:36 +00:00
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
This commit is contained in:
parent
68a542623f
commit
8af7cda17a
4 changed files with 94 additions and 8 deletions
25
Userland/Applications/TextEditor/FileArgument.h
Normal file
25
Userland/Applications/TextEditor/FileArgument.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue