summaryrefslogtreecommitdiff
path: root/src/commands.cc
AgeCommit message (Collapse)Author
2025-07-08Replace on_scope_end with CTAD with OnScopeEnd directlyMaxime Coste
2025-07-08Replace std::unique_ptr with a custom implementationMaxime Coste
<memory> is a costly header we can avoid by just implementing UniquePtr ourselves, which is a pretty straightforward in modern C++, this saves around 10% of the compilation time here.
2025-07-08Remove uses of Regex in BufferManager by taking a more general filterMaxime Coste
2025-06-03Support '*' and comma separated list for exec/eval -client switchMaxime Coste
Closes #5326
2025-06-03Refactor context_wrap use a context_wrap_for_context lambdaMaxime Coste
This makes the code a bit clearer by avoiding the base_context and effective_context pointers and replacing them with calling this lambda with the correct context we want to use as base. This also paves the way towards adding `-client *` support
2025-03-24Fix prompt history recording when using mapped keysJohannes Altmanninger
Commit e3122ab2c (Refactor prompt history handling, 2023-07-05) was a nice simplification but it breaks a rare edge case. It suppresses history recording if all keys the prompt receives were synthesized. That's not quite the right criteria: it means that if prompt is created, edited and and executed, all via mapped keys, we fail to add to history. The criteria should rather be something like "if all keys the prompt receives came from synthesized events". Make it so. This allows us to get rid of the "noninteractive" nested bool that was only used for disabling history.
2025-03-24Default InputHandler::handle_key() synthesized argumentJohannes Altmanninger
We have only one place where we handle actual keys typed by the user.
2025-03-22Merge remote-tracking branch 'lenormf/fix-user-mode-lock'Maxime Coste
2025-02-19Cleanup file.cc/hh dependenciesMaxime Coste
file.cc/hh should not know about Context, Buffer, etc... It should be a pretty low level set of helper functions. Move buffer related functions to buffer_utils and extract busy indicators to callers.
2025-02-16Revert "WIP history register"Maxime Coste
This is not finished yet, and pushed by accident, again... This reverts commit 22b461c3a0b22dd4501943230f0774c34f0b4b35.
2025-02-10WIP history registerMaxime Coste
2024-12-09Print elapsed time when blocked on opening file for writingJohannes Altmanninger
Extract the logic for "waiting for shell to finish" and reuse it for potentially blocking calls to open() that use the O_WRONLY flags.
2024-11-28Add back option to scroll in stdin buffersJohannes Altmanninger
Commit 582c3c56b (Do not add trailing newline to non-scrolling fifo buffers, 2024-01-28) completely forgot about stdin buffers, breaking the ability to make them scrolling via "ge". For example while sleep 1; do seq $LINES date done | kak Let's fix that by adding the trailing newline back for stdin buffers. Unlike "edit -scroll", don't scroll until the user explicitly moves the cursor.
2024-10-22Remove now unused CompletionFlagsMaxime Coste
Since shell-script-completions now runs the script asynchronously and unconditionally, there is no use for the CompletionFlags::Fast anymore which means we can remove that type altogether.
2024-10-22Run shell-script-completions asynchronouslyMaxime Coste
Share most logic with shell-script-candidates. Now that we do not block we can run the completion script implicitely instead of waiting for an explicit completion request with <tab>. Fixes #5245
2024-08-26Do not gather full input data in a single string when pipingMaxime Coste
Refactor ShellManager and pipe to feed lines from the buffer directly, this should reduce memory use when piping big chunks of buffers. The pipe output is still provided as a single big buffer.
2024-08-16include headers cleanupAdrià Arrufat
2024-08-14Merge remote-tracking branch 'arrufat/support-double-underline'Maxime Coste
2024-08-12Move debug utils to debug.hh/debug.ccMaxime Coste
Lots of code includes buffer_utils.hh just for write_to_debug_buffer which pulls many unnecessary dependencies. Reorganise to reduce compile times.
2024-08-04Add support for double underlineAdrià Arrufat
2024-07-22Allow escaping commas in the -buffer argument to eval/execTobias Pisani
I had this issue with device tree binding files in zephyr, that follow the vendor,device.yml convention. The linux kernel presumably uses it as well. While allowing escaping helps, we might consider using a separate option. The most obvious approach might be to move the current behavior to -buffers, and have -buffer be verbatim. However, I'm not entirely sure about the impact of that breakage, so for now, at least the ability to escape it.
2024-07-22Handle word completion when recording macrosMaxime Coste
Make last insert and macro recording closer together, paving the way towards moving last insert to a register. Use a FunctionRef for insert completer key insertion support.
2024-06-24Add EnterDirectory hookPhilipp Jungkamp
This hook runs on `change-directory` and is also emitted just before KakBegin after kakrc has been sourced.
2024-05-29Merge remote-tracking branch 'dontlaugh/debug_mapping_output'Maxime Coste
2024-05-22Add right hand side mapping to "debug mappings"Coleman McFarland
2024-04-29Add local scope to user commandsMaxime Coste
2024-04-27Add buffer -matching switchMaxime Coste
2024-04-19Use a nested command completer for the evaluate-commands commandMaxime Coste
2024-04-19Complete complete-command completer typeMaxime Coste
2024-04-12Introduce "local" scope in evaluate-commandsMaxime Coste
When using `eval` a new scope named 'local' gets pushed for the whole evaluation, this makes it possible to temporarily set an option/hook/alias... Local scopes nest so nested evals do work as expected. Remove the now trivial with-option command
2024-03-27Add SessionRenamed hookTobias Pisani
2024-03-15Fail "define-command -menu" unless a completer is givenJohannes Altmanninger
The "define-command -menu" flag does not do anything unless there is a completer flag. Let's reject it.
2024-02-28Use a size_t :debug memory total to avoid overflowMaxime Coste
2023-12-02ranked match: prefer input order over alphabetical order for user-specified ↵Johannes Altmanninger
completions When using either of set-option g completers option=my_option prompt -shell-script-candidates ... While the search text is empty, the completions will be sorted alphabetically. This is bad because it means the most important entries are not listed first, making them harder to select or even spot. Let's apply input order before resorting to sorting alphabetically. In theory there is a more elegant solution: sort candidates (except if they're user input) before passing them to RankedMatch, and then always use stable sort. However that doesn't work because we use a heap which doesn't support stable sort. Closes #1709, #4813
2023-11-20rc tools menu: replace menu builtin with a prompt-based implementationJohannes Altmanninger
prompt has fuzzy filtering which is more discoverable than the menu mode's regex filtering (because that one needs / to trigger it). There are no important differences left, so replace the menu builtin with a prompt-based command. prompt does not support markup in the completion menu, so drop that feature for now.
2023-11-15Do not use range adaptor to gather ranked matchesMaxime Coste
This ends up constructing RankedMatch twice, once when computing the number of elements then once when actually filling the vector.
2023-11-14Make shell-script-candidates completer run in the backgroundMaxime Coste
Read output from the script as it comes and update the candidate list progressively. Disable updating of the list when a completion has been explicitely selected.
2023-11-14Use a separate copy of the command completer for each completionMaxime Coste
This make the completer lifetime tied to the Prompt mode and removes the need for the Start flag. It also makes it possible to cleanup on completer destruction.
2023-11-03Use explicit target types for gather calls to bypass clang regressionMaxime Coste
Since clang-16 there has been a regression in the P0522R0 support. (Bug report at https://github.com/llvm/llvm-project/issue/63281) Closes #4892
2023-09-26Add a daemonize-session command and refactor local client handlingMaxime Coste
Make it possible to move the current session to a daemon one after the fact, which is useful to ensure the session state survives client disconnecting, for example when working from ssh.
2023-08-27Remove Window::force_redraw()Maxime Coste
This was mostly redundant with Client::force_redraw.
2023-08-13Add a ProfileScope helper class to replace most profiling usesMaxime Coste
2023-07-20Allow map/unmap during mapping executionJohannes Altmanninger
Commits e49c0fb04 (unmap: fail if the mapping is currently executing, 2023-05-14) 42be0057a (map: fail if key is currently executing, 2023-06-24) fixed potential use-after-free issues. By doing so, it broke configurations that in practice have not triggered any crashes [1] [2]. For example with, set -remove global autocomplete insert hook global InsertCompletionShow .* %{ map window insert <esc> <c-o> } hook global InsertCompletionHide .* %{ unmap window insert <esc> <c-o> } The execution of the <esc> mapping triggers InsertCompletionHide fails at unmapping. This seems legit and I don't see an obvious alternative way to write it (InsertIdle would not be correct though it would work in practice). Fix the regression by allowing map and unmap again while keeping the mappings alive until they have finished executing. Applying map/unmap immediately seems like the most obvious semantics. Alternatively, we could apply them in between key presses. [1]: <https://github.com/kak-lsp/kak-lsp/issues/689> [2]: <https://github.com/alexherbo2/auto-pairs.kak/issues/60>
2023-06-17Rename "disable_history" stack state to "noninteractive"Johannes Altmanninger
The commit after next will fix a bug where we wrongly disable prompt history in some scenarios. The root cause is that life span of "disable_history" does not model when we actually want to disable history. Let's rename the state variable to "noninteractive". It's set whenever we are executing a hook, mapping or command. Note that it's also active inside ":prompt"'s callback, which doesn't play well with the new name :(
2023-05-29Refactor KeymapManager to enfore setting is_executing on key iterationMaxime Coste
Add an iterator based remove to HashMap as that was missing. Make KeymapManager responsible for throwing on unmap an executing mapping.
2023-05-25unmap: fail if the mapping is currently executingJohannes Altmanninger
When unmapping a key sequence that is currently executing, we continue executing freed memory which can have weird effects. Let's instead throw an error if that happens. In future we can support unmap in this scenario. Closes #4896
2023-05-21Fix warnings with gcc-13Maxime Coste
2023-03-14Cleanup and speed up test runnerMaxime Coste
Add a -end-of-line switch to echo command to make it possible to use `echo -end-of-line -to-file <file>` to collect env-vars
2023-02-17Complete arguments to "echo -to-file"Johannes Altmanninger
Including this here because grandparent parent commit broke completions for "edit -fifo".
2023-02-14Immediately execute ModuleLoaded hooks for already loaded modulesMaxime Coste
This is trickier than expected because ModuleLoaded hooks can (as any other hooks) use arbitrary regular expressions for their filter. Fixes #4841