fix(ui): various pane name fixes (#3653)
This commit is contained in:
parent
c6e1f0a5fb
commit
8de5947771
3 changed files with 19 additions and 44 deletions
|
|
@ -64,38 +64,22 @@ impl ZellijPlugin for State {
|
||||||
.map(|v| v == "true")
|
.map(|v| v == "true")
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
self.userspace_configuration = configuration;
|
self.userspace_configuration = configuration;
|
||||||
// we need the ReadApplicationState permission to receive the ModeUpdate and TabUpdate
|
subscribe(&[EventType::Key, EventType::FailedToWriteConfigToDisk]);
|
||||||
// events
|
let own_plugin_id = get_plugin_ids().plugin_id;
|
||||||
// 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,
|
|
||||||
]);
|
|
||||||
if self.is_setup_wizard {
|
if self.is_setup_wizard {
|
||||||
self.ui_size = 18;
|
self.ui_size = 18;
|
||||||
self.selected_index = Some(0);
|
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)");
|
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);
|
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 {
|
fn update(&mut self, event: Event) -> bool {
|
||||||
let mut should_render = false;
|
let mut should_render = false;
|
||||||
match event {
|
match event {
|
||||||
Event::PermissionRequestResult(_) => {
|
|
||||||
should_render = true;
|
|
||||||
},
|
|
||||||
Event::Key(key) => {
|
Event::Key(key) => {
|
||||||
if self.remapping_leaders {
|
if self.remapping_leaders {
|
||||||
should_render = self.handle_remapping_screen_key(key);
|
should_render = self.handle_remapping_screen_key(key);
|
||||||
|
|
|
||||||
|
|
@ -486,8 +486,9 @@ impl ZellijPlugin for State {
|
||||||
EventType::TabUpdate,
|
EventType::TabUpdate,
|
||||||
EventType::Key,
|
EventType::Key,
|
||||||
EventType::SessionUpdate,
|
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 {
|
fn pipe(&mut self, pipe_message: PipeMessage) -> bool {
|
||||||
if pipe_message.name == "filepicker_result" {
|
if pipe_message.name == "filepicker_result" {
|
||||||
|
|
@ -523,11 +524,6 @@ impl ZellijPlugin for State {
|
||||||
fn update(&mut self, event: Event) -> bool {
|
fn update(&mut self, event: Event) -> bool {
|
||||||
let mut should_render = false;
|
let mut should_render = false;
|
||||||
match event {
|
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) => {
|
Event::SessionUpdate(live_sessions, _dead_sessions) => {
|
||||||
for session in live_sessions {
|
for session in live_sessions {
|
||||||
if session.is_current_session {
|
if session.is_current_session {
|
||||||
|
|
|
||||||
|
|
@ -3835,24 +3835,19 @@ impl Tab {
|
||||||
let err_context =
|
let err_context =
|
||||||
|| format!("failed to update name of active pane to '{buf:?}' for client {client_id}");
|
|| 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) {
|
// Only allow printable unicode, delete and backspace keys.
|
||||||
let active_terminal = if self.are_floating_panes_visible() {
|
let is_updatable = buf
|
||||||
self.floating_panes
|
.iter()
|
||||||
.get_pane_mut(PaneId::Terminal(active_terminal_id))
|
.all(|u| matches!(u, 0x20..=0x7E | 0xA0..=0xFF | 0x08 | 0x7F));
|
||||||
} else {
|
if is_updatable {
|
||||||
self.tiled_panes
|
let s = str::from_utf8(&buf).with_context(err_context)?;
|
||||||
.get_pane_mut(PaneId::Terminal(active_terminal_id))
|
self.get_active_pane_mut(client_id)
|
||||||
}
|
.with_context(|| format!("no active pane found for client {client_id}"))
|
||||||
.with_context(err_context)?;
|
.map(|active_pane| {
|
||||||
|
active_pane.update_name(s);
|
||||||
// It only allows printable unicode, delete and backspace keys.
|
})?;
|
||||||
let is_updatable = buf
|
} else {
|
||||||
.iter()
|
log::error!("Failed to update pane name due to unprintable characters");
|
||||||
.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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue