diff options
author | Akshay <nerdy@peppe.rs> | 2022-01-15 10:38:31 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-15 10:38:31 +0530 |
commit | 43c995e96cd1b7fcfb65810749849f3af039a839 (patch) | |
tree | c997c6895c094a071b633ddf77086b128cbb2cb1 /src | |
parent | 27092d042cfdf656e8a13d4c6fa4a2c1275974ec (diff) | |
parent | 00e8147473c01767a000070b9dada5c965ff92a0 (diff) |
Update to cursive 0.17
Diffstat (limited to 'src')
-rw-r--r-- | src/app/impl_view.rs | 6 | ||||
-rw-r--r-- | src/habit/traits.rs | 5 | ||||
-rw-r--r-- | src/views.rs | 10 |
3 files changed, 11 insertions, 10 deletions
diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs index c369d8f..c0f1eb4 100644 --- a/src/app/impl_view.rs +++ b/src/app/impl_view.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use cursive::direction::{Absolute, Direction}; use cursive::event::{Event, EventResult, Key}; use cursive::theme::Color; -use cursive::view::View; +use cursive::view::{CannotFocus, View}; use cursive::{Printer, Vec2}; use notify::DebouncedEvent; @@ -53,8 +53,8 @@ impl View for App { Vec2::new(width, height + 2) } - fn take_focus(&mut self, _: Direction) -> bool { - false + fn take_focus(&mut self, _: Direction) -> Result<EventResult, CannotFocus> { + Err(CannotFocus) } fn on_event(&mut self, e: Event) -> EventResult { diff --git a/src/habit/traits.rs b/src/habit/traits.rs index 54ec9e1..b17e5d2 100644 --- a/src/habit/traits.rs +++ b/src/habit/traits.rs @@ -1,6 +1,7 @@ use chrono::NaiveDate; use cursive::direction::Direction; use cursive::event::{Event, EventResult}; +use cursive::view::CannotFocus; use cursive::{Printer, Vec2}; use typetag; @@ -38,7 +39,7 @@ pub trait HabitWrapper: erased_serde::Serialize { fn on_event(&mut self, event: Event) -> EventResult; fn remaining(&self, date: NaiveDate) -> u32; fn required_size(&mut self, _: Vec2) -> Vec2; - fn take_focus(&mut self, _: Direction) -> bool; + fn take_focus(&mut self, _: Direction) -> Result<EventResult, CannotFocus>; fn inner_data_ref(&self) -> &InnerData; fn inner_data_mut_ref(&mut self) -> &mut InnerData; @@ -60,7 +61,7 @@ macro_rules! auto_habit_impl { fn required_size(&mut self, x: Vec2) -> Vec2 { ShadowView::required_size(self, x) } - fn take_focus(&mut self, d: Direction) -> bool { + fn take_focus(&mut self, d: Direction) -> Result<EventResult, CannotFocus> { ShadowView::take_focus(self, d) } diff --git a/src/views.rs b/src/views.rs index ca4f757..1bda8a8 100644 --- a/src/views.rs +++ b/src/views.rs @@ -1,7 +1,7 @@ use cursive::direction::Direction; use cursive::event::{Event, EventResult, Key}; use cursive::theme::{ColorStyle, Effect, Style}; -use cursive::view::View; +use cursive::view::{CannotFocus, View}; use cursive::{Printer, Vec2}; use chrono::prelude::*; @@ -16,7 +16,7 @@ use crate::CONFIGURATION; pub trait ShadowView { fn draw(&self, printer: &Printer); fn required_size(&mut self, _: Vec2) -> Vec2; - fn take_focus(&mut self, _: Direction) -> bool; + fn take_focus(&mut self, _: Direction) -> Result<EventResult, CannotFocus>; fn on_event(&mut self, e: Event) -> EventResult; } @@ -151,8 +151,8 @@ where (25, 6).into() } - fn take_focus(&mut self, _: Direction) -> bool { - true + fn take_focus(&mut self, _: Direction) -> Result<EventResult, CannotFocus> { + Ok(EventResult::consumed()) } fn on_event(&mut self, e: Event) -> EventResult { @@ -183,7 +183,7 @@ macro_rules! auto_view_impl { fn required_size(&mut self, x: Vec2) -> Vec2 { ShadowView::required_size(self, x) } - fn take_focus(&mut self, d: Direction) -> bool { + fn take_focus(&mut self, d: Direction) -> Result<EventResult, CannotFocus> { ShadowView::take_focus(self, d) } fn on_event(&mut self, e: Event) -> EventResult { |