pub struct Controller { /* private fields */ }Expand description
Controller, in charge of command dispatch
Implementations§
Source§impl Controller
impl Controller
Sourcepub fn new(cmd: CommandBuilder, size: Option<Size>) -> Self
pub fn new(cmd: CommandBuilder, size: Option<Size>) -> Self
Examples found in repository?
examples/simple_ls_controller.rs (line 37)
22fn run_app(terminal: &mut DefaultTerminal) -> std::io::Result<()> {
23 let terminal_size = terminal.size()?;
24 let size = Size {
25 rows: terminal_size.height,
26 cols: terminal_size.width,
27 };
28
29 // Subtract the borders from the size
30 let size = tui_term::controller::Size::new(size.cols - 2, size.rows, 0, 0);
31
32 let mut cmd = CommandBuilder::new("ls");
33 if let Ok(cwd) = std::env::current_dir() {
34 cmd.cwd(cwd);
35 }
36
37 let mut controller = Controller::new(cmd, Some(size));
38 controller.run();
39 let screen = controller.screen();
40
41 run(terminal, screen)
42}Sourcepub fn run(&mut self)
pub fn run(&mut self)
This function is blocking while waiting for the command to end.
Examples found in repository?
examples/simple_ls_controller.rs (line 38)
22fn run_app(terminal: &mut DefaultTerminal) -> std::io::Result<()> {
23 let terminal_size = terminal.size()?;
24 let size = Size {
25 rows: terminal_size.height,
26 cols: terminal_size.width,
27 };
28
29 // Subtract the borders from the size
30 let size = tui_term::controller::Size::new(size.cols - 2, size.rows, 0, 0);
31
32 let mut cmd = CommandBuilder::new("ls");
33 if let Ok(cwd) = std::env::current_dir() {
34 cmd.cwd(cwd);
35 }
36
37 let mut controller = Controller::new(cmd, Some(size));
38 controller.run();
39 let screen = controller.screen();
40
41 run(terminal, screen)
42}Sourcepub fn screen(&self) -> Option<Screen>
pub fn screen(&self) -> Option<Screen>
Examples found in repository?
examples/simple_ls_controller.rs (line 39)
22fn run_app(terminal: &mut DefaultTerminal) -> std::io::Result<()> {
23 let terminal_size = terminal.size()?;
24 let size = Size {
25 rows: terminal_size.height,
26 cols: terminal_size.width,
27 };
28
29 // Subtract the borders from the size
30 let size = tui_term::controller::Size::new(size.cols - 2, size.rows, 0, 0);
31
32 let mut cmd = CommandBuilder::new("ls");
33 if let Ok(cwd) = std::env::current_dir() {
34 cmd.cwd(cwd);
35 }
36
37 let mut controller = Controller::new(cmd, Some(size));
38 controller.run();
39 let screen = controller.screen();
40
41 run(terminal, screen)
42}Sourcepub fn status(&self) -> Option<&IoResult<ExitStatus>>
pub fn status(&self) -> Option<&IoResult<ExitStatus>>
The exit status of the process
Auto Trait Implementations§
impl Freeze for Controller
impl !RefUnwindSafe for Controller
impl Send for Controller
impl Sync for Controller
impl Unpin for Controller
impl !UnwindSafe for Controller
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more