summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/pages/options.asciidoc4
-rw-r--r--src/main.cc1
-rw-r--r--src/terminal_ui.cc16
-rw-r--r--src/terminal_ui.hh1
4 files changed, 16 insertions, 6 deletions
diff --git a/doc/pages/options.asciidoc b/doc/pages/options.asciidoc
index 761fbb47..e5cb4c38 100644
--- a/doc/pages/options.asciidoc
+++ b/doc/pages/options.asciidoc
@@ -348,6 +348,10 @@ are exclusively available to built-in options.
if *yes* or *true*, the terminal emulator title will
be changed
+ *terminal_title*:::
+ if set, the terminal title will be set to this string
+ else it will be derived from the modeline.
+
*terminal_status_on_top*:::
if *yes*, or *true* the status line will be placed
at the top of the terminal rather than at the bottom
diff --git a/src/main.cc b/src/main.cc
index 69a71631..09c9b718 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -595,6 +595,7 @@ void register_options()
" terminal_assistant clippy|cat|dilbert|none|off\n"
" terminal_status_on_top bool\n"
" terminal_set_title bool\n"
+ " terminal_title str\n"
" terminal_enable_mouse bool\n"
" terminal_synchronized bool\n"
" terminal_wheel_scroll_amount int\n"
diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc
index bcb0cde5..672626e4 100644
--- a/src/terminal_ui.cc
+++ b/src/terminal_ui.cc
@@ -609,16 +609,19 @@ void TerminalUI::draw_status(const DisplayLine& status_line,
if (m_set_title)
{
Writer writer{STDOUT_FILENO};
- constexpr char suffix[] = " - Kakoune\007";
writer.write("\033]2;");
- // Fill title escape sequence buffer, removing non ascii characters
- for (auto& atom : mode_line)
- {
- const auto str = atom.content();
+ auto write_escaped = [&](StringView str) {
for (auto it = str.begin(), end = str.end(); it != end; utf8::to_next(it, end))
writer.write((*it >= 0x20 and *it <= 0x7e) ? *it : '?');
+ };
+ if (not m_title)
+ {
+ for (auto& atom : mode_line)
+ write_escaped(atom.content());
}
- writer.write(suffix);
+ else
+ write_escaped(*m_title);
+ writer.write(" - Kakoune\007");
}
m_dirty = true;
@@ -1554,6 +1557,7 @@ void TerminalUI::set_ui_options(const Options& options)
m_status_on_top = find("terminal_status_on_top").map(to_bool).value_or(false);
m_set_title = find("terminal_set_title").map(to_bool).value_or(true);
+ m_title = find("terminal_title").map([](StringView s) { return String{s}; });
auto synchronized = find("terminal_synchronized").map(to_bool);
m_synchronized.set = (bool)synchronized;
diff --git a/src/terminal_ui.hh b/src/terminal_ui.hh
index 64e3bfcf..02085532 100644
--- a/src/terminal_ui.hh
+++ b/src/terminal_ui.hh
@@ -153,6 +153,7 @@ private:
int m_shift_function_key = default_shift_function_key;
bool m_set_title = true;
+ Optional<String> m_title;
struct Synchronized
{