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).
This commit is contained in:
Alexandre Bury 2017-10-08 16:02:43 -07:00
parent c7f995fd72
commit 7df4b06ef8
5 changed files with 5 additions and 5 deletions

View File

@ -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() {

View File

@ -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?

View File

@ -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() {

View File

@ -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);

View File

@ -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;