From 50b48b744fbe51accf19526a23b071ff43c9a24b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 7 Mar 2021 18:07:13 -0500 Subject: a few renames --- examples/async.rs | 6 +++--- examples/basic.rs | 4 ++-- examples/tmux.rs | 14 +++++++------- src/async.rs | 8 ++++---- src/blocking.rs | 10 +++++----- src/lib.rs | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/async.rs b/examples/async.rs index 7c8769e..3736cb8 100644 --- a/examples/async.rs +++ b/examples/async.rs @@ -1,6 +1,6 @@ -use textmode::TextmodeExt as _; +use textmode::Textmode as _; -async fn run(tm: &mut textmode::r#async::Textmode) -> std::io::Result<()> { +async fn run(tm: &mut textmode::r#async::Output) -> std::io::Result<()> { tm.move_to(5, 5); tm.write_str("foo"); smol::Timer::after(std::time::Duration::from_secs(2)).await; @@ -21,7 +21,7 @@ async fn run(tm: &mut textmode::r#async::Textmode) -> std::io::Result<()> { fn main() { smol::block_on(async { - let mut tm = textmode::r#async::Textmode::new().await.unwrap(); + let mut tm = textmode::r#async::Output::new().await.unwrap(); let e = run(&mut tm).await; tm.cleanup().await.unwrap(); e.unwrap(); diff --git a/examples/basic.rs b/examples/basic.rs index a46d449..fb13d89 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -1,7 +1,7 @@ -use textmode::TextmodeExt as _; +use textmode::Textmode as _; fn main() { - let mut tm = textmode::blocking::Textmode::new().unwrap(); + let mut tm = textmode::blocking::Output::new().unwrap(); tm.move_to(5, 5); tm.write_str("foo"); diff --git a/examples/tmux.rs b/examples/tmux.rs index 7f5c748..e5e4fcd 100644 --- a/examples/tmux.rs +++ b/examples/tmux.rs @@ -1,6 +1,6 @@ use pty_process::Command as _; use smol::io::{AsyncReadExt as _, AsyncWriteExt as _}; -use textmode::TextmodeExt as _; +use textmode::Textmode as _; enum Command { NewWindow, @@ -213,7 +213,7 @@ impl State { .detach(); } - async fn redraw_current_window(&mut self, tm: &mut textmode::Textmode) { + async fn redraw_current_window(&mut self, tm: &mut textmode::Output) { let window = self.current_window(); tm.clear(); let new_screen = window.vt.lock_arc().await.screen().clone(); @@ -224,7 +224,7 @@ impl State { tm.refresh().await.unwrap(); } - async fn update_current_window(&mut self, tm: &mut textmode::Textmode) { + async fn update_current_window(&mut self, tm: &mut textmode::Output) { let window = self.current_window(); let old_screen = window.screen.clone(); let new_screen = window.vt.lock_arc().await.screen().clone(); @@ -244,7 +244,7 @@ impl State { fn clear_notifications( &mut self, - tm: &mut textmode::Textmode, + tm: &mut textmode::Output, screen: &vt100::Screen, ) { if self.notifications.is_empty() { @@ -269,7 +269,7 @@ impl State { fn draw_notifications( &mut self, - tm: &mut textmode::Textmode, + tm: &mut textmode::Output, screen: &vt100::Screen, ) { if self.notifications.is_empty() { @@ -310,14 +310,14 @@ impl State { #[must_use] struct Tmux { input: textmode::Input, - tm: textmode::Textmode, + tm: textmode::Output, state: State, } impl Tmux { async fn new() -> Self { let input = textmode::Input::new(); - let tm = textmode::Textmode::new().await.unwrap(); + let tm = textmode::Output::new().await.unwrap(); let state = State::new(); Self { input, tm, state } } diff --git a/src/async.rs b/src/async.rs index 92a4f30..0a858c8 100644 --- a/src/async.rs +++ b/src/async.rs @@ -2,12 +2,12 @@ use futures_lite::io::AsyncWriteExt as _; use super::private::TextmodeImpl as _; -pub struct Textmode { +pub struct Output { cur: vt100::Parser, next: vt100::Parser, } -impl super::private::TextmodeImpl for Textmode { +impl super::private::TextmodeImpl for Output { fn cur(&self) -> &vt100::Parser { &self.cur } @@ -25,9 +25,9 @@ impl super::private::TextmodeImpl for Textmode { } } -impl super::TextmodeExt for Textmode {} +impl super::Textmode for Output {} -impl Textmode { +impl Output { pub async fn new() -> std::io::Result { let (rows, cols) = match terminal_size::terminal_size() { Some((terminal_size::Width(w), terminal_size::Height(h))) => { diff --git a/src/blocking.rs b/src/blocking.rs index 538f051..53cc54c 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -2,12 +2,12 @@ use std::io::Write as _; use super::private::TextmodeImpl as _; -pub struct Textmode { +pub struct Output { cur: vt100::Parser, next: vt100::Parser, } -impl super::private::TextmodeImpl for Textmode { +impl super::private::TextmodeImpl for Output { fn cur(&self) -> &vt100::Parser { &self.cur } @@ -25,9 +25,9 @@ impl super::private::TextmodeImpl for Textmode { } } -impl super::TextmodeExt for Textmode {} +impl super::Textmode for Output {} -impl Textmode { +impl Output { pub fn new() -> std::io::Result { let (rows, cols) = match terminal_size::terminal_size() { Some((terminal_size::Width(w), terminal_size::Height(h))) => { @@ -65,7 +65,7 @@ impl Textmode { } } -impl Drop for Textmode { +impl Drop for Output { fn drop(&mut self) { let _ = self.write_stdout(super::DEINIT); } diff --git a/src/lib.rs b/src/lib.rs index e63f208..7e1842b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ pub use input::{Input, Key}; #[cfg(feature = "async")] pub mod r#async; #[cfg(feature = "async")] -pub use r#async::Textmode; +pub use r#async::Output; const INIT: &[u8] = b"\x1b7\x1b[?47h\x1b[2J\x1b[H\x1b[?25h"; const DEINIT: &[u8] = b"\x1b[?47l\x1b8\x1b[?25h"; @@ -33,7 +33,7 @@ mod private { } } -pub trait TextmodeExt: private::TextmodeImpl { +pub trait Textmode: private::TextmodeImpl { fn screen(&self) -> &vt100::Screen { self.next().screen() } -- cgit v1.2.3-54-g00ecf