diff --git a/term/src/terminal.rs b/term/src/terminal.rs index 1ed2bc6c9..012935c81 100644 --- a/term/src/terminal.rs +++ b/term/src/terminal.rs @@ -15,10 +15,10 @@ pub trait Clipboard { pub trait TerminalHost { /// Returns an object that can be used to send data to the /// slave end of the associated pty. - fn writer(&mut self) -> &mut std::io::Write; + fn writer(&mut self) -> &mut dyn std::io::Write; /// Returns the clipboard manager - fn get_clipboard(&mut self) -> Fallible>; + fn get_clipboard(&mut self) -> Fallible>; /// Change the title of the window fn set_title(&mut self, title: &str); @@ -85,7 +85,7 @@ impl Terminal { } /// Feed the terminal parser a slice of bytes of input. - pub fn advance_bytes>(&mut self, bytes: B, host: &mut TerminalHost) { + pub fn advance_bytes>(&mut self, bytes: B, host: &mut dyn TerminalHost) { let bytes = bytes.as_ref(); let mut performer = Performer::new(&mut self.state, host); diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index 3b5412bcf..b03421c27 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -419,7 +419,7 @@ impl TerminalState { fn mouse_single_click_left( &mut self, event: MouseEvent, - host: &mut TerminalHost, + host: &mut dyn TerminalHost, ) -> Result<(), Error> { // Prepare to start a new selection. // We don't form the selection until the mouse drags. @@ -436,7 +436,7 @@ impl TerminalState { fn mouse_double_click_left( &mut self, event: MouseEvent, - host: &mut TerminalHost, + host: &mut dyn TerminalHost, ) -> Result<(), Error> { let y = event.y as ScrollbackOrVisibleRowIndex - self.viewport_offset as ScrollbackOrVisibleRowIndex; @@ -513,7 +513,7 @@ impl TerminalState { fn mouse_triple_click_left( &mut self, event: MouseEvent, - host: &mut TerminalHost, + host: &mut dyn TerminalHost, ) -> Result<(), Error> { let y = event.y as ScrollbackOrVisibleRowIndex - self.viewport_offset as ScrollbackOrVisibleRowIndex; @@ -537,7 +537,7 @@ impl TerminalState { fn mouse_press_left( &mut self, event: MouseEvent, - host: &mut TerminalHost, + host: &mut dyn TerminalHost, ) -> Result<(), Error> { self.current_mouse_button = MouseButton::Left; self.dirty_selection_lines(); @@ -565,7 +565,7 @@ impl TerminalState { fn mouse_release_left( &mut self, event: MouseEvent, - host: &mut TerminalHost, + host: &mut dyn TerminalHost, ) -> Result<(), Error> { // Finish selecting a region, update clipboard self.current_mouse_button = MouseButton::None; @@ -613,7 +613,11 @@ impl TerminalState { Ok(()) } - fn mouse_wheel(&mut self, event: MouseEvent, writer: &mut std::io::Write) -> Result<(), Error> { + fn mouse_wheel( + &mut self, + event: MouseEvent, + writer: &mut dyn std::io::Write, + ) -> Result<(), Error> { let (report_button, scroll_delta, key) = match event.button { MouseButton::WheelUp(amount) => (64, -(amount as i64), KeyCode::UpArrow), MouseButton::WheelDown(amount) => (65, amount as i64, KeyCode::DownArrow), @@ -636,7 +640,7 @@ impl TerminalState { fn mouse_button_press( &mut self, event: MouseEvent, - host: &mut TerminalHost, + host: &mut dyn TerminalHost, ) -> Result<(), Error> { self.current_mouse_button = event.button; if let Some(button) = match event.button { @@ -661,7 +665,7 @@ impl TerminalState { fn mouse_button_release( &mut self, event: MouseEvent, - writer: &mut std::io::Write, + writer: &mut dyn std::io::Write, ) -> Result<(), Error> { if self.current_mouse_button != MouseButton::None { self.current_mouse_button = MouseButton::None; @@ -673,7 +677,11 @@ impl TerminalState { Ok(()) } - fn mouse_move(&mut self, event: MouseEvent, writer: &mut std::io::Write) -> Result<(), Error> { + fn mouse_move( + &mut self, + event: MouseEvent, + writer: &mut dyn std::io::Write, + ) -> Result<(), Error> { if let Some(button) = match (self.current_mouse_button, self.button_event_mouse) { (MouseButton::Left, true) => Some(32), (MouseButton::Middle, true) => Some(33), @@ -690,7 +698,7 @@ impl TerminalState { pub fn mouse_event( &mut self, mut event: MouseEvent, - host: &mut TerminalHost, + host: &mut dyn TerminalHost, ) -> Result<(), Error> { // Clamp the mouse coordinates to the size of the model. // This situation can trigger for example when the @@ -793,7 +801,7 @@ impl TerminalState { /// Send text to the terminal that is the result of pasting. /// If bracketed paste mode is enabled, the paste is enclosed /// in the bracketing, otherwise it is fed to the pty as-is. - pub fn send_paste(&mut self, text: &str, writer: &mut std::io::Write) -> Result<(), Error> { + pub fn send_paste(&mut self, text: &str, writer: &mut dyn std::io::Write) -> Result<(), Error> { if self.bracketed_paste { let buf = format!("\x1b[200~{}\x1b[201~", text); writer.write_all(buf.as_bytes())?; @@ -811,7 +819,7 @@ impl TerminalState { &mut self, key: KeyCode, mods: KeyModifiers, - writer: &mut std::io::Write, + writer: &mut dyn std::io::Write, ) -> Result<(), Error> { const CTRL: KeyModifiers = KeyModifiers::CTRL; const SHIFT: KeyModifiers = KeyModifiers::SHIFT; @@ -1358,7 +1366,7 @@ impl TerminalState { */ } - fn perform_device(&mut self, dev: Device, host: &mut TerminalHost) { + fn perform_device(&mut self, dev: Device, host: &mut dyn TerminalHost) { match dev { Device::DeviceAttributes(a) => error!("unhandled: {:?}", a), Device::SoftReset => { @@ -1533,7 +1541,7 @@ impl TerminalState { checksum } - fn perform_csi_window(&mut self, window: Window, host: &mut TerminalHost) { + fn perform_csi_window(&mut self, window: Window, host: &mut dyn TerminalHost) { match window { Window::ReportTextAreaSizeCells => { let screen = self.screen(); @@ -1701,7 +1709,7 @@ impl TerminalState { } } - fn perform_csi_cursor(&mut self, cursor: Cursor, host: &mut TerminalHost) { + fn perform_csi_cursor(&mut self, cursor: Cursor, host: &mut dyn TerminalHost) { match cursor { Cursor::SetTopAndBottomMargins { top, bottom } => { let rows = self.screen().physical_rows; @@ -1863,7 +1871,7 @@ impl TerminalState { /// the terminal state and the embedding/host terminal interface pub(crate) struct Performer<'a> { pub state: &'a mut TerminalState, - pub host: &'a mut TerminalHost, + pub host: &'a mut dyn TerminalHost, print: Option, } @@ -1888,7 +1896,7 @@ impl<'a> Drop for Performer<'a> { } impl<'a> Performer<'a> { - pub fn new(state: &'a mut TerminalState, host: &'a mut TerminalHost) -> Self { + pub fn new(state: &'a mut TerminalState, host: &'a mut dyn TerminalHost) -> Self { Self { state, host, diff --git a/term/src/test/mod.rs b/term/src/test/mod.rs index 08f5ed3fb..172534e66 100644 --- a/term/src/test/mod.rs +++ b/term/src/test/mod.rs @@ -16,7 +16,7 @@ use termwiz::escape::{OneBased, OperatingSystemCommand, CSI}; struct TestHost { title: String, - clip: Arc, + clip: Arc, } impl TestHost { @@ -70,11 +70,11 @@ impl TerminalHost for TestHost { self.title = title.into(); } - fn get_clipboard(&mut self) -> Fallible> { + fn get_clipboard(&mut self) -> Fallible> { Ok(Arc::clone(&self.clip)) } - fn writer(&mut self) -> &mut std::io::Write { + fn writer(&mut self) -> &mut dyn std::io::Write { self } diff --git a/termwiz/examples/line_editor.rs b/termwiz/examples/line_editor.rs index e4f8ceac8..335900492 100644 --- a/termwiz/examples/line_editor.rs +++ b/termwiz/examples/line_editor.rs @@ -24,7 +24,7 @@ impl LineEditorHost for Host { ] } - fn history(&mut self) -> &mut History { + fn history(&mut self) -> &mut dyn History { &mut self.history } diff --git a/termwiz/src/lineedit/host.rs b/termwiz/src/lineedit/host.rs index f683e53a3..983ecb4a6 100644 --- a/termwiz/src/lineedit/host.rs +++ b/termwiz/src/lineedit/host.rs @@ -62,7 +62,7 @@ pub trait LineEditorHost { } /// Returns the history implementation - fn history(&mut self) -> &mut History; + fn history(&mut self) -> &mut dyn History; /// Tab completion support. /// The line and current cursor position are provided and it is up to the @@ -91,7 +91,7 @@ pub struct NopLineEditorHost { history: BasicHistory, } impl LineEditorHost for NopLineEditorHost { - fn history(&mut self) -> &mut History { + fn history(&mut self) -> &mut dyn History { &mut self.history } } diff --git a/termwiz/src/lineedit/mod.rs b/termwiz/src/lineedit/mod.rs index 303e8abbf..cad7357d7 100644 --- a/termwiz/src/lineedit/mod.rs +++ b/termwiz/src/lineedit/mod.rs @@ -144,7 +144,7 @@ impl LineEditor { } } - fn render(&mut self, host: &mut LineEditorHost) -> Fallible<()> { + fn render(&mut self, host: &mut dyn LineEditorHost) -> Fallible<()> { let mut changes = vec![ Change::CursorPosition { x: Position::Absolute(0), @@ -192,7 +192,7 @@ impl LineEditor { /// Control is not returned to the caller until a line has been /// accepted, or until an error is detected. /// Returns Ok(None) if the editor was cancelled eg: via CTRL-C. - pub fn read_line(&mut self, host: &mut LineEditorHost) -> Fallible> { + pub fn read_line(&mut self, host: &mut dyn LineEditorHost) -> Fallible> { self.terminal.set_raw_mode()?; let res = self.read_line_impl(host); self.terminal.set_cooked_mode()?; @@ -450,7 +450,7 @@ impl LineEditor { self.completion = None; } - fn read_line_impl(&mut self, host: &mut LineEditorHost) -> Fallible> { + fn read_line_impl(&mut self, host: &mut dyn LineEditorHost) -> Fallible> { self.line.clear(); self.cursor = 0; self.history_pos = None; diff --git a/termwiz/src/widgets/mod.rs b/termwiz/src/widgets/mod.rs index 3f341ac04..1f1a022a5 100644 --- a/termwiz/src/widgets/mod.rs +++ b/termwiz/src/widgets/mod.rs @@ -140,7 +140,7 @@ struct RenderData<'widget> { surface: Surface, cursor: CursorShapeAndPosition, coordinates: ParentRelativeCoords, - widget: Box, + widget: Box, } #[derive(Default)] diff --git a/window/examples/basic.rs b/window/examples/basic.rs index a3b1c969c..a76e4e90e 100644 --- a/window/examples/basic.rs +++ b/window/examples/basic.rs @@ -96,7 +96,7 @@ fn spawn_window() -> Fallible<()> { )?; win.show(); - win.apply(|myself, win| { + win.apply(|myself, _win| { if let Some(myself) = myself.downcast_ref::() { eprintln!( "got myself; allow_close={}, cursor_pos:{:?}",