[−][src]Struct unsegen::base::window::Window
A rectangular view into a terminal buffer, i.e., a grid of grapheme clusters.
Moreover, a window always has a default style that is applied to all characters that are written to it. By default this is a "plain" style that does not change color or text format.
Side note: Grapheme clusters do not always have a width of a singular cell, and thus things can quite complicated. Therefore, Multi-width characters occupy more than once cell in a single window. If any of the cells is overwritten, potentially left-over cells are overwritten with space characters.
Implementations
impl<'w> Window<'w>
[src]
pub fn get_extent<D: AxisDimension>(&self) -> PositiveAxisDiff<D>
[src]
Get the extent of the window in the specified dimension (i.e., its width or height)
pub fn get_width(&self) -> Width
[src]
Get the width (i.e., number of columns) that the window occupies.
pub fn get_height(&self) -> Height
[src]
Get the height (i.e., number of rows) that the window occupies.
pub fn create_subwindow<'a, WX: RangeBounds<ColIndex>, WY: RangeBounds<RowIndex>>(
&'a mut self,
x_range: WX,
y_range: WY
) -> Window<'a>
[src]
&'a mut self,
x_range: WX,
y_range: WY
) -> Window<'a>
Create a subview of the window.
Examples:
use unsegen::base::{ColIndex, RowIndex, GraphemeCluster}; let mut win = term.create_root_window(); { let mut w = win.create_subwindow( ColIndex::new(0) .. ColIndex::new(2), RowIndex::new(2) .. RowIndex::new(4) ); w.fill(GraphemeCluster::try_from('A').unwrap()); } { let mut w = win.create_subwindow( ColIndex::new(2) .. ColIndex::new(4), RowIndex::new(0) .. RowIndex::new(2) ); w.fill(GraphemeCluster::try_from('B').unwrap()); }
Panics:
Panics on invalid ranges, i.e., if: start > end, start < 0, or end > [width of the window]
pub fn split<D: AxisDimension>(
self,
split_pos: AxisIndex<D>
) -> Result<(Self, Self), Self>
[src]
self,
split_pos: AxisIndex<D>
) -> Result<(Self, Self), Self>
Split the window horizontally or vertically into two halves.
If the split position is invalid (i.e., larger than the height/width of the window or negative), the original window is returned untouched as the error value. split_pos defines the first row of the second window.
Examples:
use unsegen::base::*; let mut wb = WindowBuffer::new(Width::new(5).unwrap(), Height::new(5).unwrap()); { let win = wb.as_window(); let (w1, w2) = win.split(RowIndex::new(3)).unwrap(); assert_eq!(w1.get_height(), Height::new(3).unwrap()); assert_eq!(w1.get_width(), Width::new(5).unwrap()); assert_eq!(w2.get_height(), Height::new(2).unwrap()); assert_eq!(w2.get_width(), Width::new(5).unwrap()); } { let win = wb.as_window(); let (w1, w2) = win.split(ColIndex::new(3)).unwrap(); assert_eq!(w1.get_height(), Height::new(5).unwrap()); assert_eq!(w1.get_width(), Width::new(3).unwrap()); assert_eq!(w2.get_height(), Height::new(5).unwrap()); assert_eq!(w2.get_width(), Width::new(2).unwrap()); }
pub fn fill(&mut self, c: GraphemeCluster)
[src]
Fill the window with the specified GraphemeCluster.
The style is defined by the default style of the window. If the grapheme cluster is wider than 1 cell, any left over cells are filled with space characters.
Examples:
use unsegen::base::*; let mut wb = WindowBuffer::new(Width::new(5).unwrap(), Height::new(5).unwrap()); wb.as_window().fill(GraphemeCluster::try_from('X').unwrap()); // Every cell of wb now contains an 'X'. wb.as_window().fill(GraphemeCluster::try_from('山').unwrap()); // Every row of wb now contains two '山', while the last column cotains spaces.
pub fn clear(&mut self)
[src]
Fill the window with space characters.
The style (i.e., the background color) is defined by the default style of the window.
Examples:
use unsegen::base::*; let mut wb = WindowBuffer::new(Width::new(5).unwrap(), Height::new(5).unwrap()); wb.as_window().clear(); // Every cell of wb now contains a ' '.
pub fn set_default_style(&mut self, style: Style)
[src]
Specify the new default style of the window. This style will be applied to all grapheme clusters written to the window.
Examples:
use unsegen::base::*; let mut wb = WindowBuffer::new(Width::new(5).unwrap(), Height::new(5).unwrap()); let mut win = wb.as_window(); win.set_default_style(StyleModifier::new().fg_color(Color::Red).bg_color(Color::Blue).apply_to_default()); win.clear(); // wb is now cleared and has a blue background.
pub fn modify_default_style(&mut self, modifier: StyleModifier)
[src]
Specify the new default style of the window. This style will be applied to all grapheme clusters written to the window.
Examples:
use unsegen::base::*; let mut wb = WindowBuffer::new(Width::new(5).unwrap(), Height::new(5).unwrap()); let mut win = wb.as_window(); win.set_default_style(StyleModifier::new().fg_color(Color::Red).bg_color(Color::Blue).apply_to_default()); win.clear(); // wb is now cleared an has a blue background. win.modify_default_style(StyleModifier::new().bg_color(Color::Yellow)); win.clear(); // wb is now cleared an has a yellow background. assert_eq!(*win.default_style(), StyleModifier::new().fg_color(Color::Red).bg_color(Color::Yellow).apply_to_default())
pub fn default_style(&self) -> &Style
[src]
Get the current default style of the window.
Change the default style using modify_default_style or set_default_style.
Trait Implementations
impl<'a> CursorTarget for Window<'a>
[src]
fn get_width(&self) -> Width
[src]
fn get_height(&self) -> Height
[src]
fn get_cell_mut(
&mut self,
x: ColIndex,
y: RowIndex
) -> Option<&mut StyledGraphemeCluster>
[src]
&mut self,
x: ColIndex,
y: RowIndex
) -> Option<&mut StyledGraphemeCluster>
fn get_cell(&self, x: ColIndex, y: RowIndex) -> Option<&StyledGraphemeCluster>
[src]
fn get_default_style(&self) -> Style
[src]
fn get_soft_width(&self) -> Width
[src]
impl<'w> Debug for Window<'w>
[src]
Auto Trait Implementations
impl<'w> RefUnwindSafe for Window<'w>
impl<'w> Send for Window<'w>
impl<'w> Sync for Window<'w>
impl<'w> Unpin for Window<'w>
impl<'w> !UnwindSafe for Window<'w>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,