fix(ui): various pane name fixes (#3653)

This commit is contained in:
Aram Drevekenin 2024-10-09 10:44:43 +02:00 committed by GitHub
parent c6e1f0a5fb
commit 8de5947771
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 44 deletions

View file

@ -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);

View file

@ -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 {

View file

@ -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(())
}