summaryrefslogtreecommitdiff
path: root/src/keys.cc
AgeCommit message (Collapse)Author
2024-08-16include headers cleanupAdrià Arrufat
2024-08-14Merge remote-tracking branch 'enricozb/enricozb/scroll-coordinates'Maxime Coste
2024-08-12Reduce headers dependency graphMaxime Coste
Move more code into the implementation files to reduce the amount of code pulled by headers.
2024-08-04fix mouse coord underflowEnrico Zandomeni Borba
previously, clicking on the status line if it is on the top of the window results on a coord.line = 1 << 16, or there abouts. This is because the expression (key & 0xFFFF0000) >> 16 results in an `shr` instruction which does not propagate the sign bit. Mouse event coordinates can be negative if the status line is on top and the status line is clicked. The new line (int32_t) (key & 0xFFFF0000) >> 16 properly propagates the sign bit, leading to the correct signed numeric line coordinate.
2024-08-04add scroll coordinatesEnrico Zandomeni Borba
adds scroll amount in the upper 16-bits of `Key.modifiers`, reclaiming the space in `Key.key` for coordinates. Previously, while mouse events included their coordinates, scrolling did not. Scroll events are now emitted as <scroll:amount:line.column>.
2024-06-05Add <quote> and <dquote> key name aliases.Tobias Pisani
These two can also be annoying to have to escape, so this should make it slightly easier to manage
2023-05-11Fix debug keys output for shift/ctrl modified mouse eventsChris Webb
Although Kakoune responds to modified mouse events, they show up in the debug buffer corrupted. to_string() tests for equality on the mouse event modifiers rather than testing just the relevant bits, so the modified mouse events incorrectly fall through to the normal key handling. Fix this and restructure to allow mouse events to be modifier-prefixed. Signed-off-by: Chris Webb <chris@arachsys.com>
2022-08-17Rename button_to_str() to the more idiomatic to_string()Johannes Altmanninger
Analogous to the parent commit. This returns StringView, but it's immortal so it's even better than String.
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-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
2021-12-11Make space a named key to correctly handle shift modifierMaxime Coste
2021-05-28Fix focus_in/focus_out keys not having user friendly namesMaxime Coste
2020-10-31src/ncurses_ui.cc: Teach Kakoune about ctrl-symbol keys.Tim Allen
Previously, Kakoune only handled ctrl-codes less than 27, representing them as lower-case ASCII codes. For regular keys like <c-a>, that worked fine. However, NUL became the unorthodox <c-`> and other ctrl-symbols (<c-\>, <c-]>, <c-_>) weren't supported at all. Now NUL is rendered as the more comfortable <c-space>, and the other ctrl-symbol codes are properly decoded. Fixes #2553.
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-06-03src: Introduce a <percent> named keyFrank LENORMAND
Similarly to the <semicolon> key, make it easier to write `:execute-keys` commands by replacing <percent> with `%`. Highlighters can keep escaping the sign when regular expressions are not quoted, but built-in scripts that use `%` as an editing primitive have been modified to use the named key, for clarity.
2020-04-13Parse ascii newline/tab/escape as special keys instead of control keysMaxime Coste
Fixes #3439
2019-10-22src: Create a <semicolon> named keyFrank LENORMAND
This commit allows using the <semicolon> expansion in commands, instead of `\;`. It makes commands look more elegant, and prevents new-comers from falling into the trap of using <a-;> without escaping the semicolon.
2019-09-08Fix printing of F12 keyMaxime 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-07allow for mapping the Insert keyJoachim Henke
2019-06-24src: Enforce case sensitivity when parsing function keysFrank LENORMAND
The `parse_keys()` function is case insensitive when parsing function keys, while the `key_to_str()` function always returns a capitalized key description. When users hook on the lowercase name of a function key, e.g. `NormalKey <f10>`, and later hit that same key in normal mode, the `key_to_str()` will convert it to the uppercase description ("<F10>"). This results into a hook with a lowercase regex predicate being unsuccessfully matched against an uppercase key description by the hook manager, which works on a case sensitive basis. One solution could be to uppercase all function key descriptions passed as hook filter upon declaration, but detecting that is not trivial as the filter can contain more than just the simple <f\d+> data, e.g. --- hook global InsertKey '<(?<name>\w+)>' %{…} --- Another simpler solution that this commit implements is to allow only <F\d+> descriptions in `parse_keys()`, and hope users will know not to use the lowercase notation when declaring hooks. Fixes #2907
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-04-11Add support for the shift modifier.Tim Allen
Because keyboard layouts vary, the shift-modifier `<s-…>` is only supported for special keys (like `<up>` and `<home>`) and for ASCII lowercase where we assume the shift-modifier just produces the matching uppercase character. Even that's not universally true, since in Turkish `i` and `I` are not an uppercase/lowercase pair, but Kakoune's default keyboard mappings already assume en-US mappings for mnemonic purposes. Mappings of the form `<s-x>` are normalized to `<X>` when `x` is an ASCII character. `<backtab>` is removed, since we can now say `<s-tab>`.
2018-04-06Make error messages more consistentDelapouite
2017-10-10Move all non-core string code to string_utils.{hh,cc}Maxime Coste
2017-08-29Rename containers.hh to ranges.hh (and Container to Range)Maxime Coste
2017-07-19Cleanup some code with C++14 featuresMaxime Coste
2017-04-11Name key '+' as plus and '-' as minusMaxime Coste
2017-04-11Change multi modifier key syntax to be <c-a-space> instead of <ca-space>Maxime Coste
Better fix for #1311
2017-04-10Add support for parsing multiple modifiers in keysMaxime Coste
<ca-key> means control+alt key, <ac-key> works as well. Fixes #1311
2017-01-08Apply clang-tidy modernize to the codebaseMaxime Coste
2016-12-14Support inserting esc characters through <c-v>Maxime Coste
As requested in #960
2016-10-13Support Ctrl + mouse dragging to add a new selectionMaxime Coste
Fixes #838
2016-10-01Support codepoints of variable widthMaxime Coste
Add a ColumnCount type and use it in place of CharCount whenever more appropriate, take column size of codepoints into account for vertical movements and docstring wrapping. Fixes #811
2016-07-05Use named keys for Return and Tab instead of <c-m> and <c-i>Maxime Coste
Fixes #722
2016-06-30Support Resize modifiers in key_to_strMaxime Coste
As seen in #715, that was not supported correctly
2016-03-23Support mosue event in key_to_strMaxime Coste
2016-02-05More string usage cleanupMaxime Coste
2015-11-11Fix to_lower/to_upper handling to correctly support non unicode charsMaxime Coste
require a proper unicode locale setup on the system Fixes #94
2015-09-23Refactor utf8::iterator to be on the safe sideMaxime Coste
utf8::iterator now knows the iterator valid range, and pass it to utf8 functions.
2015-08-18Cleanup key to codepoint conversionMaxime Coste
Fixes #378 Fixes #365
2015-05-22Move unit test functions in next to the code they are testingMaxime Coste
2015-03-28Handle mouse events in key_to_strMaxime Coste
2015-03-27Make utf8_iterator a proper stl useable iteratorMaxime Coste
2015-03-10Refactor String, use a common StringOps interface, hide std::stringMaxime Coste
2014-12-29Use a struct KeyAndName rather than a std::pairMaxime Coste
2014-12-23Move containers utils to containers.hh and add filtered/transformed utilsMaxime Coste
2014-12-08More string cleanupsMaxime Coste
2014-11-09refactor parse_keysMaxime Coste
2014-11-09small code simplificationMaxime Coste