diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-11-11 15:19:31 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-11-11 15:19:31 -0500 |
commit | e7fa88dcd4b261af643a9aedfce0f0a1d9a97462 (patch) | |
tree | 60cc330de5c038c4f1534b142c600a6e0a87f624 /src/readline.rs | |
parent | 7a411e269b59cb7754eadacaf29a18e02845040b (diff) | |
download | nbsh-e7fa88dcd4b261af643a9aedfce0f0a1d9a97462.tar.gz nbsh-e7fa88dcd4b261af643a9aedfce0f0a1d9a97462.zip |
handle dynamic terminal sizes
Diffstat (limited to 'src/readline.rs')
-rw-r--r-- | src/readline.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/readline.rs b/src/readline.rs index cc6c776..929905d 100644 --- a/src/readline.rs +++ b/src/readline.rs @@ -1,6 +1,7 @@ use textmode::Textmode as _; pub struct Readline { + size: (u16, u16), prompt: String, input_line: String, action: async_std::channel::Sender<crate::action::Action>, @@ -11,6 +12,7 @@ impl Readline { action: async_std::channel::Sender<crate::action::Action>, ) -> Self { Self { + size: (24, 80), prompt: "$ ".into(), input_line: "".into(), action, @@ -52,12 +54,16 @@ impl Readline { &self, out: &mut textmode::Output, ) -> anyhow::Result<()> { - out.move_to(23, 0); + out.move_to(self.size.0 - 1, 0); out.write_str(&self.prompt); out.write_str(&self.input_line); Ok(()) } + pub async fn resize(&mut self, size: (u16, u16)) { + self.size = size; + } + fn input(&self) -> String { self.input_line.clone() } |