diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-04-05 18:43:27 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-04-06 18:43:27 +0100 |
| commit | b7144fff6c8ab013addd3f0c7b17babe62925bc2 (patch) | |
| tree | b461a5e632cc750dd6b4c3a5c5b975c35bb8e3c3 /src | |
| parent | dde16b00a91af805cd382dbccce115569ab9b1f0 (diff) | |
Make ncurses wheel scroll button configurable
Diffstat (limited to 'src')
| -rw-r--r-- | src/ncurses_ui.cc | 19 | ||||
| -rw-r--r-- | src/ncurses_ui.hh | 3 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 7d94d08c..628ccd8b 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -453,11 +453,14 @@ Key NCursesUI::get_key() MEVENT ev; if (getmouse(&ev) == OK) { + auto wheel_down_mask = NCURSES_MOUSE_MASK(m_wheel_down_button, NCURSES_BUTTON_PRESSED); + auto wheel_up_mask = NCURSES_MOUSE_MASK(m_wheel_up_button, NCURSES_BUTTON_PRESSED); + CharCoord pos{ ev.y, ev.x }; if ((ev.bstate & BUTTON1_PRESSED) == BUTTON1_PRESSED) return mouse_press(pos); if ((ev.bstate & BUTTON1_RELEASED) == BUTTON1_RELEASED) return mouse_release(pos); - if ((ev.bstate & BUTTON2_PRESSED) == BUTTON2_PRESSED) return mouse_wheel_down(pos); - if ((ev.bstate & BUTTON4_PRESSED) == BUTTON4_PRESSED) return mouse_wheel_up(pos); + if ((ev.bstate & wheel_down_mask) == wheel_down_mask) return mouse_wheel_down(pos); + if ((ev.bstate & wheel_up_mask) == wheel_up_mask) return mouse_wheel_up(pos); else return mouse_pos(pos); } } @@ -880,6 +883,18 @@ void NCursesUI::set_ui_options(const Options& options) if (it != options.end()) m_status_on_top = it->second == "yes" or it->second == "true"; } + + { + auto wheel_down_it = options.find("ncurses_wheel_down_button"); + if (wheel_down_it != options.end()) try { + m_wheel_down_button = str_to_int(wheel_down_it->second);; + } catch(...) {} + + auto wheel_up_it = options.find("ncurses_wheel_up_button"); + if (wheel_up_it != options.end()) try { + m_wheel_up_button = str_to_int(wheel_up_it->second);; + } catch(...) {} + } } } diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh index 411cab58..2f992d2e 100644 --- a/src/ncurses_ui.hh +++ b/src/ncurses_ui.hh @@ -75,6 +75,9 @@ private: bool m_status_on_top = false; ConstArrayView<StringView> m_assistant; + int m_wheel_down_button = 2; + int m_wheel_up_button = 4; + bool m_dirty = false; }; |
