feat(ux): reload config options at runtime (#3564)

* change simplified_ui at runtime

* change default_shell at runtime

* change pane_frames (from config) at runtime

* all other options

* some refactoring

* style(fmt): rustfmt
This commit is contained in:
Aram Drevekenin 2024-08-23 15:41:48 +02:00 committed by GitHub
parent 3923bf5027
commit 820ff85231
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 311 additions and 57 deletions

View file

@ -263,14 +263,33 @@ impl SessionMetaData {
} }
pub fn propagate_configuration_changes(&mut self, config_changes: Vec<(ClientId, Config)>) { pub fn propagate_configuration_changes(&mut self, config_changes: Vec<(ClientId, Config)>) {
for (client_id, new_config) in config_changes { for (client_id, new_config) in config_changes {
self.default_shell = new_config.options.default_shell.as_ref().map(|shell| {
TerminalAction::RunCommand(RunCommand {
command: shell.clone(),
cwd: new_config.options.default_cwd.clone(),
..Default::default()
})
});
self.senders self.senders
.send_to_screen(ScreenInstruction::Reconfigure { .send_to_screen(ScreenInstruction::Reconfigure {
client_id, client_id,
keybinds: Some(new_config.keybinds.clone()), keybinds: new_config.keybinds.clone(),
default_mode: new_config.options.default_mode, default_mode: new_config
.options
.default_mode
.unwrap_or_else(Default::default),
theme: new_config theme: new_config
.theme_config(new_config.options.theme.as_ref()) .theme_config(new_config.options.theme.as_ref())
.or_else(|| Some(default_palette())), .unwrap_or_else(|| default_palette()),
simplified_ui: new_config.options.simplified_ui.unwrap_or(false),
default_shell: new_config.options.default_shell,
pane_frames: new_config.options.pane_frames.unwrap_or(true),
copy_command: new_config.options.copy_command,
copy_to_clipboard: new_config.options.copy_clipboard,
copy_on_select: new_config.options.copy_on_select.unwrap_or(true),
auto_layout: new_config.options.auto_layout.unwrap_or(true),
rounded_corners: new_config.ui.pane_frames.rounded_corners,
hide_session_name: new_config.ui.pane_frames.hide_session_name,
}) })
.unwrap(); .unwrap();
self.senders self.senders
@ -278,6 +297,13 @@ impl SessionMetaData {
client_id, client_id,
keybinds: Some(new_config.keybinds), keybinds: Some(new_config.keybinds),
default_mode: new_config.options.default_mode, default_mode: new_config.options.default_mode,
default_shell: self.default_shell.clone(),
})
.unwrap();
self.senders
.send_to_pty(PtyInstruction::Reconfigure {
client_id,
default_editor: new_config.options.scrollback_editor,
}) })
.unwrap(); .unwrap();
} }

View file

@ -919,4 +919,15 @@ impl FloatingPanes {
pane.update_theme(theme); pane.update_theme(theme);
} }
} }
pub fn update_pane_arrow_fonts(&mut self, should_support_arrow_fonts: bool) {
for pane in self.panes.values_mut() {
pane.update_arrow_fonts(should_support_arrow_fonts);
}
}
pub fn update_pane_rounded_corners(&mut self, rounded_corners: bool) {
self.style.rounded_corners = rounded_corners;
for pane in self.panes.values_mut() {
pane.update_rounded_corners(rounded_corners);
}
}
} }

View file

@ -2158,6 +2158,9 @@ impl Grid {
pub fn update_theme(&mut self, theme: Palette) { pub fn update_theme(&mut self, theme: Palette) {
self.style.colors = theme.clone(); self.style.colors = theme.clone();
} }
pub fn update_arrow_fonts(&mut self, should_support_arrow_fonts: bool) {
self.arrow_fonts = should_support_arrow_fonts;
}
} }
impl Perform for Grid { impl Perform for Grid {

View file

@ -681,6 +681,17 @@ impl Pane for PluginPane {
grid.update_theme(theme.clone()); grid.update_theme(theme.clone());
} }
} }
fn update_arrow_fonts(&mut self, should_support_arrow_fonts: bool) {
self.arrow_fonts = should_support_arrow_fonts;
for grid in self.grids.values_mut() {
grid.update_arrow_fonts(should_support_arrow_fonts);
}
self.set_should_render(true);
}
fn update_rounded_corners(&mut self, rounded_corners: bool) {
self.style.rounded_corners = rounded_corners;
self.frame.clear();
}
} }
impl PluginPane { impl PluginPane {

View file

@ -798,6 +798,14 @@ impl Pane for TerminalPane {
self.render_first_run_banner(); self.render_first_run_banner();
} }
} }
fn update_arrow_fonts(&mut self, should_support_arrow_fonts: bool) {
self.arrow_fonts = should_support_arrow_fonts;
self.grid.update_arrow_fonts(should_support_arrow_fonts);
}
fn update_rounded_corners(&mut self, rounded_corners: bool) {
self.style.rounded_corners = rounded_corners;
self.frame.clear();
}
} }
impl TerminalPane { impl TerminalPane {

View file

@ -1772,6 +1772,17 @@ impl TiledPanes {
pane.update_theme(theme); pane.update_theme(theme);
} }
} }
pub fn update_pane_arrow_fonts(&mut self, should_support_arrow_fonts: bool) {
for pane in self.panes.values_mut() {
pane.update_arrow_fonts(should_support_arrow_fonts);
}
}
pub fn update_pane_rounded_corners(&mut self, rounded_corners: bool) {
self.style.rounded_corners = rounded_corners;
for pane in self.panes.values_mut() {
pane.update_rounded_corners(rounded_corners);
}
}
} }
#[allow(clippy::borrowed_box)] #[allow(clippy::borrowed_box)]

View file

@ -148,6 +148,7 @@ pub enum PluginInstruction {
client_id: ClientId, client_id: ClientId,
keybinds: Option<Keybinds>, keybinds: Option<Keybinds>,
default_mode: Option<InputMode>, default_mode: Option<InputMode>,
default_shell: Option<TerminalAction>,
}, },
FailedToWriteConfigToDisk { FailedToWriteConfigToDisk {
file_path: Option<PathBuf>, file_path: Option<PathBuf>,
@ -778,11 +779,12 @@ pub(crate) fn plugin_thread_main(
client_id, client_id,
keybinds, keybinds,
default_mode, default_mode,
default_shell,
} => { } => {
// TODO: notify plugins that this happened so that they can eg. rebind temporary keys that // TODO: notify plugins that this happened so that they can eg. rebind temporary keys that
// were lost // were lost
wasm_bridge wasm_bridge
.reconfigure(client_id, keybinds, default_mode) .reconfigure(client_id, keybinds, default_mode, default_shell)
.non_fatal(); .non_fatal();
}, },
PluginInstruction::FailedToWriteConfigToDisk { file_path } => { PluginInstruction::FailedToWriteConfigToDisk { file_path } => {

View file

@ -432,4 +432,7 @@ impl RunningPlugin {
pub fn update_default_mode(&mut self, default_mode: InputMode) { pub fn update_default_mode(&mut self, default_mode: InputMode) {
self.store.data_mut().default_mode = default_mode; self.store.data_mut().default_mode = default_mode;
} }
pub fn update_default_shell(&mut self, default_shell: Option<TerminalAction>) {
self.store.data_mut().default_shell = default_shell;
}
} }

View file

@ -826,6 +826,7 @@ impl WasmBridge {
client_id: ClientId, client_id: ClientId,
keybinds: Option<Keybinds>, keybinds: Option<Keybinds>,
default_mode: Option<InputMode>, default_mode: Option<InputMode>,
default_shell: Option<TerminalAction>,
) -> Result<()> { ) -> Result<()> {
let plugins_to_reconfigure: Vec<Arc<Mutex<RunningPlugin>>> = self let plugins_to_reconfigure: Vec<Arc<Mutex<RunningPlugin>>> = self
.plugin_map .plugin_map
@ -848,10 +849,12 @@ impl WasmBridge {
if let Some(keybinds) = keybinds.as_ref() { if let Some(keybinds) = keybinds.as_ref() {
self.keybinds.insert(client_id, keybinds.clone()); self.keybinds.insert(client_id, keybinds.clone());
} }
self.default_shell = default_shell.clone();
for running_plugin in plugins_to_reconfigure { for running_plugin in plugins_to_reconfigure {
task::spawn({ task::spawn({
let running_plugin = running_plugin.clone(); let running_plugin = running_plugin.clone();
let keybinds = keybinds.clone(); let keybinds = keybinds.clone();
let default_shell = default_shell.clone();
async move { async move {
let mut running_plugin = running_plugin.lock().unwrap(); let mut running_plugin = running_plugin.lock().unwrap();
if let Some(keybinds) = keybinds { if let Some(keybinds) = keybinds {
@ -860,6 +863,7 @@ impl WasmBridge {
if let Some(default_mode) = default_mode { if let Some(default_mode) = default_mode {
running_plugin.update_default_mode(default_mode); running_plugin.update_default_mode(default_mode);
} }
running_plugin.update_default_shell(default_shell);
} }
}); });
} }

View file

@ -100,6 +100,10 @@ pub enum PtyInstruction {
Option<FloatingPaneCoordinates>, Option<FloatingPaneCoordinates>,
), ),
ListClientsMetadata(SessionLayoutMetadata, ClientId), ListClientsMetadata(SessionLayoutMetadata, ClientId),
Reconfigure {
client_id: ClientId,
default_editor: Option<PathBuf>,
},
Exit, Exit,
} }
@ -123,6 +127,7 @@ impl From<&PtyInstruction> for PtyContext {
PtyInstruction::LogLayoutToHd(..) => PtyContext::LogLayoutToHd, PtyInstruction::LogLayoutToHd(..) => PtyContext::LogLayoutToHd,
PtyInstruction::FillPluginCwd(..) => PtyContext::FillPluginCwd, PtyInstruction::FillPluginCwd(..) => PtyContext::FillPluginCwd,
PtyInstruction::ListClientsMetadata(..) => PtyContext::ListClientsMetadata, PtyInstruction::ListClientsMetadata(..) => PtyContext::ListClientsMetadata,
PtyInstruction::Reconfigure { .. } => PtyContext::Reconfigure,
PtyInstruction::Exit => PtyContext::Exit, PtyInstruction::Exit => PtyContext::Exit,
} }
} }
@ -765,6 +770,12 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> {
floating_pane_coordinates, floating_pane_coordinates,
)?; )?;
}, },
PtyInstruction::Reconfigure {
default_editor,
client_id,
} => {
pty.reconfigure(default_editor);
},
PtyInstruction::Exit => break, PtyInstruction::Exit => break,
} }
} }
@ -1545,6 +1556,9 @@ impl Pty {
))?; ))?;
Ok(()) Ok(())
} }
pub fn reconfigure(&mut self, default_editor: Option<PathBuf>) {
self.default_editor = default_editor;
}
} }
impl Drop for Pty { impl Drop for Pty {

View file

@ -54,7 +54,7 @@ use zellij_utils::{
PluginCapabilities, Style, TabInfo, PluginCapabilities, Style, TabInfo,
}, },
errors::{ContextType, ScreenContext}, errors::{ContextType, ScreenContext},
input::{get_mode_info, options::Options}, input::get_mode_info,
ipc::{ClientAttributes, PixelDimensions, ServerToClientMsg}, ipc::{ClientAttributes, PixelDimensions, ServerToClientMsg},
}; };
@ -366,9 +366,18 @@ pub enum ScreenInstruction {
ListClientsMetadata(Option<PathBuf>, ClientId), // Option<PathBuf> - default shell ListClientsMetadata(Option<PathBuf>, ClientId), // Option<PathBuf> - default shell
Reconfigure { Reconfigure {
client_id: ClientId, client_id: ClientId,
keybinds: Option<Keybinds>, keybinds: Keybinds,
default_mode: Option<InputMode>, default_mode: InputMode,
theme: Option<Palette>, theme: Palette,
simplified_ui: bool,
default_shell: Option<PathBuf>,
pane_frames: bool,
copy_command: Option<String>,
copy_to_clipboard: Option<Clipboard>,
copy_on_select: bool,
auto_layout: bool,
rounded_corners: bool,
hide_session_name: bool,
}, },
RerunCommandPane(u32), // u32 - terminal pane id RerunCommandPane(u32), // u32 - terminal pane id
} }
@ -1743,6 +1752,7 @@ impl Screen {
.unwrap_or(&self.default_mode_info); .unwrap_or(&self.default_mode_info);
let previous_mode = previous_mode_info.mode; let previous_mode = previous_mode_info.mode;
mode_info.style = previous_mode_info.style; mode_info.style = previous_mode_info.style;
mode_info.capabilities = previous_mode_info.capabilities;
let err_context = || { let err_context = || {
format!( format!(
@ -2182,22 +2192,48 @@ impl Screen {
} }
Ok(()) Ok(())
} }
pub fn reconfigure_mode_info( pub fn reconfigure(
&mut self, &mut self,
new_keybinds: Option<Keybinds>, new_keybinds: Keybinds,
new_default_mode: Option<InputMode>, new_default_mode: InputMode,
theme: Option<Palette>, theme: Palette,
simplified_ui: bool,
default_shell: Option<PathBuf>,
pane_frames: bool,
copy_command: Option<String>,
copy_to_clipboard: Option<Clipboard>,
copy_on_select: bool,
auto_layout: bool,
rounded_corners: bool,
hide_session_name: bool,
client_id: ClientId, client_id: ClientId,
) -> Result<()> { ) -> Result<()> {
let should_update_mode_info = let should_support_arrow_fonts = !simplified_ui;
new_keybinds.is_some() || new_default_mode.is_some() || theme.is_some();
// themes are currently global and not per-client // global configuration
if let Some(theme) = theme {
self.default_mode_info.update_theme(theme); self.default_mode_info.update_theme(theme);
self.default_mode_info
.update_rounded_corners(rounded_corners);
self.default_shell = default_shell.clone();
self.auto_layout = auto_layout;
self.copy_options.command = copy_command.clone();
self.copy_options.copy_on_select = copy_on_select;
self.draw_pane_frames = pane_frames;
self.default_mode_info
.update_arrow_fonts(should_support_arrow_fonts);
self.default_mode_info
.update_hide_session_name(hide_session_name);
if let Some(copy_to_clipboard) = copy_to_clipboard {
self.copy_options.clipboard = copy_to_clipboard;
}
for tab in self.tabs.values_mut() { for tab in self.tabs.values_mut() {
tab.update_theme(theme); tab.update_theme(theme);
} tab.update_rounded_corners(rounded_corners);
tab.update_default_shell(default_shell.clone());
tab.update_auto_layout(auto_layout);
tab.update_copy_options(&self.copy_options);
tab.set_pane_frames(pane_frames);
tab.update_arrow_fonts(should_support_arrow_fonts);
} }
// client specific configuration // client specific configuration
@ -2206,28 +2242,22 @@ impl Screen {
.mode_info .mode_info
.entry(client_id) .entry(client_id)
.or_insert_with(|| self.default_mode_info.clone()); .or_insert_with(|| self.default_mode_info.clone());
if let Some(new_keybinds) = new_keybinds {
mode_info.update_keybinds(new_keybinds); mode_info.update_keybinds(new_keybinds);
}
if let Some(new_default_mode) = new_default_mode {
mode_info.update_default_mode(new_default_mode); mode_info.update_default_mode(new_default_mode);
}
if let Some(theme) = theme {
mode_info.update_theme(theme); mode_info.update_theme(theme);
} mode_info.update_arrow_fonts(should_support_arrow_fonts);
if should_update_mode_info { mode_info.update_hide_session_name(hide_session_name);
for tab in self.tabs.values_mut() { for tab in self.tabs.values_mut() {
tab.change_mode_info(mode_info.clone(), client_id); tab.change_mode_info(mode_info.clone(), client_id);
tab.mark_active_pane_for_rerender(client_id); tab.mark_active_pane_for_rerender(client_id);
} }
} }
}
if should_update_mode_info { // this needs to be done separately at the end because it applies some of the above changes
// and propagates them to plugins
for tab in self.tabs.values_mut() { for tab in self.tabs.values_mut() {
tab.update_input_modes()?; tab.update_input_modes()?;
} }
}
Ok(()) Ok(())
} }
fn unblock_input(&self) -> Result<()> { fn unblock_input(&self) -> Result<()> {
@ -4104,9 +4134,32 @@ pub(crate) fn screen_thread_main(
keybinds, keybinds,
default_mode, default_mode,
theme, theme,
simplified_ui,
default_shell,
pane_frames,
copy_to_clipboard,
copy_command,
copy_on_select,
auto_layout,
rounded_corners,
hide_session_name,
} => { } => {
screen screen
.reconfigure_mode_info(keybinds, default_mode, theme, client_id) .reconfigure(
keybinds,
default_mode,
theme,
simplified_ui,
default_shell,
pane_frames,
copy_command,
copy_to_clipboard,
copy_on_select,
auto_layout,
rounded_corners,
hide_session_name,
client_id,
)
.non_fatal(); .non_fatal();
}, },
ScreenInstruction::RerunCommandPane(terminal_pane_id) => { ScreenInstruction::RerunCommandPane(terminal_pane_id) => {

View file

@ -493,6 +493,8 @@ pub trait Pane {
None None
} // only relevant to terminal panes } // only relevant to terminal panes
fn update_theme(&mut self, _theme: Palette) {} fn update_theme(&mut self, _theme: Palette) {}
fn update_arrow_fonts(&mut self, _should_support_arrow_fonts: bool) {}
fn update_rounded_corners(&mut self, _rounded_corners: bool) {}
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -3960,6 +3962,39 @@ impl Tab {
pane.update_theme(theme); pane.update_theme(theme);
} }
} }
pub fn update_rounded_corners(&mut self, rounded_corners: bool) {
self.style.rounded_corners = rounded_corners;
self.floating_panes
.update_pane_rounded_corners(rounded_corners);
self.tiled_panes
.update_pane_rounded_corners(rounded_corners);
for (_, pane) in self.suppressed_panes.values_mut() {
pane.update_rounded_corners(rounded_corners);
}
}
pub fn update_arrow_fonts(&mut self, should_support_arrow_fonts: bool) {
self.arrow_fonts = should_support_arrow_fonts;
self.floating_panes
.update_pane_arrow_fonts(should_support_arrow_fonts);
self.tiled_panes
.update_pane_arrow_fonts(should_support_arrow_fonts);
for (_, pane) in self.suppressed_panes.values_mut() {
pane.update_arrow_fonts(should_support_arrow_fonts);
}
}
pub fn update_default_shell(&mut self, default_shell: Option<PathBuf>) {
self.default_shell = default_shell;
}
pub fn update_copy_options(&mut self, copy_options: &CopyOptions) {
self.clipboard_provider = match &copy_options.command {
Some(command) => ClipboardProvider::Command(CopyCommand::new(command.clone())),
None => ClipboardProvider::Osc52(copy_options.clipboard),
};
self.copy_on_select = copy_options.copy_on_select;
}
pub fn update_auto_layout(&mut self, auto_layout: bool) {
self.auto_layout = auto_layout;
}
} }
pub fn pane_info_for_pane(pane_id: &PaneId, pane: &Box<dyn Pane>) -> PaneInfo { pub fn pane_info_for_pane(pane_id: &PaneId, pane: &Box<dyn Pane>) -> PaneInfo {

View file

@ -193,6 +193,8 @@ keybinds {
} }
} }
// Plugin aliases - can be used to change the implementation of Zellij
// changing these requires a restart to take effect
plugins { plugins {
tab-bar location="zellij:tab-bar" tab-bar location="zellij:tab-bar"
status-bar location="zellij:status-bar" status-bar location="zellij:status-bar"
@ -210,6 +212,7 @@ plugins {
// Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP // Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP
// eg. when terminal window with an active zellij session is closed // eg. when terminal window with an active zellij session is closed
// (Requires restart)
// Options: // Options:
// - detach (Default) // - detach (Default)
// - quit // - quit
@ -247,6 +250,7 @@ plugins {
// auto_layout true // auto_layout true
// Whether sessions should be serialized to the cache folder (including their tabs/panes, cwds and running commands) so that they can later be resurrected // Whether sessions should be serialized to the cache folder (including their tabs/panes, cwds and running commands) so that they can later be resurrected
// (Requires restart)
// Options: // Options:
// - true (default) // - true (default)
// - false // - false
@ -254,14 +258,17 @@ plugins {
// session_serialization false // session_serialization false
// Whether pane viewports are serialized along with the session, default is false // Whether pane viewports are serialized along with the session, default is false
// (Requires restart)
// Options: // Options:
// - true // - true
// - false (default) // - false (default)
//
// serialize_pane_viewport true // serialize_pane_viewport true
// Scrollback lines to serialize along with the pane viewport when serializing sessions, 0 // Scrollback lines to serialize along with the pane viewport when serializing sessions, 0
// defaults to the scrollback size. If this number is higher than the scrollback size, it will // defaults to the scrollback size. If this number is higher than the scrollback size, it will
// also default to the scrollback size. This does nothing if `serialize_pane_viewport` is not true. // also default to the scrollback size. This does nothing if `serialize_pane_viewport` is not true.
// (Requires restart)
// //
// scrollback_lines_to_serialize 10000 // scrollback_lines_to_serialize 10000
@ -292,6 +299,7 @@ plugins {
// The name of the default layout to load on startup // The name of the default layout to load on startup
// Default: "default" // Default: "default"
// (Requires restart)
// //
// default_layout "compact" // default_layout "compact"
@ -303,6 +311,7 @@ plugins {
// Toggle enabling the mouse mode. // Toggle enabling the mouse mode.
// On certain configurations, or terminals this could // On certain configurations, or terminals this could
// potentially interfere with copying text. // potentially interfere with copying text.
// (Requires restart)
// Options: // Options:
// - true (default) // - true (default)
// - false // - false
@ -312,6 +321,7 @@ plugins {
// Configure the scroll back buffer size // Configure the scroll back buffer size
// This is the number of lines zellij stores for each pane in the scroll back // This is the number of lines zellij stores for each pane in the scroll back
// buffer. Excess number of lines are discarded in a FIFO fashion. // buffer. Excess number of lines are discarded in a FIFO fashion.
// (Requires restart)
// Valid values: positive integers // Valid values: positive integers
// Default value: 10000 // Default value: 10000
// //
@ -349,31 +359,37 @@ plugins {
// When attaching to an existing session with other users, // When attaching to an existing session with other users,
// should the session be mirrored (true) // should the session be mirrored (true)
// or should each user have their own cursor (false) // or should each user have their own cursor (false)
// (Requires restart)
// Default: false // Default: false
// //
// mirror_session true // mirror_session true
// The folder in which Zellij will look for layouts // The folder in which Zellij will look for layouts
// (Requires restart)
// //
// layout_dir "/path/to/my/layout_dir" // layout_dir "/path/to/my/layout_dir"
// The folder in which Zellij will look for themes // The folder in which Zellij will look for themes
// (Requires restart)
// //
// theme_dir "/path/to/my/theme_dir" // theme_dir "/path/to/my/theme_dir"
// Enable or disable the rendering of styled and colored underlines (undercurl). // Enable or disable the rendering of styled and colored underlines (undercurl).
// May need to be disabled for certain unsupported terminals // May need to be disabled for certain unsupported terminals
// (Requires restart)
// Default: true // Default: true
// //
// styled_underlines false // styled_underlines false
// Enable or disable writing of session metadata to disk (if disabled, other sessions might not know // Enable or disable writing of session metadata to disk (if disabled, other sessions might not know
// metadata info on this session) // metadata info on this session)
// (Requires restart)
// Default: false // Default: false
// //
// disable_session_metadata true // disable_session_metadata true
// Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it) // Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it)
// (Requires restart)
// Default: true (if the host terminal supports it) // Default: true (if the host terminal supports it)
// //
// support_kitty_keyboard_protocol false // support_kitty_keyboard_protocol false

View file

@ -1178,6 +1178,17 @@ impl ModeInfo {
pub fn update_theme(&mut self, theme: Palette) { pub fn update_theme(&mut self, theme: Palette) {
self.style.colors = theme; self.style.colors = theme;
} }
pub fn update_rounded_corners(&mut self, rounded_corners: bool) {
self.style.rounded_corners = rounded_corners;
}
pub fn update_arrow_fonts(&mut self, should_support_arrow_fonts: bool) {
// it is honestly quite baffling to me how "arrow_fonts: false" can mean "I support arrow
// fonts", but since this is a public API... ¯\_(ツ)_/¯
self.capabilities.arrow_fonts = !should_support_arrow_fonts;
}
pub fn update_hide_session_name(&mut self, hide_session_name: bool) {
self.style.hide_session_name = hide_session_name;
}
} }
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)] #[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)]

View file

@ -377,6 +377,7 @@ pub enum PtyContext {
FillPluginCwd, FillPluginCwd,
DumpLayoutToPlugin, DumpLayoutToPlugin,
ListClientsMetadata, ListClientsMetadata,
Reconfigure,
Exit, Exit,
} }

View file

@ -2427,8 +2427,11 @@ impl Options {
} }
fn layout_dir_to_kdl(&self, add_comments: bool) -> Option<KdlNode> { fn layout_dir_to_kdl(&self, add_comments: bool) -> Option<KdlNode> {
let comment_text = format!( let comment_text = format!(
"{}\n{}\n{}", "{}\n{}\n{}\n{}",
" ", "// The folder in which Zellij will look for layouts", "// ", " ",
"// The folder in which Zellij will look for layouts",
"// (Requires restart)",
"// ",
); );
let create_node = |node_value: &str| -> KdlNode { let create_node = |node_value: &str| -> KdlNode {
@ -2452,8 +2455,11 @@ impl Options {
} }
fn theme_dir_to_kdl(&self, add_comments: bool) -> Option<KdlNode> { fn theme_dir_to_kdl(&self, add_comments: bool) -> Option<KdlNode> {
let comment_text = format!( let comment_text = format!(
"{}\n{}\n{}", "{}\n{}\n{}\n{}",
" ", "// The folder in which Zellij will look for themes", "// ", " ",
"// The folder in which Zellij will look for themes",
"// (Requires restart)",
"// ",
); );
let create_node = |node_value: &str| -> KdlNode { let create_node = |node_value: &str| -> KdlNode {
@ -2539,11 +2545,12 @@ impl Options {
} }
fn mirror_session_to_kdl(&self, add_comments: bool) -> Option<KdlNode> { fn mirror_session_to_kdl(&self, add_comments: bool) -> Option<KdlNode> {
let comment_text = format!( let comment_text = format!(
"{}\n{}\n{}\n{}\n{}\n{}", "{}\n{}\n{}\n{}\n{}\n{}\n{}",
" ", " ",
"// When attaching to an existing session with other users,", "// When attaching to an existing session with other users,",
"// should the session be mirrored (true)", "// should the session be mirrored (true)",
"// or should each user have their own cursor (false)", "// or should each user have their own cursor (false)",
"// (Requires restart)",
"// Default: false", "// Default: false",
"// ", "// ",
); );
@ -2569,10 +2576,11 @@ impl Options {
} }
fn on_force_close_to_kdl(&self, add_comments: bool) -> Option<KdlNode> { fn on_force_close_to_kdl(&self, add_comments: bool) -> Option<KdlNode> {
let comment_text = format!( let comment_text = format!(
"{}\n{}\n{}\n{}\n{}\n{}\n{}", "{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
" ", " ",
"// Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP", "// Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP",
"// eg. when terminal window with an active zellij session is closed", "// eg. when terminal window with an active zellij session is closed",
"// (Requires restart)",
"// Options:", "// Options:",
"// - detach (Default)", "// - detach (Default)",
"// - quit", "// - quit",
@ -2603,11 +2611,12 @@ impl Options {
} }
fn scroll_buffer_size_to_kdl(&self, add_comments: bool) -> Option<KdlNode> { fn scroll_buffer_size_to_kdl(&self, add_comments: bool) -> Option<KdlNode> {
let comment_text = format!( let comment_text = format!(
"{}\n{}\n{}\n{}\n{}\n{}\n{}", "{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
" ", " ",
"// Configure the scroll back buffer size", "// Configure the scroll back buffer size",
"// This is the number of lines zellij stores for each pane in the scroll back", "// This is the number of lines zellij stores for each pane in the scroll back",
"// buffer. Excess number of lines are discarded in a FIFO fashion.", "// buffer. Excess number of lines are discarded in a FIFO fashion.",
"// (Requires restart)",
"// Valid values: positive integers", "// Valid values: positive integers",
"// Default value: 10000", "// Default value: 10000",
"// ", "// ",
@ -2933,10 +2942,11 @@ impl Options {
} }
fn styled_underlines_to_kdl(&self, add_comments: bool) -> Option<KdlNode> { fn styled_underlines_to_kdl(&self, add_comments: bool) -> Option<KdlNode> {
let comment_text = format!( let comment_text = format!(
"{}\n{}\n{}\n{}\n{}", "{}\n{}\n{}\n{}\n{}\n{}",
" ", " ",
"// Enable or disable the rendering of styled and colored underlines (undercurl).", "// Enable or disable the rendering of styled and colored underlines (undercurl).",
"// May need to be disabled for certain unsupported terminals", "// May need to be disabled for certain unsupported terminals",
"// (Requires restart)",
"// Default: true", "// Default: true",
"// ", "// ",
); );
@ -2986,10 +2996,11 @@ impl Options {
} }
} }
fn disable_session_metadata_to_kdl(&self, add_comments: bool) -> Option<KdlNode> { fn disable_session_metadata_to_kdl(&self, add_comments: bool) -> Option<KdlNode> {
let comment_text = format!("{}\n{}\n{}\n{}\n{}", let comment_text = format!("{}\n{}\n{}\n{}\n{}\n{}",
" ", " ",
"// Enable or disable writing of session metadata to disk (if disabled, other sessions might not know", "// Enable or disable writing of session metadata to disk (if disabled, other sessions might not know",
"// metadata info on this session)", "// metadata info on this session)",
"// (Requires restart)",
"// Default: false", "// Default: false",
"// ", "// ",
); );
@ -3014,9 +3025,10 @@ impl Options {
} }
} }
fn support_kitty_keyboard_protocol_to_kdl(&self, add_comments: bool) -> Option<KdlNode> { fn support_kitty_keyboard_protocol_to_kdl(&self, add_comments: bool) -> Option<KdlNode> {
let comment_text = format!("{}\n{}\n{}\n{}", let comment_text = format!("{}\n{}\n{}\n{}\n{}",
" ", " ",
"// Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it)", "// Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it)",
"// (Requires restart)",
"// Default: true (if the host terminal supports it)", "// Default: true (if the host terminal supports it)",
"// ", "// ",
); );
@ -3625,7 +3637,7 @@ impl Config {
document.nodes_mut().push(themes); document.nodes_mut().push(themes);
} }
let plugins = self.plugins.to_kdl(); let plugins = self.plugins.to_kdl(add_comments);
document.nodes_mut().push(plugins); document.nodes_mut().push(plugins);
if let Some(ui_config) = self.ui.to_kdl() { if let Some(ui_config) = self.ui.to_kdl() {
@ -3667,7 +3679,7 @@ impl PluginAliases {
} }
Ok(PluginAliases { aliases }) Ok(PluginAliases { aliases })
} }
pub fn to_kdl(&self) -> KdlNode { pub fn to_kdl(&self, add_comments: bool) -> KdlNode {
let mut plugins = KdlNode::new("plugins"); let mut plugins = KdlNode::new("plugins");
let mut plugins_children = KdlDocument::new(); let mut plugins_children = KdlDocument::new();
for (alias_name, plugin_alias) in self.aliases.iter() { for (alias_name, plugin_alias) in self.aliases.iter() {
@ -3705,6 +3717,14 @@ impl PluginAliases {
plugins_children.nodes_mut().push(plugin_alias_node); plugins_children.nodes_mut().push(plugin_alias_node);
} }
plugins.set_children(plugins_children); plugins.set_children(plugins_children);
if add_comments {
plugins.set_leading(format!(
"\n{}\n{}\n",
"// Plugin aliases - can be used to change the implementation of Zellij",
"// changing these requires a restart to take effect",
));
}
plugins plugins
} }
} }
@ -5147,7 +5167,7 @@ fn plugins_to_string() {
}"##; }"##;
let document: KdlDocument = fake_config.parse().unwrap(); let document: KdlDocument = fake_config.parse().unwrap();
let deserialized = PluginAliases::from_kdl(document.get("plugins").unwrap()).unwrap(); let deserialized = PluginAliases::from_kdl(document.get("plugins").unwrap()).unwrap();
let serialized = PluginAliases::to_kdl(&deserialized); let serialized = PluginAliases::to_kdl(&deserialized, true);
let deserialized_from_serialized = PluginAliases::from_kdl( let deserialized_from_serialized = PluginAliases::from_kdl(
serialized serialized
.to_string() .to_string()
@ -5175,7 +5195,7 @@ fn plugins_to_string_with_file_and_web() {
}"##; }"##;
let document: KdlDocument = fake_config.parse().unwrap(); let document: KdlDocument = fake_config.parse().unwrap();
let deserialized = PluginAliases::from_kdl(document.get("plugins").unwrap()).unwrap(); let deserialized = PluginAliases::from_kdl(document.get("plugins").unwrap()).unwrap();
let serialized = PluginAliases::to_kdl(&deserialized); let serialized = PluginAliases::to_kdl(&deserialized, true);
let deserialized_from_serialized = PluginAliases::from_kdl( let deserialized_from_serialized = PluginAliases::from_kdl(
serialized serialized
.to_string() .to_string()

View file

@ -1,6 +1,6 @@
--- ---
source: zellij-utils/src/kdl/mod.rs source: zellij-utils/src/kdl/mod.rs
assertion_line: 5069 assertion_line: 5441
expression: fake_config_stringified expression: fake_config_stringified
--- ---
keybinds clear-defaults=true { keybinds clear-defaults=true {
@ -223,6 +223,9 @@ keybinds clear-defaults=true {
bind "z" { ToggleFocusFullscreen; SwitchToMode "normal"; } bind "z" { ToggleFocusFullscreen; SwitchToMode "normal"; }
} }
} }
// Plugin aliases - can be used to change the implementation of Zellij
// changing these requires a restart to take effect
plugins { plugins {
compact-bar location="zellij:compact-bar" compact-bar location="zellij:compact-bar"
configuration location="zellij:configuration" configuration location="zellij:configuration"
@ -270,10 +273,12 @@ plugins {
// default_layout "compact" // default_layout "compact"
// The folder in which Zellij will look for layouts // The folder in which Zellij will look for layouts
// (Requires restart)
// //
// layout_dir "/tmp" // layout_dir "/tmp"
// The folder in which Zellij will look for themes // The folder in which Zellij will look for themes
// (Requires restart)
// //
// theme_dir "/tmp" // theme_dir "/tmp"
@ -296,12 +301,14 @@ plugins {
// When attaching to an existing session with other users, // When attaching to an existing session with other users,
// should the session be mirrored (true) // should the session be mirrored (true)
// or should each user have their own cursor (false) // or should each user have their own cursor (false)
// (Requires restart)
// Default: false // Default: false
// //
// mirror_session true // mirror_session true
// Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP // Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP
// eg. when terminal window with an active zellij session is closed // eg. when terminal window with an active zellij session is closed
// (Requires restart)
// Options: // Options:
// - detach (Default) // - detach (Default)
// - quit // - quit
@ -311,6 +318,7 @@ plugins {
// Configure the scroll back buffer size // Configure the scroll back buffer size
// This is the number of lines zellij stores for each pane in the scroll back // This is the number of lines zellij stores for each pane in the scroll back
// buffer. Excess number of lines are discarded in a FIFO fashion. // buffer. Excess number of lines are discarded in a FIFO fashion.
// (Requires restart)
// Valid values: positive integers // Valid values: positive integers
// Default value: 10000 // Default value: 10000
// //
@ -388,6 +396,7 @@ plugins {
// Enable or disable the rendering of styled and colored underlines (undercurl). // Enable or disable the rendering of styled and colored underlines (undercurl).
// May need to be disabled for certain unsupported terminals // May need to be disabled for certain unsupported terminals
// (Requires restart)
// Default: true // Default: true
// //
// styled_underlines false // styled_underlines false
@ -398,11 +407,13 @@ plugins {
// Enable or disable writing of session metadata to disk (if disabled, other sessions might not know // Enable or disable writing of session metadata to disk (if disabled, other sessions might not know
// metadata info on this session) // metadata info on this session)
// (Requires restart)
// Default: false // Default: false
// //
// disable_session_metadata false // disable_session_metadata false
// Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it) // Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it)
// (Requires restart)
// Default: true (if the host terminal supports it) // Default: true (if the host terminal supports it)
// //
// support_kitty_keyboard_protocol false // support_kitty_keyboard_protocol false

View file

@ -1,6 +1,6 @@
--- ---
source: zellij-utils/src/kdl/mod.rs source: zellij-utils/src/kdl/mod.rs
assertion_line: 4987 assertion_line: 5380
expression: fake_document.to_string() expression: fake_document.to_string()
--- ---
@ -36,10 +36,12 @@ default_cwd "/tmp/foo"
default_layout "compact" default_layout "compact"
// The folder in which Zellij will look for layouts // The folder in which Zellij will look for layouts
// (Requires restart)
// //
layout_dir "/tmp/layouts" layout_dir "/tmp/layouts"
// The folder in which Zellij will look for themes // The folder in which Zellij will look for themes
// (Requires restart)
// //
theme_dir "/tmp/themes" theme_dir "/tmp/themes"
@ -62,12 +64,14 @@ pane_frames false
// When attaching to an existing session with other users, // When attaching to an existing session with other users,
// should the session be mirrored (true) // should the session be mirrored (true)
// or should each user have their own cursor (false) // or should each user have their own cursor (false)
// (Requires restart)
// Default: false // Default: false
// //
mirror_session true mirror_session true
// Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP // Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP
// eg. when terminal window with an active zellij session is closed // eg. when terminal window with an active zellij session is closed
// (Requires restart)
// Options: // Options:
// - detach (Default) // - detach (Default)
// - quit // - quit
@ -77,6 +81,7 @@ on_force_close "quit"
// Configure the scroll back buffer size // Configure the scroll back buffer size
// This is the number of lines zellij stores for each pane in the scroll back // This is the number of lines zellij stores for each pane in the scroll back
// buffer. Excess number of lines are discarded in a FIFO fashion. // buffer. Excess number of lines are discarded in a FIFO fashion.
// (Requires restart)
// Valid values: positive integers // Valid values: positive integers
// Default value: 10000 // Default value: 10000
// //
@ -154,6 +159,7 @@ scrollback_lines_to_serialize 1000
// Enable or disable the rendering of styled and colored underlines (undercurl). // Enable or disable the rendering of styled and colored underlines (undercurl).
// May need to be disabled for certain unsupported terminals // May need to be disabled for certain unsupported terminals
// (Requires restart)
// Default: true // Default: true
// //
styled_underlines false styled_underlines false
@ -164,11 +170,13 @@ serialization_interval 1
// Enable or disable writing of session metadata to disk (if disabled, other sessions might not know // Enable or disable writing of session metadata to disk (if disabled, other sessions might not know
// metadata info on this session) // metadata info on this session)
// (Requires restart)
// Default: false // Default: false
// //
disable_session_metadata true disable_session_metadata true
// Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it) // Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it)
// (Requires restart)
// Default: true (if the host terminal supports it) // Default: true (if the host terminal supports it)
// //
support_kitty_keyboard_protocol false support_kitty_keyboard_protocol false

View file

@ -1,8 +1,11 @@
--- ---
source: zellij-utils/src/kdl/mod.rs source: zellij-utils/src/kdl/mod.rs
assertion_line: 3874 assertion_line: 5184
expression: serialized.to_string() expression: serialized.to_string()
--- ---
// Plugin aliases - can be used to change the implementation of Zellij
// changing these requires a restart to take effect
plugins { plugins {
compact-bar location="zellij:compact-bar" compact-bar location="zellij:compact-bar"
filepicker location="zellij:strider" { filepicker location="zellij:strider" {

View file

@ -1,8 +1,11 @@
--- ---
source: zellij-utils/src/kdl/mod.rs source: zellij-utils/src/kdl/mod.rs
assertion_line: 3891 assertion_line: 5212
expression: serialized.to_string() expression: serialized.to_string()
--- ---
// Plugin aliases - can be used to change the implementation of Zellij
// changing these requires a restart to take effect
plugins { plugins {
filepicker location="file:/path/to/my/plugin.wasm" { filepicker location="file:/path/to/my/plugin.wasm" {
cwd "/" cwd "/"