mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-22 22:26:54 +03:00
fix: Allow terminal title passthrough even when not drawing pane frames. (#1113)
* fix: Allow terminal title passthrough even when not drawing pane frames. * Minor formatting fix. * Handle case where the session name is not set.
This commit is contained in:
parent
c2e06a1a70
commit
e2081f2649
@ -16,6 +16,7 @@ use zellij_utils::zellij_tile::prelude::{Event, InputMode, Mouse, PaletteColor};
|
||||
use zellij_utils::{
|
||||
channels::SenderWithContext,
|
||||
pane_size::{Dimension, PaneGeom},
|
||||
shared::make_terminal_title,
|
||||
};
|
||||
|
||||
pub(crate) struct PluginPane {
|
||||
@ -253,6 +254,16 @@ impl Pane for PluginPane {
|
||||
) -> Option<String> {
|
||||
None
|
||||
}
|
||||
fn render_terminal_title(&mut self, input_mode: InputMode) -> String {
|
||||
let pane_title = if self.pane_name.is_empty() && input_mode == InputMode::RenamePane {
|
||||
"Enter name..."
|
||||
} else if self.pane_name.is_empty() {
|
||||
&self.pane_title
|
||||
} else {
|
||||
&self.pane_name
|
||||
};
|
||||
make_terminal_title(pane_title)
|
||||
}
|
||||
fn update_name(&mut self, name: &str) {
|
||||
match name {
|
||||
"\0" => {
|
||||
|
@ -17,6 +17,7 @@ use zellij_utils::pane_size::Offset;
|
||||
use zellij_utils::{
|
||||
pane_size::{Dimension, PaneGeom},
|
||||
position::Position,
|
||||
shared::make_terminal_title,
|
||||
vte,
|
||||
zellij_tile::data::{InputMode, Palette, PaletteColor},
|
||||
};
|
||||
@ -303,6 +304,16 @@ impl Pane for TerminalPane {
|
||||
}
|
||||
vte_output
|
||||
}
|
||||
fn render_terminal_title(&mut self, input_mode: InputMode) -> String {
|
||||
let pane_title = if self.pane_name.is_empty() && input_mode == InputMode::RenamePane {
|
||||
"Enter name..."
|
||||
} else if self.pane_name.is_empty() {
|
||||
self.grid.title.as_deref().unwrap_or(&self.pane_title)
|
||||
} else {
|
||||
&self.pane_name
|
||||
};
|
||||
make_terminal_title(pane_title)
|
||||
}
|
||||
fn update_name(&mut self, name: &str) {
|
||||
match name {
|
||||
"\0" => {
|
||||
|
@ -169,6 +169,7 @@ pub trait Pane {
|
||||
cursor_color: PaletteColor,
|
||||
text_color: PaletteColor,
|
||||
) -> Option<String>;
|
||||
fn render_terminal_title(&mut self, _input_mode: InputMode) -> String;
|
||||
fn update_name(&mut self, name: &str);
|
||||
fn pid(&self) -> PaneId;
|
||||
fn reduce_height(&mut self, percent: f64);
|
||||
@ -1225,6 +1226,7 @@ impl Tab {
|
||||
self.session_is_mirrored,
|
||||
);
|
||||
}
|
||||
pane_contents_and_ui.render_terminal_title_if_needed(client_id, client_mode);
|
||||
// this is done for panes that don't have their own cursor (eg. panes of
|
||||
// another user)
|
||||
pane_contents_and_ui.render_fake_cursor_if_needed(client_id);
|
||||
|
@ -2,8 +2,8 @@ use crate::output::CharacterChunk;
|
||||
use crate::panes::{AnsiCode, CharacterStyles, TerminalCharacter, EMPTY_TERMINAL_CHARACTER};
|
||||
use crate::ui::boundaries::boundary_type;
|
||||
use crate::ClientId;
|
||||
use zellij_utils::pane_size::Viewport;
|
||||
use zellij_utils::zellij_tile::prelude::{client_id_to_colors, Palette, PaletteColor};
|
||||
use zellij_utils::{envs::get_session_name, pane_size::Viewport};
|
||||
|
||||
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
|
||||
|
||||
@ -603,15 +603,6 @@ impl PaneFrame {
|
||||
character_chunks.push(CharacterChunk::new(boundary_character_right, x, y));
|
||||
}
|
||||
}
|
||||
let vte_output = if self.is_main_client {
|
||||
Some(format!(
|
||||
"\u{1b}]0;Zellij ({}) - {}\u{07}",
|
||||
get_session_name().unwrap(),
|
||||
self.title
|
||||
))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
(character_chunks, vte_output)
|
||||
(character_chunks, None)
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ use std::collections::HashMap;
|
||||
use zellij_tile::data::{
|
||||
client_id_to_colors, single_client_color, InputMode, Palette, PaletteColor,
|
||||
};
|
||||
|
||||
pub struct PaneContentsAndUi<'a> {
|
||||
pane: &'a mut Box<dyn Pane>,
|
||||
output: &'a mut Output,
|
||||
@ -111,6 +110,14 @@ impl<'a> PaneContentsAndUi<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn render_terminal_title_if_needed(&mut self, client_id: ClientId, client_mode: InputMode) {
|
||||
if !self.focused_clients.contains(&client_id) {
|
||||
return;
|
||||
}
|
||||
let vte_output = self.pane.render_terminal_title(client_mode);
|
||||
self.output
|
||||
.add_post_vte_instruction_to_client(client_id, &vte_output);
|
||||
}
|
||||
pub fn render_pane_frame(
|
||||
&mut self,
|
||||
client_id: ClientId,
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use std::{iter, str::from_utf8};
|
||||
|
||||
use crate::envs::get_session_name;
|
||||
use colorsys::Rgb;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::Path;
|
||||
@ -40,6 +41,16 @@ pub fn adjust_to_size(s: &str, rows: usize, columns: usize) -> String {
|
||||
.join("\n\r")
|
||||
}
|
||||
|
||||
pub fn make_terminal_title(pane_title: &str) -> String {
|
||||
format!(
|
||||
"\u{1b}]0;Zellij {}- {}\u{07}",
|
||||
get_session_name()
|
||||
.map(|n| format!("({}) ", n))
|
||||
.unwrap_or_default(),
|
||||
pane_title,
|
||||
)
|
||||
}
|
||||
|
||||
// Colors
|
||||
pub mod colors {
|
||||
pub const WHITE: u8 = 255;
|
||||
|
Loading…
Reference in New Issue
Block a user