Files
LLeMbas-TTY/term/src/config.rs
T
Wez Furlong aac93e7f0a Improve palette handling w/ live config reloading
@fanzeyi ran into part of this issue when using multiplexing;
tabs from a remote domain always used the default color scheme
rather than the local configuration file color scheme.

Another variation on this is that making changes to the `[colors]`
section of the config only impacts tabs created after the change
was loaded, rather than updating the running tabs.

The root of this was that each terminal was keeping its own
copy of the palette that was updated at creation time to reflect
the config file.  Relatively recently I introduced a new trait
to allow the terminal state to reach out and obtain configuration
from another source.

This commit connects the terminal configuration layer to the
configuration file directly.

The color schemes are now pulled directly from the configuration
file, except in the case where a dynamic color scheme has been
applied: using escape sequences to change the colors causes
the palette to be forked away from the configuration file.

There's still a low pri TODO around this space: if we're connected
to a remote domain and someone uses dynamic color scheme escapes,
should we reflect those locally?  If so then we'll need to build
some plumbing to transport the palette to/from the remote system.

Closes: https://github.com/wez/wezterm/pull/60
2019-12-23 14:19:48 -08:00

42 lines
1.2 KiB
Rust

use crate::color::ColorPalette;
use termwiz::hyperlink::Rule as HyperlinkRule;
pub trait TerminalConfiguration: std::fmt::Debug {
/// Returns a generation counter for the active
/// configuration. If the implementation may be
/// changed at runtime, it must increment the generation
/// number with each change so that any caches maintained
/// by the terminal can be flushed.
fn generation(&self) -> usize {
0
}
fn scrollback_size(&self) -> usize {
3500
}
// TODO: expose is_double_click_word in config file
fn is_double_click_word(&self, s: &str) -> bool {
match s.len() {
1 => match s.chars().nth(0).unwrap() {
' ' | '\t' | '\n' | '{' | '[' | '}' | ']' | '(' | ')' | '"' | '\'' => false,
_ => true,
},
0 => false,
_ => true,
}
}
// TODO: expose scroll_to_bottom_on_key_input in config file
fn scroll_to_bottom_on_key_input(&self) -> bool {
true
}
/// Returns the current generation and its associated hyperlink rules.
fn hyperlink_rules(&self) -> (usize, Vec<HyperlinkRule>) {
(self.generation(), vec![])
}
fn color_palette(&self) -> ColorPalette;
}