Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): various pane name fixes #3653

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading