mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-24 07:53:41 +03:00
NCursesUI: Add support for shifted function keys
Shifted function keys are not well standardized around terminals, Shift F(N) usually returns F(X) + N, with X=12 on xterm, X=10 on rxvt-unicode... Default to X=12 and make it configuable through the ncurses_shift_function_key ui_option. This fixes what #1898 tried to.
This commit is contained in:
parent
50e422659b
commit
5fa19f4d7f
@ -278,3 +278,7 @@ are exclusively available to built-in options.
|
|||||||
|
|
||||||
*ncurses_wheel_down_button*, *ncurses_wheel_up_button*:::
|
*ncurses_wheel_down_button*, *ncurses_wheel_up_button*:::
|
||||||
specify which button send for wheel down/up events
|
specify which button send for wheel down/up events
|
||||||
|
|
||||||
|
*ncurses_shift_function_key*:::
|
||||||
|
Function key from which shifted function key start, if th
|
||||||
|
terminal sends F13 for <s-F1>, this should be set to 12.
|
||||||
|
@ -360,7 +360,8 @@ void register_options()
|
|||||||
" ncurses_enable_mouse bool\n"
|
" ncurses_enable_mouse bool\n"
|
||||||
" ncurses_change_colors bool\n"
|
" ncurses_change_colors bool\n"
|
||||||
" ncurses_wheel_up_button int\n"
|
" ncurses_wheel_up_button int\n"
|
||||||
" ncurses_wheel_down_button int\n",
|
" ncurses_wheel_down_button int\n"
|
||||||
|
" ncurses_shift_function_key int\n",
|
||||||
UserInterface::Options{});
|
UserInterface::Options{});
|
||||||
reg.declare_option("modelinefmt", "format string used to generate the modeline",
|
reg.declare_option("modelinefmt", "format string used to generate the modeline",
|
||||||
"%val{bufname} %val{cursor_line}:%val{cursor_char_column} {{context_info}} {{mode_info}} - %val{client}@[%val{session}]"_str);
|
"%val{bufname} %val{cursor_line}:%val{cursor_char_column} {{context_info}} {{mode_info}} - %val{client}@[%val{session}]"_str);
|
||||||
|
@ -29,6 +29,8 @@ using std::max;
|
|||||||
|
|
||||||
struct NCursesWin : WINDOW {};
|
struct NCursesWin : WINDOW {};
|
||||||
|
|
||||||
|
constexpr int NCursesUI::default_shift_function_key;
|
||||||
|
|
||||||
static constexpr StringView assistant_cat[] =
|
static constexpr StringView assistant_cat[] =
|
||||||
{ R"( ___ )",
|
{ R"( ___ )",
|
||||||
R"( (__ \ )",
|
R"( (__ \ )",
|
||||||
@ -615,8 +617,10 @@ Optional<Key> NCursesUI::get_next_key()
|
|||||||
|
|
||||||
for (int i = 0; i < 12; ++i)
|
for (int i = 0; i < 12; ++i)
|
||||||
{
|
{
|
||||||
if (c == KEY_F(i+1))
|
if (c == KEY_F(i + 1))
|
||||||
return {Key::F1 + i};
|
return {Key::F1 + i};
|
||||||
|
if (c == KEY_F(m_shift_function_key + i + 1))
|
||||||
|
return shift(Key::F1 + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c >= 0 and c < 256)
|
if (c >= 0 and c < 256)
|
||||||
@ -1082,6 +1086,13 @@ void NCursesUI::set_ui_options(const Options& options)
|
|||||||
(it->value == "yes" or it->value == "true");
|
(it->value == "yes" or it->value == "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto it = options.find("ncurses_shift_function_key"_sv);
|
||||||
|
m_shift_function_key = it != options.end() ?
|
||||||
|
str_to_int_ifp(it->value).value_or(default_shift_function_key)
|
||||||
|
: default_shift_function_key;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto it = options.find("ncurses_change_colors"_sv);
|
auto it = options.find("ncurses_change_colors"_sv);
|
||||||
auto value = it == options.end() or
|
auto value = it == options.end() or
|
||||||
|
@ -140,6 +140,9 @@ private:
|
|||||||
int m_wheel_up_button = 4;
|
int m_wheel_up_button = 4;
|
||||||
int m_wheel_down_button = 5;
|
int m_wheel_down_button = 5;
|
||||||
|
|
||||||
|
static constexpr int default_shift_function_key = 12;
|
||||||
|
int m_shift_function_key = default_shift_function_key;
|
||||||
|
|
||||||
bool m_set_title = true;
|
bool m_set_title = true;
|
||||||
bool m_change_colors = true;
|
bool m_change_colors = true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user