diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-08-19 22:16:39 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-08-19 22:16:39 +1000 |
| commit | 2359df0f1754a29a451e86f6835d572fcd7fe393 (patch) | |
| tree | 053f08739b4fd11e988732f682289986a8747074 /src/json_ui.cc | |
| parent | f1047181cb35fb5ee6e4e8bf85adfa4aafa4be19 (diff) | |
Make scrolling speed configurable
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
Diffstat (limited to 'src/json_ui.cc')
| -rw-r--r-- | src/json_ui.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/json_ui.cc b/src/json_ui.cc index b8acd6ad..ebb3b7bf 100644 --- a/src/json_ui.cc +++ b/src/json_ui.cc @@ -430,13 +430,18 @@ void JsonUI::eval_json(const Value& json) m_on_key({Key::Modifiers::MouseReleaseLeft, coord}); else if (type == "release_right") m_on_key({Key::Modifiers::MouseReleaseRight, coord}); - else if (type == "wheel_up") - m_on_key({Key::Modifiers::MouseWheelUp, coord}); - else if (type == "wheel_down") - m_on_key({Key::Modifiers::MouseWheelDown, coord}); else throw invalid_rpc_request(format("invalid mouse event type: {}", type)); } + else if (method == "scroll") + { + if (params.size() != 1) + throw invalid_rpc_request("scroll needs an amount"); + else if (not params[0].is_a<int>()) + throw invalid_rpc_request("scroll amount is not an integer"); + m_on_key({Key::Modifiers::Scroll, (Codepoint)params[0].as<int>()}); + + } else if (method == "menu_select") { if (params.size() != 1) |
