Add more ed commands.

This commit is contained in:
2026-08-09 21:44:02 +01:00
parent f044f69f1c
commit e56f784c9a
9 changed files with 340 additions and 30 deletions
+10 -4
View File
@@ -19,9 +19,13 @@ struct Command {
Print,
Number,
Append,
Insert,
Change,
Delete,
Write,
Edit,
ForceEdit,
Filename,
Dump,
None
} type;
@@ -56,22 +60,24 @@ struct Ed {
uint64_t line = 0;
bool modified = false;
bool quitting = false;
bool editing = false;
uint64_t marks[26]{0};
std::string last_regex = "";
bool help_mode = false;
bool suppress_mode = false;
bool prompt_mode = false;
std::string prompt = "*";
std::filesystem::path save_path = "";
std::string last_message = "";
Ed(std::filesystem::path file, bool suppress_mode, std::string prompt_)
: vase(file, "/tmp"), suppress_mode(suppress_mode), prompt(prompt_) {
Ed(std::string file_path, bool suppress_mode, std::string prompt_)
: vase("/tmp"), suppress_mode(suppress_mode), prompt(prompt_) {
if (prompt == "")
prompt = "*";
else
prompt_mode = true;
line = vase.lines();
std::cout << vase.length() << std::endl;
if (file_path != "")
handle("E " + file_path, false);
}
void parse_address(std::string_view cmd, uint64_t &i, Command::Address &addr);
+3 -2
View File
@@ -25,8 +25,9 @@ struct Shard {
static void retain(Shard *n);
static void release(Shard *n);
static Shard *from_file(std::filesystem::path path, OriginalBuffer *b, bool posix_ending);
static std::vector<Shard *> from_swap(std::filesystem::path path, OriginalBuffer *b);
static Shard *from_file(std::filesystem::path &path, OriginalBuffer *b, bool posix_ending);
static Shard *from_command(const char *cmd, OriginalBuffer *o, bool posix_ending);
static std::vector<Shard *> from_swap(std::filesystem::path &path, OriginalBuffer *b);
static std::pair<Shard *, Shard *> split(Shard *n, uint64_t offset);
static Shard *concat(Shard *left, Shard *right);
+6
View File
@@ -56,7 +56,13 @@ struct Vase {
std::filesystem::path swapdir;
Vase(std::filesystem::path path, std::filesystem::path swapdir);
Vase(std::string cmd, std::filesystem::path swapdir);
Vase(std::filesystem::path swapdir);
~Vase();
Vase(Vase &&other) noexcept;
Vase &operator=(Vase &&other) noexcept;
Vase(const Vase &) = delete;
Vase &operator=(const Vase &) = delete;
uint64_t length();
uint64_t lines();