From 7df4b06ef81e15883ca77e16e92e82d828f1e3ae Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Sun, 8 Oct 2017 16:02:43 -0700 Subject: [PATCH] Backend::poll_event now takes &mut self To manage an internal buffer, in case backend events and cursive events don't match 1-for-1. Planned uses: mouse support (translate click into Press+Release). --- src/backend/blt.rs | 2 +- src/backend/curses/n.rs | 2 +- src/backend/curses/pan.rs | 2 +- src/backend/mod.rs | 2 +- src/backend/termion.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/blt.rs b/src/backend/blt.rs index de0a137..20f0583 100644 --- a/src/backend/blt.rs +++ b/src/backend/blt.rs @@ -79,7 +79,7 @@ impl backend::Backend for Concrete { // TODO: unsupported } - fn poll_event(&self) -> Event { + fn poll_event(&mut self) -> Event { // TODO: we could add backend-specific controls here. // Ex: ctrl+mouse wheel cause window cellsize to change if let Some(ev) = terminal::wait_event() { diff --git a/src/backend/curses/n.rs b/src/backend/curses/n.rs index fc0e963..20538a7 100644 --- a/src/backend/curses/n.rs +++ b/src/backend/curses/n.rs @@ -139,7 +139,7 @@ impl backend::Backend for Concrete { ncurses::mvaddstr(y as i32, x as i32, text); } - fn poll_event(&self) -> Event { + fn poll_event(&mut self) -> Event { let ch: i32 = ncurses::getch(); // Is it a UTF-8 starting point? diff --git a/src/backend/curses/pan.rs b/src/backend/curses/pan.rs index 3f77378..0866b86 100644 --- a/src/backend/curses/pan.rs +++ b/src/backend/curses/pan.rs @@ -136,7 +136,7 @@ impl backend::Backend for Concrete { self.window.mvaddstr(y as i32, x as i32, text); } - fn poll_event(&self) -> Event { + fn poll_event(&mut self) -> Event { // TODO: there seems to not be any indication // of Ctrl/Alt/Shift in these :v if let Some(ev) = self.window.getch() { diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 41ff8a2..f5619f8 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -27,7 +27,7 @@ pub trait Backend { fn screen_size(&self) -> (usize, usize); /// Main input method - fn poll_event(&self) -> event::Event; + fn poll_event(&mut self) -> event::Event; /// Main method used for printing fn print_at(&self, (usize, usize), &str); diff --git a/src/backend/termion.rs b/src/backend/termion.rs index 7284a43..60943fb 100644 --- a/src/backend/termion.rs +++ b/src/backend/termion.rs @@ -144,7 +144,7 @@ impl backend::Backend for Concrete { self.timeout = Some(1000 / fps as u32); } - fn poll_event(&self) -> Event { + fn poll_event(&mut self) -> Event { let input = &self.input; let resize = &self.resize;