1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 05:12:40 +03:00

populate pixel dims + dpi in PaneEntry

This makes those fields usable in `wezterm cli list --format json`.

This doesn't change the ABI of the mux protocol, but prior to
this commit, those fields were always 0.

refs: #2319
This commit is contained in:
Wez Furlong 2022-07-31 11:25:39 -07:00
parent 7dda063c27
commit aed0e3ebf8
6 changed files with 41 additions and 5 deletions

View File

@ -40,6 +40,8 @@ pub struct RenderableDimensions {
/// expressed as a stable index.
pub scrollback_top: StableRowIndex,
pub dpi: u32,
pub pixel_width: usize,
pub pixel_height: usize,
}
impl_lua_conversion_dynamic!(RenderableDimensions);
@ -127,6 +129,7 @@ pub fn terminal_get_lines(
/// Implements Pane::get_dimensions for Terminal
pub fn terminal_get_dimensions(term: &mut Terminal) -> RenderableDimensions {
let size = term.get_size();
let screen = term.screen();
RenderableDimensions {
cols: screen.physical_cols,
@ -135,5 +138,7 @@ pub fn terminal_get_dimensions(term: &mut Terminal) -> RenderableDimensions {
physical_top: screen.visible_row_to_stable_row(0),
scrollback_top: screen.phys_to_stable_row_index(0),
dpi: screen.dpi,
pixel_width: size.pixel_width,
pixel_height: size.pixel_height,
}
}

View File

@ -220,9 +220,9 @@ fn pane_tree(
size: TerminalSize {
cols: dims.cols,
rows: dims.viewport_rows,
pixel_height: 0,
pixel_width: 0,
dpi: 0,
pixel_height: dims.pixel_height,
pixel_width: dims.pixel_width,
dpi: dims.dpi,
},
working_dir: working_dir.map(Into::into),
workspace: workspace.to_string(),

View File

@ -844,6 +844,17 @@ impl TerminalState {
}
}
pub fn get_size(&self) -> TerminalSize {
let screen = self.screen();
TerminalSize {
dpi: self.dpi,
pixel_width: self.pixel_width,
pixel_height: self.pixel_height,
rows: screen.physical_rows,
cols: screen.physical_cols,
}
}
/// When dealing with selection, mark a range of lines as dirty
pub fn make_all_lines_dirty(&mut self) {
let seqno = self.seqno;

View File

@ -74,6 +74,8 @@ impl ClientPane {
physical_top: 0,
scrollback_top: 0,
dpi: size.dpi,
pixel_width: size.pixel_width,
pixel_height: size.pixel_height,
},
title,
fetch_limiter,

View File

@ -951,6 +951,8 @@ impl super::TermWindow {
scrollback_top: 0,
viewport_rows: 1,
dpi: self.terminal_size.dpi,
pixel_height: self.render_metrics.cell_size.height as usize,
pixel_width: self.terminal_size.pixel_width,
},
config: &self.config,
cursor_border_color: LinearRgba::default(),

View File

@ -575,6 +575,9 @@ async fn resolve_pane_id(client: &Client, pane_id: Option<PaneId>) -> anyhow::Re
struct CliListResultPtySize {
rows: usize,
cols: usize,
pixel_width: usize,
pixel_height: usize,
dpi: u32,
}
// This will be serialized to JSON via the 'List' command.
// As such it is intended to be a stable output format,
@ -600,7 +603,14 @@ impl From<mux::tab::PaneEntry> for CliListResultItem {
workspace,
title,
working_dir,
size: TerminalSize { rows, cols, .. },
size:
TerminalSize {
rows,
cols,
pixel_width,
pixel_height,
dpi,
},
..
} = pane;
@ -609,7 +619,13 @@ impl From<mux::tab::PaneEntry> for CliListResultItem {
tab_id,
pane_id,
workspace,
size: CliListResultPtySize { rows, cols },
size: CliListResultPtySize {
rows,
cols,
pixel_width,
pixel_height,
dpi,
},
title,
cwd: working_dir
.as_ref()