mirror of
https://github.com/helix-editor/termina.git
synced 2025-10-06 00:22:43 +02:00
feat: add window pixel width and height (#6)
This commit is contained in:
@@ -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>,
|
||||
}
|
||||
|
@@ -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,
|
||||
}));
|
||||
}
|
||||
_ => (),
|
||||
|
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -256,6 +256,8 @@ impl OutputHandle {
|
||||
Ok(WindowSize {
|
||||
rows: rows.get(),
|
||||
cols: cols.get(),
|
||||
pixel_width: None,
|
||||
pixel_height: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user