Change ncurses title logic, use hard coded \033]2;<title>\007 sequence

And add a ncurses_set_title ui option defaulting to true.
This commit is contained in:
Maxime Coste 2015-09-03 00:03:07 +01:00
parent 995a094471
commit ea7f76f7f2
3 changed files with 16 additions and 11 deletions

View File

@ -727,6 +727,8 @@ Some options are built in Kakoune, and can be used to control it's behaviour:
modification is detected.
* `ui_options`: colon separated list of key=value pairs that are forwarded to
the user interface implementation. The NCurses UI support the following options:
- `ncurses_set_title`: if `yes` or `true`, the terminal emulator title will
be changed.
- `ncurses_status_on_top`: if `yes`, or `true` the status line will be placed
at the top of the terminal rather than at the bottom.
- `ncurses_assistant`: specify the nice assistant you get in info boxes, can

View File

@ -413,16 +413,13 @@ void NCursesUI::draw_status(const DisplayLine& status_line,
draw_line(trimmed_mode_line, col, default_face);
}
const char* tsl = tigetstr((char*)"tsl");
const char* fsl = tigetstr((char*)"fsl");
if (tsl != 0 and (ptrdiff_t)tsl != -1 and
fsl != 0 and (ptrdiff_t)fsl != -1)
if (m_set_title)
{
String title;
String title = "\033]2;";
for (auto& atom : mode_line)
title += atom.content();
title += " - Kakoune";
printf("%s%s%s", tsl, title.c_str(), fsl);
title += " - Kakoune\007";
write(1, title.data(), (int)title.length());
}
m_dirty = true;
@ -930,10 +927,14 @@ void NCursesUI::set_ui_options(const Options& options)
{
auto it = options.find("ncurses_status_on_top");
if (it == options.end())
m_status_on_top = false;
else
m_status_on_top = it->second == "yes" or it->second == "true";
m_status_on_top = it != options.end() and
(it->second == "yes" or it->second == "true");
}
{
auto it = options.find("ncurses_set_title");
m_set_title = it == options.end() or
(it->second == "yes" or it->second == "true");
}
{

View File

@ -83,6 +83,8 @@ private:
int m_wheel_down_button = 2;
int m_wheel_up_button = 4;
bool m_set_title = true;
bool m_dirty = false;
};