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 31)
20fn main() -> std::io::Result<()> {
21 let (mut terminal, size) = setup_terminal().unwrap();
22
23 // Subtract the borders from the size
24 let size = tui_term::controller::Size::new(size.cols - 2, size.rows, 0, 0);
25
26 let mut cmd = CommandBuilder::new("ls");
27 if let Ok(cwd) = std::env::current_dir() {
28 cmd.cwd(cwd);
29 }
30
31 let mut controller = Controller::new(cmd, Some(size));
32 controller.run();
33 let screen = controller.screen();
34
35 run(&mut terminal, screen)?;
36
37 cleanup_terminal(&mut terminal).unwrap();
38 Ok(())
39}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 32)
20fn main() -> std::io::Result<()> {
21 let (mut terminal, size) = setup_terminal().unwrap();
22
23 // Subtract the borders from the size
24 let size = tui_term::controller::Size::new(size.cols - 2, size.rows, 0, 0);
25
26 let mut cmd = CommandBuilder::new("ls");
27 if let Ok(cwd) = std::env::current_dir() {
28 cmd.cwd(cwd);
29 }
30
31 let mut controller = Controller::new(cmd, Some(size));
32 controller.run();
33 let screen = controller.screen();
34
35 run(&mut terminal, screen)?;
36
37 cleanup_terminal(&mut terminal).unwrap();
38 Ok(())
39}Sourcepub fn screen(&self) -> Option<Screen>
pub fn screen(&self) -> Option<Screen>
Examples found in repository?
examples/simple_ls_controller.rs (line 33)
20fn main() -> std::io::Result<()> {
21 let (mut terminal, size) = setup_terminal().unwrap();
22
23 // Subtract the borders from the size
24 let size = tui_term::controller::Size::new(size.cols - 2, size.rows, 0, 0);
25
26 let mut cmd = CommandBuilder::new("ls");
27 if let Ok(cwd) = std::env::current_dir() {
28 cmd.cwd(cwd);
29 }
30
31 let mut controller = Controller::new(cmd, Some(size));
32 controller.run();
33 let screen = controller.screen();
34
35 run(&mut terminal, screen)?;
36
37 cleanup_terminal(&mut terminal).unwrap();
38 Ok(())
39}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