diff --git a/doc/pages/options.asciidoc b/doc/pages/options.asciidoc index 96afb9a4..bc5fbf79 100644 --- a/doc/pages/options.asciidoc +++ b/doc/pages/options.asciidoc @@ -278,3 +278,7 @@ are exclusively available to built-in options. *ncurses_wheel_down_button*, *ncurses_wheel_up_button*::: 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 , this should be set to 12. diff --git a/src/main.cc b/src/main.cc index e152fa94..26cb1ebf 100644 --- a/src/main.cc +++ b/src/main.cc @@ -360,7 +360,8 @@ void register_options() " ncurses_enable_mouse bool\n" " ncurses_change_colors bool\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{}); 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); diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index e6863945..9514af07 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -29,6 +29,8 @@ using std::max; struct NCursesWin : WINDOW {}; +constexpr int NCursesUI::default_shift_function_key; + static constexpr StringView assistant_cat[] = { R"( ___ )", R"( (__ \ )", @@ -615,8 +617,10 @@ Optional NCursesUI::get_next_key() for (int i = 0; i < 12; ++i) { - if (c == KEY_F(i+1)) + if (c == KEY_F(i + 1)) 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) @@ -1082,6 +1086,13 @@ void NCursesUI::set_ui_options(const Options& options) (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 value = it == options.end() or diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh index 35889193..d2449d59 100644 --- a/src/ncurses_ui.hh +++ b/src/ncurses_ui.hh @@ -140,6 +140,9 @@ private: int m_wheel_up_button = 4; 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_change_colors = true;