Clippy fixes
This commit is contained in:
@@ -252,7 +252,8 @@ impl CommandManager {
|
|||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
/* handle default commands
|
/*
|
||||||
|
TODO: handle default commands
|
||||||
else if let Some(callback) = self.callbacks.get(cmd) {
|
else if let Some(callback) = self.callbacks.get(cmd) {
|
||||||
callback.as_ref().map(|cb| cb(s, args)).unwrap_or(Ok(None))
|
callback.as_ref().map(|cb| cb(s, args)).unwrap_or(Ok(None))
|
||||||
} */
|
} */
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ use cursive::{Cursive, Printer};
|
|||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use command::Command;
|
use command::Command;
|
||||||
use command::Command::Focus;
|
|
||||||
use commands::CommandResult;
|
use commands::CommandResult;
|
||||||
use events;
|
use events;
|
||||||
use traits::{IntoBoxedViewExt, ViewExt};
|
use traits::{IntoBoxedViewExt, ViewExt};
|
||||||
@@ -207,6 +206,25 @@ impl View for Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn layout(&mut self, size: Vec2) {
|
||||||
|
self.last_size = size;
|
||||||
|
|
||||||
|
self.statusbar.layout(Vec2::new(size.x, 2));
|
||||||
|
|
||||||
|
self.cmdline.layout(Vec2::new(size.x, 1));
|
||||||
|
|
||||||
|
if let Some(screen) = self.get_current_screen_mut() {
|
||||||
|
screen.view.layout(Vec2::new(size.x, size.y - 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
// the focus view has changed, let the views know so they can redraw
|
||||||
|
// their items
|
||||||
|
if self.screenchange {
|
||||||
|
debug!("layout: new screen selected: {:?}", self.focus);
|
||||||
|
self.screenchange = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn required_size(&mut self, constraint: Vec2) -> Vec2 {
|
fn required_size(&mut self, constraint: Vec2) -> Vec2 {
|
||||||
Vec2::new(constraint.x, constraint.y)
|
Vec2::new(constraint.x, constraint.y)
|
||||||
}
|
}
|
||||||
@@ -246,25 +264,6 @@ impl View for Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout(&mut self, size: Vec2) {
|
|
||||||
self.last_size = size;
|
|
||||||
|
|
||||||
self.statusbar.layout(Vec2::new(size.x, 2));
|
|
||||||
|
|
||||||
self.cmdline.layout(Vec2::new(size.x, 1));
|
|
||||||
|
|
||||||
if let Some(screen) = self.get_current_screen_mut() {
|
|
||||||
screen.view.layout(Vec2::new(size.x, size.y - 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
// the focus view has changed, let the views know so they can redraw
|
|
||||||
// their items
|
|
||||||
if self.screenchange {
|
|
||||||
debug!("layout: new screen selected: {:?}", self.focus);
|
|
||||||
self.screenchange = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn call_on_any<'a>(&mut self, s: &Selector, c: AnyCb<'a>) {
|
fn call_on_any<'a>(&mut self, s: &Selector, c: AnyCb<'a>) {
|
||||||
if let Some(screen) = self.get_current_screen_mut() {
|
if let Some(screen) = self.get_current_screen_mut() {
|
||||||
screen.view.call_on_any(s, c);
|
screen.view.call_on_any(s, c);
|
||||||
|
|||||||
@@ -54,14 +54,11 @@ impl ViewWrapper for PlaylistsView {
|
|||||||
|
|
||||||
impl ViewExt for PlaylistsView {
|
impl ViewExt for PlaylistsView {
|
||||||
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
||||||
match cmd {
|
if let Command::Delete = cmd {
|
||||||
Command::Delete => {
|
if let Some(dialog) = self.delete_dialog() {
|
||||||
if let Some(dialog) = self.delete_dialog() {
|
s.add_layer(dialog);
|
||||||
s.add_layer(dialog);
|
|
||||||
}
|
|
||||||
return Ok(CommandResult::Consumed(None));
|
|
||||||
}
|
}
|
||||||
_ => {}
|
return Ok(CommandResult::Consumed(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.list.on_command(s, cmd)
|
self.list.on_command(s, cmd)
|
||||||
|
|||||||
@@ -412,6 +412,14 @@ impl View for SearchView {
|
|||||||
self.tabs.layout(Vec2::new(size.x, size.y - 1));
|
self.tabs.layout(Vec2::new(size.x, size.y - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn on_event(&mut self, event: Event) -> EventResult {
|
||||||
|
if self.edit_focused {
|
||||||
|
self.edit.on_event(event)
|
||||||
|
} else {
|
||||||
|
self.tabs.on_event(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn call_on_any<'a>(&mut self, selector: &Selector<'_>, mut callback: AnyCb<'a>) {
|
fn call_on_any<'a>(&mut self, selector: &Selector<'_>, mut callback: AnyCb<'a>) {
|
||||||
self.edit.call_on_any(selector, Box::new(|v| callback(v)));
|
self.edit.call_on_any(selector, Box::new(|v| callback(v)));
|
||||||
self.tabs.call_on_any(selector, Box::new(|v| callback(v)));
|
self.tabs.call_on_any(selector, Box::new(|v| callback(v)));
|
||||||
@@ -425,21 +433,13 @@ impl View for SearchView {
|
|||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&mut self, event: Event) -> EventResult {
|
|
||||||
if self.edit_focused {
|
|
||||||
self.edit.on_event(event)
|
|
||||||
} else {
|
|
||||||
self.tabs.on_event(event)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ViewExt for SearchView {
|
impl ViewExt for SearchView {
|
||||||
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
||||||
match cmd {
|
match cmd {
|
||||||
Command::Search(query) => self.run_search(query.to_string()),
|
Command::Search(query) => self.run_search(query.to_string()),
|
||||||
Command::Focus(view) => {
|
Command::Focus(_) => {
|
||||||
self.edit_focused = true;
|
self.edit_focused = true;
|
||||||
self.clear();
|
self.clear();
|
||||||
return Ok(CommandResult::Consumed(None));
|
return Ok(CommandResult::Consumed(None));
|
||||||
@@ -454,8 +454,8 @@ impl ViewExt for SearchView {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let CommandResult::Ignored = result {
|
if let CommandResult::Ignored = result {
|
||||||
match cmd {
|
if let Command::Move(mode, _) = cmd {
|
||||||
Command::Move(mode, amount) => match mode {
|
match mode {
|
||||||
MoveMode::Up if !self.edit_focused => {
|
MoveMode::Up if !self.edit_focused => {
|
||||||
self.edit_focused = true;
|
self.edit_focused = true;
|
||||||
return Ok(CommandResult::Consumed(None));
|
return Ok(CommandResult::Consumed(None));
|
||||||
@@ -465,8 +465,7 @@ impl ViewExt for SearchView {
|
|||||||
return Ok(CommandResult::Consumed(None));
|
return Ok(CommandResult::Consumed(None));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,28 +104,25 @@ impl View for TabView {
|
|||||||
|
|
||||||
impl ViewExt for TabView {
|
impl ViewExt for TabView {
|
||||||
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
||||||
match cmd {
|
if let Command::Move(mode, amount) = cmd {
|
||||||
Command::Move(mode, amount) => {
|
let amount = match amount {
|
||||||
let amount = match amount {
|
Some(amount) => *amount,
|
||||||
Some(amount) => *amount,
|
_ => 1,
|
||||||
_ => 1,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let len = self.tabs.len();
|
let len = self.tabs.len();
|
||||||
|
|
||||||
match mode {
|
match mode {
|
||||||
MoveMode::Left if self.selected > 0 => {
|
MoveMode::Left if self.selected > 0 => {
|
||||||
self.move_focus(-(amount as i32));
|
self.move_focus(-(amount as i32));
|
||||||
return Ok(CommandResult::Consumed(None));
|
return Ok(CommandResult::Consumed(None));
|
||||||
}
|
|
||||||
MoveMode::Right if self.selected < len - 1 => {
|
|
||||||
self.move_focus(amount as i32);
|
|
||||||
return Ok(CommandResult::Consumed(None));
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
MoveMode::Right if self.selected < len - 1 => {
|
||||||
|
self.move_focus(amount as i32);
|
||||||
|
return Ok(CommandResult::Consumed(None));
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(tab) = self.tabs.get_mut(self.selected) {
|
if let Some(tab) = self.tabs.get_mut(self.selected) {
|
||||||
|
|||||||
Reference in New Issue
Block a user