mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-29 10:02:57 +03:00
Make ncurses wheel scroll button configurable
This commit is contained in:
parent
dde16b00a9
commit
b7144fff6c
@ -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(...) {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user