feat: add window pixel width and height (#6)

This commit is contained in:
Austin Schey
2025-05-15 09:16:40 -07:00
committed by GitHub
parent 07cc87ef7a
commit b7f6c327a6
4 changed files with 12 additions and 1 deletions

View File

@@ -62,7 +62,8 @@ impl From<NonZeroU16> for OneBased {
/// The dimensions of a terminal screen.
///
/// For both Unix and Windows, Termina returns the width and height
/// For both Unix and Windows, Termina returns the rows and columns.
/// Pixel width and height are not supported on Windows.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct WindowSize {
/// The width - the number of columns.
@@ -71,4 +72,8 @@ pub struct WindowSize {
/// The height - the number of rows.
#[doc(alias = "height")]
pub rows: u16,
/// The height of the window in pixels.
pub pixel_width: Option<u16>,
/// The width of the window in pixels.
pub pixel_height: Option<u16>,
}

View File

@@ -128,6 +128,8 @@ mod windows {
self.events.push_back(Event::WindowResized(WindowSize {
rows: rows.get(),
cols: cols.get(),
pixel_width: None,
pixel_height: None,
}));
}
_ => (),

View File

@@ -86,6 +86,8 @@ impl From<termios::Winsize> for WindowSize {
Self {
cols: size.ws_col,
rows: size.ws_row,
pixel_width: Some(size.ws_xpixel),
pixel_height: Some(size.ws_ypixel),
}
}
}

View File

@@ -256,6 +256,8 @@ impl OutputHandle {
Ok(WindowSize {
rows: rows.get(),
cols: cols.get(),
pixel_width: None,
pixel_height: None,
})
}
}