summaryrefslogtreecommitdiff
path: root/src/keys.hh
AgeCommit message (Collapse)Author
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>.
2023-02-28Fix new gcc errors for missing types.ioh
Errors when building with gcc 13: ranked_match.hh:10:21: error: ‘uint64_t’ does not name a type 10 | using UsedLetters = uint64_t; | ^~~~~~~~
2023-01-21Replace std::strong_ordering with auto return type to not require <compare>Maxime Coste
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.
2021-12-11Make space a named key to correctly handle shift modifierMaxime Coste
2021-11-21More C++20 refactoringsMaxime Coste
Use CTAD instead of make functions, requires instead of enable_if
2021-11-21Convert comparisons to spaceship operatorMaxime Coste
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
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
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-12-09Refactor parsing of keys and introduce a builtin key parser modeMaxime Coste
By setting the ncurses_builtin_key_parser ui_option to true, we can disable ncurses parsing of key strokes to get less portable parsing but support for more complex modifiers.
2018-12-07Parse xterm-keys for motion directlyJay McCarthy
Ideally, something better should be done (re #2554) but this is a decent intermediate step for some useful keys. Note: NCurses supports parsing these keys when shifted (KEY_SR, _SLEFT, S_RIGHT, etc), but it does not do the same thing for the other modifiers.
2018-06-19Change Search completion to display on top of the modelineMaxime Coste
2018-06-11Add position offset to Window to limit moves with search menu styleMaxime Coste
Window can be resized with an "offset_pos" flag, which means that the resize took place on the top left corner of the window, leading to a change in current window position. This is treated as temporary and the position change is stored in a m_position_offset field. That allows the ncurses UI to offset the position when it displays a Search menu, so that the window does not constantly scroll when the search menu open/closes. The window will only scroll if it needs to in order to keep the main selectin visible.
2018-05-03Add support for explicit menu selection from the UIMaxime Coste
the JsonUI now supports a "menu_select(int)" RPC call that should trigger explicit selection of the provided item index. As discussed for issue #2019.
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>`.
2017-10-20Make the normal mode keymap a compile time hash mapMaxime Coste
This hash map is now fully constexpr, and ends up stored in the read only data segment instead of being recomputed at each startup.
2017-10-20Constexprify various hash functionsMaxime Coste
2017-03-16Fixes some clang-tidy warning and add a few missing meta.hh includeMaxime Coste
2017-03-15Migrate WithBitOps template specialization to with_bit_ops functionMaxime Coste
This way we dont depend on knowing the base template to enable bit ops on an enum type.
2017-01-30Rework NCurses key parsing to properly handle <a-special key>Maxime Coste
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
2015-08-23Rework resize handlingMaxime Coste
Fixes #383
2015-08-18Cleanup key to codepoint conversionMaxime Coste
Fixes #378 Fixes #365
2015-07-15Add support for FocusIn/FocusOut events from UIMaxime Coste
2015-03-28Handle mouse events in key_to_strMaxime Coste
2015-03-22Add support for mouse wheelMaxime Coste
2015-03-22Experimental support for mouseMaxime Coste
2015-03-07Orderable KeysMaxime Coste
2015-01-12Yet more trackingMaxime Coste
2014-12-16Rework hashing, use a more extensible framework similar to n3876 proposalMaxime Coste
std::hash specialization is a pain to work with, stop using that, and just specialize a 'size_t hash_value(const T&)' free function.
2014-11-12Cleanup includesMaxime Coste
2014-10-15Make it more explicit that Key modifiers is a bit fieldMaxime Coste
2014-05-25Rename Key::Erase to Key::Delete and add 'del' keynameMaxime Coste
Fixes #145 Fixes #146
2014-04-20use StringView for parse_keysMaxime Coste
2014-01-09Style changes, replace typedefs with usingsMaxime Coste
2014-01-04Add support for the erase key in prompt and insert modeMaxime Coste
Fixes #18
2013-11-09Add support for function keys F1-F12Maxime Coste
2013-10-26Specify key modifiers using constexpr functions for brevityMaxime Coste
2013-07-26Key: always pass by valueMaxime Coste
2013-04-09sort includes directivesMaxime Coste
2013-02-19Add support for Home/End key in promptsMaxime Coste
2013-01-30Keys: add key_to_str functionMaxime Coste
2012-10-18avoid utf8 errors with invalid keys, like ncurse KEY_RESIZEMaxime Coste
2012-10-09add a unicode.hh header for Codepoint related functions, ↵Maxime Coste
s/utf8::Codepoint/Codepoint/