mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +00:00
LibVT: Add title stack support
This feature allows applications to reset the window title once they exited. It is used by `vim` if `set title` is enabled.
This commit is contained in:
parent
439dc9b734
commit
ee24f2eb2d
2 changed files with 35 additions and 6 deletions
|
@ -267,7 +267,31 @@ void Terminal::XTERM_WM(Parameters params)
|
||||||
{
|
{
|
||||||
if (params.size() < 1)
|
if (params.size() < 1)
|
||||||
return;
|
return;
|
||||||
dbgln("FIXME: XTERM_WM: Ps: {} (param count: {})", params[0], params.size());
|
switch (params[0]) {
|
||||||
|
case 22: {
|
||||||
|
if (params.size() > 1 && params[1] == 1) {
|
||||||
|
dbgln("FIXME: we don't support icon titles");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbgln_if(TERMINAL_DEBUG, "Title stack push: {}", m_current_window_title);
|
||||||
|
[[maybe_unused]] auto rc = m_title_stack.try_append(move(m_current_window_title));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 23: {
|
||||||
|
if (params.size() > 1 && params[1] == 1)
|
||||||
|
return;
|
||||||
|
if (m_title_stack.is_empty()) {
|
||||||
|
dbgln("Shenanigans: Tried to pop from empty title stack");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_current_window_title = m_title_stack.take_last();
|
||||||
|
dbgln_if(TERMINAL_DEBUG, "Title stack pop: {}", m_current_window_title);
|
||||||
|
m_client.set_window_title(m_current_window_title);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
dbgln("FIXME: XTERM_WM: Ps: {} (param count: {})", params[0], params.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Terminal::DECSTBM(Parameters params)
|
void Terminal::DECSTBM(Parameters params)
|
||||||
|
@ -934,12 +958,14 @@ void Terminal::execute_osc_sequence(OscParameters parameters, u8 last_byte)
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
if (parameters.size() < 2)
|
if (parameters.size() < 2) {
|
||||||
dbgln("Attempted to set window title without any parameters");
|
dbgln("Attempted to set window title without any parameters");
|
||||||
else
|
} else {
|
||||||
m_client.set_window_title(stringview_ify(1));
|
// FIXME: the split breaks titles containing semicolons.
|
||||||
// FIXME: the split breaks titles containing semicolons.
|
// Should we expose the raw OSC string from the parser? Or join by semicolon?
|
||||||
// Should we expose the raw OSC string from the parser? Or join by semicolon?
|
m_current_window_title = stringview_ify(1).to_string();
|
||||||
|
m_client.set_window_title(m_current_window_title);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
|
|
|
@ -339,6 +339,9 @@ protected:
|
||||||
Attribute m_current_attribute;
|
Attribute m_current_attribute;
|
||||||
Attribute m_saved_attribute;
|
Attribute m_saved_attribute;
|
||||||
|
|
||||||
|
String m_current_window_title;
|
||||||
|
Vector<String> m_title_stack;
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
u32 m_next_href_id { 0 };
|
u32 m_next_href_id { 0 };
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue