summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
AgeCommit message (Collapse)Author
2022-08-17Rename key_to_str() to the more idiomatic to_string()Johannes Altmanninger
This makes the function easier to find for newcomers because to_string() is the obvious name. It enables format() to do the conversion automatically which seems like good idea (since there is no other obvious representation). Of course this change makes it a bit harder to grep but that's not a problem with clang tooling. We need to cast the function in one place when calling transform() but that's acceptable.
2022-07-28Merge remote-tracking branch 'krobelus/support-shift-backspace'Maxime Coste
2022-07-21Remove redundant check for menu bitJohannes Altmanninger
can_auto_insert_completion already requires the menu bit.
2022-07-10Make Shift+Backspace erase a character in insert modeJohannes Altmanninger
Terminals that support CSI u escape codes (like iTerm2, Kitty and foot) allow us to map <s-backspace> independently of <backspace>. Users expect that <s-backspace> does the same as <backspace>, especially when typing ALL_CAPS. Make it so. The first version of 0cf719103 (Make Shift+Space insert a space in insert mode, 2022-02-09) did that already but I later dropped it because I wasn't sure if it's right.
2022-07-05Remove <esc> as end macro recording, Q should be enoughMaxime Coste
Besides being redundant, it is easy to press esc by mistake/habit while recording a macro.
2022-07-05Distinguish between non-eol max column target and plain max columnMaxime Coste
2022-07-05Store HistoryRegisters with most recent entry in frontMaxime Coste
Closes #3105
2022-06-30Insert all register values in prompt after <c-r> when Alt-modifiedMaxime Coste
`<c-r><a-.>` will insert all selections joined by space instead of only the main one as `<c-r>.` would.
2022-06-04Merge remote-tracking branch 'krobelus/shift-space'Maxime Coste
2022-06-04Code style cleanups around insert completerMaxime Coste
2022-05-29Run InsertCompletionHide hook before insertions that close completion menuJohannes Altmanninger
Insert mode completions are accepted by typing any key. For example, if there is a completion "somefunction()", then typing some<c-n>; will insert somefunction(); and then the InsertCompletionHide hook will fire. The hook parameter is a range that contains the entire thing: the actual completion plus the trailing semicolon that closed the completion menu. The [original motivation] for the hook parameter was to support removing text inserted by completion, so we can apply text edits or expand snippets instead. One problem is that we don't want to remove the semicolon. Another problem came up in a discussion about [snippets]: let's say we have a snippet "add" that expands to add(?, ?) where ? are placeholders. After snippet expansion the cursor replaces the first placeholder. If I type "ad<c-n>1" I expect to get "add(1, ?)". If the InsertCompletionHide hook only runs after processing the "1" keystroke, this is not possible without evil hacks. Fix these problems by running InsertCompletionHide when a completion is accepted _before_ inserting anything else into the buffer. This should make it much easier to fully implement [LSP text edits]. I doubt that anyone besides kak-lsp is using the hook parameter today so this should be a low-risk fix. [original motivation]: https://github.com/mawww/kakoune/issues/2898 [snippets]: https://github.com/kak-lsp/kak-lsp/pull/616#discussion_r883208858 [LSP text edits]: https://github.com/kak-lsp/kak-lsp/issues/40
2022-05-01Remove invalid assert in ScopedForceNormal destructorMaxime Coste
commit 90db664635013f6e857ec696403f2164032410a8 introduced logic to handle the case where the mode had been removed, but did not get rid of the assert.
2022-04-16Make Shift+Space insert a space in insert modeJohannes Altmanninger
Terminals that support CSI u escape codes (like iTerm2, Kitty and foot) allow us to map <s-space> independently of <space>. Users expect that <s-space> inputs a space character; make it so. Fixes #4534 Also reported in https://discuss.kakoune.com/t/shift-space-doesnt-send-space-character/2004
2022-04-12Fix crash when deleting a buffer from a user mappingMaxime Coste
Deleting a buffer resets normal mode on all clients that were displaing that buffer, but ScopedForceNormalMode that are used from user mode do not take this possiblity into account on destruction, which leads to deleting the last normal mode from the context, ending up with an empty mode stack. Fixes #3909
2021-12-11Fix mode line inconsistency between normal and insert modesChris Webb
In normal mode, the mode line contains "1 sel" or "n sels (k)" when n > 1, whereas in insert mode, it contains "n sels (k)" even for n == 1. Change the contents in insert mode to match normal mode.
2021-12-11Make space a named key to correctly handle shift modifierMaxime Coste
2021-10-10Split InsertMode into InsertMode and PasteModeMaxime Coste
They are quite different use cases, and this allow moving InsertMode to input_handler.hh which is what uses it. This also cleans up the code as we can get rid of get_insert_pos and rely more on SelectionList::for_each.
2021-08-17Move control character escaping responsibility to the terminal UIMaxime Coste
Fix atom text at display time, allow tabs/eol/etc... in display atoms and escape them just-in-time Fixes #4293
2021-04-30Improve prompt handlingMarkus F.X.J. Oberhumer
As a long time vi user I find it highly irritating that you cannot backspace out of the command prompt.
2021-02-15Add + key to duplicate selections and <a-+> to merge overlapping onesMaxime Coste
This is an experiment and might get reverted if overlapping selections prove too cumbersome. Fixes #4041
2021-01-03Add missing limits includesMaxime Coste
Fixes #4003
2020-12-20Add Timer::disable() to be more explicit than set_next_date(TimePoint::max())Maxime Coste
2020-12-01Avoid potential use after free of the mode nameMaxime Coste
This can be an issue with NextKey that now does not have a static mode name.
2020-12-01Ensure InputModes are kept alive during their idle logicMaxime Coste
Various paths can run arbitrary commands (callbacks, hooks) which could lead to the InputMode being popped off the mode stack, but contrarily to the on_key method, we had no guarantees to be kept alive. Add a keep_alive RefPtr to this to ensure the mode survives till the end. Fixes #3915
2020-11-18Restore auto-select on return, add a flag to disable that for commandsMaxime Coste
Fixes #3849 Again
2020-11-17Revert "Auto-insert prompt menu completions on <ret> if any text was entered"Maxime Coste
Unfortunately this breaks some pretty useful use cases, such as inserting a command ending with a new-line (as it now leads to an addtional command being auto-completed on validation) This reverts commit aab0be529f77f3a8e86185a030838e6d547d0286.
2020-11-01Auto-insert prompt menu completions on <ret> if any text was enteredMaxime Coste
Previously we would only auto-insert if the current token had some text, but this breaks auto-selection of the first match. Fixes #3849
2020-10-20Disable auto-insertion of menu completion when no text was enteredMaxime Coste
This avoids a frustrating behaviour where Kakoune autoinserts the first command name when hitting <space> after a ; in a command line. It also fixes the empty prompt case that was auto-completed instead of executing the default command.
2020-10-19Auto-insert best completion on space for menu completionsMaxime Coste
The menu flag signifies that only the completions are valid arguments, hence it makes sense to auto insert the best one on space. Because full match is always considered the best match in completion ranking, this should always have a reasonable behaviour. This makes it harder to enter a hidden command, but completion can always be disabled via <c-o> or by quoting in those rare cases.
2020-10-19Add support for explicit completion in prompt modeMaxime Coste
2020-07-05Fix selections getting unsorted on scrollMaxime Coste
Fixes #3478
2020-06-28Refactor mouse press/release handling to support 3 buttonsMaxime Coste
Change button to be an additional parameter instead of having separate events for left/right buttons. Fixes #3471
2020-03-15Merge remote-tracking branch 'Anfid/scroll-test'Maxime Coste
2020-02-27Make `on_next_key_with_autoinfo()` respect `idle_timeout`Nicolas Ouellet-Payeur
The prompt and autocomplete normally wait for `idle_timeout` before showing suggestions, however commands like `g`, `v`, or the lead-key show Clippy instantly. This fixes the issue by making `on_next_key_with_autoinfo()` wait for `idle_timeout` before displaying suggestions. Fixes mawww/kakoune#3365 Fixes mawww/kakoune#2066
2019-11-28Update scroll behaviorMikhail Pogretskiy
2019-11-11Add mode information to next-key mode nameMaxime Coste
Currently expose an additional name, the format is up for discussion. Fixes #1855 Fixes #2569 Fixes #2672
2019-10-16Replace ModeChange hooks by ModePush and ModePopMaxime Coste
Remove deprecated InsertBegin, InsertEnd, NormalBegin, NormalEnd hooks. Closes #2545
2019-09-15Allow scrolling while dragging mouseMaxime Coste
Closes #2052
2019-09-07Fix modifiers support with mouse eventsMaxime Coste
2019-08-19Make scrolling speed configurableMaxime Coste
The UI now can send a 'Scroll' key, whose value is the scrolling amount encoded as a signed integer. This replaces the MouseWheelUp and MouseWheelDown keys. The NCursesUI now has a ncurses_wheel_scroll_amount ui_option that controls that amount, it can be negative to swap scrolling direction. Fixes #3045
2019-07-21Slight code cleanup in prompt history handlingMaxime Coste
2019-07-06fix a few typosJoachim Henke
2019-06-23Use register to store prompt historyMaxime Coste
2019-05-29Do not merge selections on backspace in insert modeMaxime Coste
Fixes #2861
2019-05-17Introduce Menu completion flags to auto select best candidateMaxime Coste
2019-04-28Fix typoAlex Leferry 2
2019-02-27Fixed all reorder warningsJustin Frank
2019-01-24Header and dependency cleanupMaxime Coste
2018-12-20src: Add support for right click eventsFrank LENORMAND
The current implementation treats left mouse button clicks as a generic "mouse press" modifier, this commit extends the list of modifiers by adding a "right mouse click" one. The proper way to implement this would be to ship the coordinates of mouse key press events in each `Key` object, and pass whichever button was clicked as a codepoint value (instead of coordinates currently), but this would require more work. This commit allows: * right clicks to set the cursor of the main selection * control-right clicks to merge all the selections, and then set its cursor Fixes #843
2018-11-25Merge remote-tracking branch 'lenormf/rename-auto_complete'Maxime Coste