Skip to content

Commit

Permalink
fix(ui): various pane name fixes (zellij-org#3653)
Browse files Browse the repository at this point in the history
  • Loading branch information
imsnif authored and Tomcat-42 committed Nov 9, 2024
1 parent 2036b7e commit 8910740
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 44 deletions.
24 changes: 4 additions & 20 deletions default-plugins/configuration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 2 additions & 6 deletions default-plugins/plugin-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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 {
Expand Down
31 changes: 13 additions & 18 deletions zellij-server/src/tab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down

0 comments on commit 8910740

Please sign in to comment.