mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Fix clippy warnings
This commit is contained in:
parent
91fdf96066
commit
bd5c45ac0e
@ -323,8 +323,8 @@ impl Color {
|
|||||||
3 => (1, 17),
|
3 => (1, 17),
|
||||||
_ => panic!("Cannot parse color: {}", value),
|
_ => panic!("Cannot parse color: {}", value),
|
||||||
};
|
};
|
||||||
let r = load_hex(&value[0 * l..1 * l]) * multiplier;
|
let r = load_hex(&value[0..l]) * multiplier;
|
||||||
let g = load_hex(&value[1 * l..2 * l]) * multiplier;
|
let g = load_hex(&value[l..2 * l]) * multiplier;
|
||||||
let b = load_hex(&value[2 * l..3 * l]) * multiplier;
|
let b = load_hex(&value[2 * l..3 * l]) * multiplier;
|
||||||
Some(Color::Rgb(r as u8, g as u8, b as u8))
|
Some(Color::Rgb(r as u8, g as u8, b as u8))
|
||||||
} else if value.len() == 3 {
|
} else if value.len() == 3 {
|
||||||
|
@ -2,7 +2,7 @@ use std::cmp::max;
|
|||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
use Cursive;
|
use Cursive;
|
||||||
use direction;
|
use direction::Direction;
|
||||||
use align::*;
|
use align::*;
|
||||||
use event::*;
|
use event::*;
|
||||||
use theme::ColorStyle;
|
use theme::ColorStyle;
|
||||||
@ -249,7 +249,7 @@ impl View for Dialog {
|
|||||||
// Up goes back to the content
|
// Up goes back to the content
|
||||||
Event::Key(Key::Up) => {
|
Event::Key(Key::Up) => {
|
||||||
if self.content
|
if self.content
|
||||||
.take_focus(direction::Direction::down()) {
|
.take_focus(Direction::down()) {
|
||||||
self.focus = Focus::Content;
|
self.focus = Focus::Content;
|
||||||
EventResult::Consumed(None)
|
EventResult::Consumed(None)
|
||||||
} else {
|
} else {
|
||||||
@ -258,7 +258,7 @@ impl View for Dialog {
|
|||||||
}
|
}
|
||||||
Event::Shift(Key::Tab) => {
|
Event::Shift(Key::Tab) => {
|
||||||
if self.content
|
if self.content
|
||||||
.take_focus(direction::Direction::back()) {
|
.take_focus(Direction::back()) {
|
||||||
self.focus = Focus::Content;
|
self.focus = Focus::Content;
|
||||||
EventResult::Consumed(None)
|
EventResult::Consumed(None)
|
||||||
} else {
|
} else {
|
||||||
@ -267,13 +267,12 @@ impl View for Dialog {
|
|||||||
}
|
}
|
||||||
Event::Key(Key::Tab) => {
|
Event::Key(Key::Tab) => {
|
||||||
if self.content
|
if self.content
|
||||||
.take_focus(direction::Direction::front()) {
|
.take_focus(Direction::front()) {
|
||||||
self.focus = Focus::Content;
|
self.focus = Focus::Content;
|
||||||
EventResult::Consumed(None)
|
EventResult::Consumed(None)
|
||||||
} else {
|
} else {
|
||||||
EventResult::Ignored
|
EventResult::Ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Left and Right move to other buttons
|
// Left and Right move to other buttons
|
||||||
Event::Key(Key::Right) if i + 1 <
|
Event::Key(Key::Right) if i + 1 <
|
||||||
@ -295,7 +294,7 @@ impl View for Dialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_focus(&mut self, source: direction::Direction) -> bool {
|
fn take_focus(&mut self, source: Direction) -> bool {
|
||||||
// Dialogs aren't meant to be used in layouts, so...
|
// Dialogs aren't meant to be used in layouts, so...
|
||||||
// Let's be super lazy and not even care about the focus source.
|
// Let's be super lazy and not even care about the focus source.
|
||||||
if self.content.take_focus(source) {
|
if self.content.take_focus(source) {
|
||||||
|
@ -29,13 +29,9 @@ impl Child {
|
|||||||
self.size
|
self.size
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_ref(&self) -> &View {
|
fn as_view(&self) -> &View {
|
||||||
&*self.view
|
&*self.view
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_mut(&mut self) -> &mut View {
|
|
||||||
&mut *self.view
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LinearLayout {
|
impl LinearLayout {
|
||||||
@ -106,14 +102,14 @@ impl LinearLayout {
|
|||||||
fn children_are_sleeping(&self) -> bool {
|
fn children_are_sleeping(&self) -> bool {
|
||||||
!self.children
|
!self.children
|
||||||
.iter()
|
.iter()
|
||||||
.map(Child::as_ref)
|
.map(Child::as_view)
|
||||||
.any(View::needs_relayout)
|
.any(View::needs_relayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a cyclic mutable iterator starting with the child in focus
|
/// Returns a cyclic mutable iterator starting with the child in focus
|
||||||
fn iter_mut<'a>(&'a mut self, from_focus: bool,
|
fn iter_mut<'a>(&'a mut self, from_focus: bool,
|
||||||
direction: direction::Relative)
|
direction: direction::Relative)
|
||||||
-> Box<Iterator<Item = (usize, &'a mut Child)> + 'a> {
|
-> Box<Iterator<Item = (usize, &mut Child)> + 'a> {
|
||||||
|
|
||||||
match direction {
|
match direction {
|
||||||
direction::Relative::Front => {
|
direction::Relative::Front => {
|
||||||
@ -154,35 +150,6 @@ impl LinearLayout {
|
|||||||
self.focus = i;
|
self.focus = i;
|
||||||
EventResult::Consumed(None)
|
EventResult::Consumed(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn focus_prev(&mut self) -> EventResult {
|
|
||||||
if let Some(i) = self.children[..self.focus]
|
|
||||||
.iter_mut()
|
|
||||||
.rev()
|
|
||||||
.map(Child::as_mut)
|
|
||||||
.position(|v| v.take_focus(direction::Direction::back())) {
|
|
||||||
|
|
||||||
// We're looking at the list in reverse
|
|
||||||
self.focus -= i + 1;
|
|
||||||
EventResult::Consumed(None)
|
|
||||||
} else {
|
|
||||||
EventResult::Ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn focus_next(&mut self) -> EventResult {
|
|
||||||
if let Some(i) = self.children[(self.focus + 1)..]
|
|
||||||
.iter_mut()
|
|
||||||
.rev()
|
|
||||||
.map(Child::as_mut)
|
|
||||||
.position(|v| v.take_focus(direction::Direction::front())) {
|
|
||||||
// Our slice doesn't start at 0
|
|
||||||
self.focus += i + 1;
|
|
||||||
EventResult::Consumed(None)
|
|
||||||
} else {
|
|
||||||
EventResult::Ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_focus((i, child): (usize, &mut Child), source: direction::Direction)
|
fn try_focus((i, child): (usize, &mut Child), source: direction::Direction)
|
||||||
|
Loading…
Reference in New Issue
Block a user