diff options
| author | Maxime Coste <mawww@kakoune.org> | 2025-02-16 10:17:00 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2025-02-16 10:17:00 +1100 |
| commit | 026284deb250ae420ea97f90a716fdda3ab6224f (patch) | |
| tree | 9faadc0e33ba4c15ba12945c1590ec9dfe95aca7 | |
| parent | 0a4bea856fe6ddd6420d6d7141b20eed8fe0bd25 (diff) | |
Revert "WIP history register"
This is not finished yet, and pushed by accident, again...
This reverts commit 22b461c3a0b22dd4501943230f0774c34f0b4b35.
| -rw-r--r-- | doc/pages/changelog.asciidoc | 6 | ||||
| -rw-r--r-- | doc/pages/commands.asciidoc | 3 | ||||
| -rw-r--r-- | src/commands.cc | 5 | ||||
| -rw-r--r-- | src/main.cc | 3 | ||||
| -rw-r--r-- | src/register_manager.cc | 17 | ||||
| -rw-r--r-- | src/register_manager.hh | 7 |
6 files changed, 11 insertions, 30 deletions
diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index 7d92fa42..f443f207 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -6,16 +6,10 @@ released versions. == Development version * Expose env vars that are mentioned in the arguments passed to shell expansions - * Support for colored double underlines - * `git apply` can now operate on selected changes in the current buffer's file (useful for quick (un)staging and reverting) -* `prompt -history-register` switch to specify which register to use for - a prompt history. - - == Kakoune 2024.05.18 * Fixed tests on Alpine Linux and *BSD diff --git a/doc/pages/commands.asciidoc b/doc/pages/commands.asciidoc index b0fb104e..6b5a48e5 100644 --- a/doc/pages/commands.asciidoc +++ b/doc/pages/commands.asciidoc @@ -319,9 +319,6 @@ but not really useful in that context. will have this command executed whenever the prompt content changes or the prompt is aborted, respectively. - The *-history-register <register-name>* switch selects which register - to use to load and store history for this prompt. - Completion support can be controlled with the same switches provided by the *define-command* command, see <<declaring-new-commands,Declaring new commands>>. diff --git a/src/commands.cc b/src/commands.cc index 086097ec..0f892004 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -2269,7 +2269,6 @@ const CommandDesc prompt_cmd = { { "shell-completion", { {}, "use shell command completion for prompt" } }, { "shell-script-completion", { ArgCompleter{}, "use shell command completion for prompt" } }, { "shell-script-candidates", { ArgCompleter{}, "use shell command completion for prompt" } }, - { "history-register", { ArgCompleter{}, "register to read and store history to, default to '_'"} }, { "on-change", { ArgCompleter{}, "command to execute whenever the prompt changes" } }, { "on-abort", { ArgCompleter{}, "command to execute whenever the prompt is canceled" } } }, ParameterDesc::Flags::None, 2, 2 @@ -2289,11 +2288,9 @@ const CommandDesc prompt_cmd = { const auto flags = parser.get_switch("password") ? PromptFlags::Password : PromptFlags::None; - auto history_register = RegisterManager::parse_register_name(parser.get_switch("history-register").value_or("_")); - context.input_handler().prompt( parser[0], initstr.str(), {}, context.faces()["Prompt"], - flags, history_register, std::move(completer), + flags, '_', std::move(completer), [command, on_change = parser.get_switch("on-change").value_or("").str(), on_abort = parser.get_switch("on-abort").value_or("").str(), diff --git a/src/main.cc b/src/main.cc index 9f479768..ac9af4ca 100644 --- a/src/main.cc +++ b/src/main.cc @@ -49,7 +49,6 @@ struct { "» kak_* appearing in shell arguments will be added to the environment\n" "» {+U}double underline{} support\n" "» {+u}git apply{} can stage/revert selected changes to current buffer\n" - "» {+u}prompt -history-register{} switch\n" }, { 20240518, "» Fix tests failing on some platforms\n" @@ -607,7 +606,7 @@ void register_options() " terminal_info_max_width int\n", UserInterface::Options{}); reg.declare_option("modelinefmt", "format string used to generate the modeline", - "%val{bufname} %val{cursor_line}:%val{cursor_char_column} {{busy_indicator}} {{context_info}} {{mode_info}} - %val{client}@[%val{session}]"_str); + "%val{bufname} %val{cursor_line}:%val{cursor_char_column} {{context_info}} {{mode_info}} - %val{client}@[%val{session}]"_str); reg.declare_option("debug", "various debug flags", DebugFlags::None); reg.declare_option("readonly", "prevent buffers from being modified", false); diff --git a/src/register_manager.cc b/src/register_manager.cc index 987849e1..b9d09a52 100644 --- a/src/register_manager.cc +++ b/src/register_manager.cc @@ -70,7 +70,7 @@ const String& HistoryRegister::get_main(const Context&, size_t) return m_content.empty() ? String::ms_empty : m_content.front(); } -static const HashMap<StringView, char> reg_names { +static const HashMap<StringView, Codepoint> reg_names { { "slash", '/' }, { "dquote", '"' }, { "pipe", '|' }, @@ -83,23 +83,18 @@ static const HashMap<StringView, char> reg_names { { "colon", ':' } }; -char RegisterManager::parse_register_name(StringView reg) +Register& RegisterManager::operator[](StringView reg) const { if (reg.length() == 1) - return reg[0_byte]; + return (*this)[reg[0_byte]]; auto it = reg_names.find(reg); if (it == reg_names.end()) throw runtime_error(format("no such register: '{}'", reg)); - return it->value; -} - -Register& RegisterManager::operator[](StringView reg) const -{ - return (*this)[parse_register_name(reg)]; + return (*this)[it->value]; } -Register& RegisterManager::operator[](char c) const +Register& RegisterManager::operator[](Codepoint c) const { c = to_lower(c); auto it = m_registers.find(c); @@ -109,7 +104,7 @@ Register& RegisterManager::operator[](char c) const return *(it->value); } -void RegisterManager::add_register(char c, std::unique_ptr<Register> reg) +void RegisterManager::add_register(Codepoint c, std::unique_ptr<Register> reg) { auto& reg_ptr = m_registers[c]; kak_assert(not reg_ptr); diff --git a/src/register_manager.hh b/src/register_manager.hh index 6c7cf084..9d843eff 100644 --- a/src/register_manager.hh +++ b/src/register_manager.hh @@ -118,17 +118,16 @@ public: class RegisterManager : public Singleton<RegisterManager> { public: - static char parse_register_name(StringView reg); Register& operator[](StringView reg) const; - Register& operator[](char c) const; - void add_register(char c, std::unique_ptr<Register> reg); + Register& operator[](Codepoint c) const; + void add_register(Codepoint c, std::unique_ptr<Register> reg); CandidateList complete_register_name(StringView prefix, ByteCount cursor_pos) const; auto begin() const { return m_registers.begin(); } auto end() const { return m_registers.end(); } protected: - HashMap<char, std::unique_ptr<Register>, MemoryDomain::Registers> m_registers; + HashMap<Codepoint, std::unique_ptr<Register>, MemoryDomain::Registers> m_registers; }; } |
