Struct tty_interface::Interface
source · [−]pub struct Interface<'a> { /* private fields */ }Expand description
A terminal interface (TUI) which efficiently handles updates and layout.
Implementations
sourceimpl<'a> Interface<'a>
impl<'a> Interface<'a>
sourcepub fn new(writer: &'a mut dyn Write) -> Result<Interface<'a>>
pub fn new(writer: &'a mut dyn Write) -> Result<Interface<'a>>
A new interface using the specified output device.
sourcepub fn new_with_configuration(
writer: &'a mut dyn Write,
configuration: Configuration
) -> Result<Interface<'a>>
pub fn new_with_configuration(
writer: &'a mut dyn Write,
configuration: Configuration
) -> Result<Interface<'a>>
A new interface using the specified output device and configuration options.
sourcepub fn cursor(&self) -> Option<Position>
pub fn cursor(&self) -> Option<Position>
The interface’s cursor position. Reflects the latest state, even if staged changes have not yet been applied to the interface.
sourcepub fn line_ids(&self) -> &Vec<LineId>
pub fn line_ids(&self) -> &Vec<LineId>
The interface’s line identifiers. Reflects the latest state, even if staged changes have not yet been applied to the interface.
sourcepub fn lines(&self) -> Vec<&Line>
pub fn lines(&self) -> Vec<&Line>
The interface’s lines. Reflects the latest state, even if staged changes have not yet been applied to the interface.
sourcepub fn get_lines(&self, ids: &Vec<LineId>) -> Result<Vec<&Line>>
pub fn get_lines(&self, ids: &Vec<LineId>) -> Result<Vec<&Line>>
Retrieves several line references by their identifiers.
sourcepub fn get_line(&self, id: &LineId) -> Result<&Line>
pub fn get_line(&self, id: &LineId) -> Result<&Line>
Retrieves a line reference by its identifier.
sourcepub fn get_line_mut(&mut self, id: &LineId) -> Result<&mut Line>
pub fn get_line_mut(&mut self, id: &LineId) -> Result<&mut Line>
Retrieves a mutable line reference by its identifier.
sourcepub fn get_line_index(&self, id: &LineId) -> Result<usize>
pub fn get_line_index(&self, id: &LineId) -> Result<usize>
Determines the specified line’s index in this interface.
sourcepub fn set_cursor(&mut self, cursor: Position)
pub fn set_cursor(&mut self, cursor: Position)
Sets the cursor position. The cursor update will be staged until changes are applied.
sourcepub fn hide_cursor(&mut self)
pub fn hide_cursor(&mut self)
Hides the cursor. The cursor update will be staged until changes are applied.
sourcepub fn set_optimization(&mut self, allow_optimization: bool)
pub fn set_optimization(&mut self, allow_optimization: bool)
Updates whether to allow optimizations when rendering.
sourcepub fn add_line(&mut self) -> &mut Line
pub fn add_line(&mut self) -> &mut Line
Appends a new line to this interface. The line addition will be staged until changes are applied. Note that the returned line may have other changes staged against it for the same update.
sourcepub fn insert_line(&mut self, index: usize) -> Result<&mut Line>
pub fn insert_line(&mut self, index: usize) -> Result<&mut Line>
Inserts a new line in this interface at a specified index. The line addition will be staged until changes are applied. Note that the returned line may have other changes staged against it for the same update.
sourcepub fn remove_line(&mut self, id: &LineId) -> Result<()>
pub fn remove_line(&mut self, id: &LineId) -> Result<()>
Removes a line with the specified identifier from the interface. The line removal will be staged until changes are applied.
sourcepub fn remove_line_at(&mut self, index: usize) -> Result<LineId>
pub fn remove_line_at(&mut self, index: usize) -> Result<LineId>
Removes a line from this interface at the specified index. The line removal will be staged until changes are applied.
sourcepub fn move_segment(
&mut self,
segment_id: &SegmentId,
from_line_id: &LineId,
to_line_id: &LineId
) -> Result<()>
pub fn move_segment(
&mut self,
segment_id: &SegmentId,
from_line_id: &LineId,
to_line_id: &LineId
) -> Result<()>
Move a segment from one line to the specified index in another.
sourcepub fn has_changes(&self) -> bool
pub fn has_changes(&self) -> bool
Whether this line or its segments have any staged changes.
sourcepub fn apply_changes(&mut self) -> Result<InterfaceLayout>
pub fn apply_changes(&mut self) -> Result<InterfaceLayout>
Applies any staged changes for this interface and its constituent lines and segments. Returns the rendered-layout.
sourcepub fn advance_to_end(&mut self) -> Result<()>
pub fn advance_to_end(&mut self) -> Result<()>
Advances the cursor to the end of the interface.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Interface<'a>
impl<'a> !Send for Interface<'a>
impl<'a> !Sync for Interface<'a>
impl<'a> Unpin for Interface<'a>
impl<'a> !UnwindSafe for Interface<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more