Add help and history prune commands

- And other minor fixes/cleanup.
This commit is contained in:
2026-09-03 11:40:07 +01:00
parent cd9583ec34
commit 662df68ab4
6 changed files with 218 additions and 42 deletions
+29 -26
View File
@@ -34,7 +34,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Line,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::Text,
.desc = "Append text to a line.",
.desc = "Append text to a line",
.default_address = ".",
.accept_zero = true,
.pre_text_mode = nullptr,
@@ -57,7 +57,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::Text,
.desc = "Change set of lines.",
.desc = "Change a range of lines",
.default_address = ".,.",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -80,7 +80,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Delete set of lines.",
.desc = "Delete a range of lines",
.default_address = ".,.",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -102,7 +102,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::File,
.input_mode = Function::InputMode::None,
.desc = "Try load a file into the current buffer.",
.desc = "Load a file into the current buffer, warn once if unsaved changes exist",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -152,7 +152,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::File,
.input_mode = Function::InputMode::None,
.desc = "Load a file into the current buffer.",
.desc = "Load a file into the current buffer, discarding unsaved changes",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -198,7 +198,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::File,
.input_mode = Function::InputMode::None,
.desc = "Set a save path.",
.desc = "Set/print a save path",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -248,7 +248,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Toggle help mode.",
.desc = "Toggle help mode",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -271,7 +271,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Line,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::Text,
.desc = "Insert text before a line.",
.desc = "Insert text before a line",
.default_address = ".",
.accept_zero = true,
.pre_text_mode = nullptr,
@@ -296,7 +296,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Join a set of lines.",
.desc = "Join a range of lines",
.default_address = ".,.+1",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -318,7 +318,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Line,
.argument_kind = Function::ArgumentKind::Mark,
.input_mode = Function::InputMode::None,
.desc = "Mark a line.",
.desc = "Mark a line",
.default_address = ".",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -340,7 +340,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "List (print unambiguous) range",
.desc = "Print a range, showing nonprinting characters unambiguously",
.default_address = ".,.",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -363,7 +363,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::Line,
.input_mode = Function::InputMode::None,
.desc = "Move a range of lines.",
.desc = "Move a range of lines",
.default_address = ".,.",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -407,7 +407,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Print range with line numbers",
.desc = "Print a range with line numbers",
.default_address = ".,.",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -430,7 +430,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Print range",
.desc = "Print a range",
.default_address = ".,.",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -453,7 +453,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::Any,
.input_mode = Function::InputMode::None,
.desc = "Toggle/set prompt.",
.desc = "Toggle/set prompt string",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -482,7 +482,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Try quitting.",
.desc = "Quit, warn once if unsaved changes exist",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -513,7 +513,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Force quit.",
.desc = "Quit without saving, discarding unsaved changes",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -534,7 +534,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Line,
.argument_kind = Function::ArgumentKind::File,
.input_mode = Function::InputMode::None,
.desc = "Read from file into buffer.",
.desc = "Read a file's contents into the buffer after the given address",
.default_address = "$",
.accept_zero = true,
.pre_text_mode = nullptr,
@@ -581,7 +581,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::Regex,
.input_mode = Function::InputMode::None,
.desc = "Substitute regex.",
.desc = "Substitute pattern in range for replacement",
.default_address = ".,.",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -620,7 +620,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::Line,
.input_mode = Function::InputMode::None,
.desc = "Copy a range of lines.",
.desc = "Copy a range of lines",
.default_address = ".,.",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -650,7 +650,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Undo last modification to buffer.",
.desc = "Undo the last modification to the buffer",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -677,7 +677,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::File,
.input_mode = Function::InputMode::None,
.desc = "Write buffer to disk.",
.desc = "Write a range of lines to disk",
.default_address = "0,$",
.accept_zero = true,
.pre_text_mode = nullptr,
@@ -729,7 +729,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Range,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Print line numbers",
.desc = "Print the line number of the given address",
.default_address = "$",
.accept_zero = true,
.pre_text_mode = nullptr,
@@ -758,7 +758,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::Shell,
.input_mode = Function::InputMode::None,
.desc = "Run a shell command.",
.desc = "Run a shell command",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,
@@ -785,7 +785,7 @@ void Function::register_posix(BEd &ctx) {
.address_kind = Function::AddressKind::Line,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Prints a line and jumps to it.",
.desc = "Print given line and move the cursor to it",
.default_address = ".+1",
.accept_zero = true,
.pre_text_mode = nullptr,
@@ -800,13 +800,16 @@ void Function::register_posix(BEd &ctx) {
if (addr.number != 0)
ctx.buffer(addr.buffername).print(ctx, addr.number, addr.number);
ctx.current() = addr;
ctx.prev().buffername = addr.buffername;
ctx.prev().start = addr.number;
ctx.prev().end = addr.number;
}
};
ctx.eof_op = Function{
.address_kind = Function::AddressKind::None,
.argument_kind = Function::ArgumentKind::None,
.input_mode = Function::InputMode::None,
.desc = "Try quitting.",
.desc = "Quit, warn once if unsaved changes exist",
.default_address = "",
.accept_zero = false,
.pre_text_mode = nullptr,