diff options
| author | Fuwn <[email protected]> | 2022-07-17 10:52:58 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-07-17 10:52:58 +0000 |
| commit | 3287ca848c1abde039a237fc1af0e48b63a91409 (patch) | |
| tree | 46c81727200e74bdc78ce3032e4de51fa0d22611 /src | |
| parent | docs(README.md): add gif of usage (diff) | |
| download | sydney-3287ca848c1abde039a237fc1af0e48b63a91409.tar.xz sydney-3287ca848c1abde039a237fc1af0e48b63a91409.zip | |
feat(app.rs): auto obtain terminal width
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.rs | 6 | ||||
| -rw-r--r-- | src/command.rs | 2 |
2 files changed, 4 insertions, 4 deletions
@@ -37,7 +37,7 @@ pub struct App { pub response_input: String, pub accept_response_input: bool, pub response_input_text: String, - pub wrap_at: usize, + pub wrap_at: u16, } impl App { pub fn new() -> Self { @@ -57,7 +57,7 @@ impl App { previous_capsule: None, accept_response_input: false, response_input_text: "".to_string(), - wrap_at: 80, + wrap_at: crossterm::terminal::size().unwrap_or((80, 24)).0, }; app.make_request(); @@ -123,7 +123,7 @@ impl App { } else { line .as_bytes() - .chunks(self.wrap_at) + .chunks(self.wrap_at as usize) .map(|buf| { #[allow(unsafe_code)] unsafe { std::str::from_utf8_unchecked(buf) }.to_string() diff --git a/src/command.rs b/src/command.rs index 4dc3615..f17b235 100644 --- a/src/command.rs +++ b/src/command.rs @@ -19,7 +19,7 @@ pub enum Command { Quit, Open(Option<String>), Unknown, - Wrap(usize, Option<String>), + Wrap(u16, Option<String>), } impl From<String> for Command { fn from(s: String) -> Self { |