From 8de59477719241c376336653a8dfa009eb438f3f Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Wed, 9 Oct 2024 10:44:43 +0200 Subject: [PATCH] fix(ui): various pane name fixes (#3653) --- default-plugins/configuration/src/main.rs | 24 +++-------------- default-plugins/plugin-manager/src/main.rs | 8 ++---- zellij-server/src/tab/mod.rs | 31 +++++++++------------- 3 files changed, 19 insertions(+), 44 deletions(-) diff --git a/default-plugins/configuration/src/main.rs b/default-plugins/configuration/src/main.rs index dee18b5f..a01d74c2 100644 --- a/default-plugins/configuration/src/main.rs +++ b/default-plugins/configuration/src/main.rs @@ -64,38 +64,22 @@ impl ZellijPlugin for State { .map(|v| v == "true") .unwrap_or(false); self.userspace_configuration = configuration; - // we need the ReadApplicationState permission to receive the ModeUpdate and TabUpdate - // events - // we need the RunCommands permission to run "cargo test" in a floating window - request_permission(&[ - PermissionType::ReadApplicationState, - PermissionType::RunCommands, - PermissionType::ReadCliPipes, - PermissionType::MessageAndLaunchOtherPlugins, - PermissionType::Reconfigure, - PermissionType::ChangeApplicationState, - ]); - subscribe(&[ - EventType::PermissionRequestResult, - EventType::Key, - EventType::FailedToWriteConfigToDisk, - ]); + subscribe(&[EventType::Key, EventType::FailedToWriteConfigToDisk]); + let own_plugin_id = get_plugin_ids().plugin_id; if self.is_setup_wizard { self.ui_size = 18; self.selected_index = Some(0); - let own_plugin_id = get_plugin_ids().plugin_id; rename_plugin_pane(own_plugin_id, "First Run Setup Wizard (Step 1/1)"); resize_focused_pane(Resize::Increase); resize_focused_pane(Resize::Increase); resize_focused_pane(Resize::Increase); + } else { + rename_plugin_pane(own_plugin_id, "Configuration"); } } fn update(&mut self, event: Event) -> bool { let mut should_render = false; match event { - Event::PermissionRequestResult(_) => { - should_render = true; - }, Event::Key(key) => { if self.remapping_leaders { should_render = self.handle_remapping_screen_key(key); diff --git a/default-plugins/plugin-manager/src/main.rs b/default-plugins/plugin-manager/src/main.rs index bc451d8a..7cd5e5c4 100644 --- a/default-plugins/plugin-manager/src/main.rs +++ b/default-plugins/plugin-manager/src/main.rs @@ -486,8 +486,9 @@ impl ZellijPlugin for State { EventType::TabUpdate, EventType::Key, EventType::SessionUpdate, - EventType::PermissionRequestResult, ]); + let own_plugin_id = get_plugin_ids().plugin_id; + rename_plugin_pane(own_plugin_id, "Plugin Manager"); } fn pipe(&mut self, pipe_message: PipeMessage) -> bool { if pipe_message.name == "filepicker_result" { @@ -523,11 +524,6 @@ impl ZellijPlugin for State { fn update(&mut self, event: Event) -> bool { let mut should_render = false; match event { - Event::PermissionRequestResult(_) => { - let own_plugin_id = get_plugin_ids().plugin_id; - rename_plugin_pane(own_plugin_id, "Plugin Manager"); - should_render = true; - }, Event::SessionUpdate(live_sessions, _dead_sessions) => { for session in live_sessions { if session.is_current_session { diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs index 9cabfabe..bb2678e9 100644 --- a/zellij-server/src/tab/mod.rs +++ b/zellij-server/src/tab/mod.rs @@ -3835,24 +3835,19 @@ impl Tab { let err_context = || format!("failed to update name of active pane to '{buf:?}' for client {client_id}"); - if let Some(active_terminal_id) = self.get_active_terminal_id(client_id) { - let active_terminal = if self.are_floating_panes_visible() { - self.floating_panes - .get_pane_mut(PaneId::Terminal(active_terminal_id)) - } else { - self.tiled_panes - .get_pane_mut(PaneId::Terminal(active_terminal_id)) - } - .with_context(err_context)?; - - // It only allows printable unicode, delete and backspace keys. - let is_updatable = buf - .iter() - .all(|u| matches!(u, 0x20..=0x7E | 0xA0..=0xFF | 0x08 | 0x7F)); - if is_updatable { - let s = str::from_utf8(&buf).with_context(err_context)?; - active_terminal.update_name(s); - } + // Only allow printable unicode, delete and backspace keys. + let is_updatable = buf + .iter() + .all(|u| matches!(u, 0x20..=0x7E | 0xA0..=0xFF | 0x08 | 0x7F)); + if is_updatable { + let s = str::from_utf8(&buf).with_context(err_context)?; + self.get_active_pane_mut(client_id) + .with_context(|| format!("no active pane found for client {client_id}")) + .map(|active_pane| { + active_pane.update_name(s); + })?; + } else { + log::error!("Failed to update pane name due to unprintable characters"); } Ok(()) }