fix clippy warnings

pull/32/head
Takayuki Maeda 3 years ago
parent b64e43bbc9
commit 58a0485742

@ -1,7 +1,5 @@
use crate::clipboard::Clipboard;
use crate::components::{
CommandInfo, CommandText, Component as _, DrawableComponent as _, EventState,
};
use crate::components::{CommandInfo, Component as _, DrawableComponent as _, EventState};
use crate::event::Key;
use crate::utils::{MySqlPool, Pool};
use crate::{
@ -121,37 +119,13 @@ impl App {
}
fn commands(&self) -> Vec<CommandInfo> {
let mut res = Vec::new();
res.push(CommandInfo::new(
crate::components::command::move_left("h"),
true,
true,
));
res.push(CommandInfo::new(
crate::components::command::move_down("j"),
true,
true,
));
res.push(CommandInfo::new(
crate::components::command::move_up("k"),
true,
true,
));
res.push(CommandInfo::new(
crate::components::command::move_right("l"),
true,
true,
));
res.push(CommandInfo::new(
crate::components::command::filter("/"),
true,
true,
));
let res = vec![
CommandInfo::new(crate::components::command::move_left("h"), true, true),
CommandInfo::new(crate::components::command::move_down("j"), true, true),
CommandInfo::new(crate::components::command::move_up("k"), true, true),
CommandInfo::new(crate::components::command::move_right("l"), true, true),
CommandInfo::new(crate::components::command::filter("/"), true, true),
];
res
}

@ -14,7 +14,6 @@ use tui::{
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Style},
symbols::line::HORIZONTAL,
text::Span,
widgets::{Block, Borders, Paragraph},
Frame,
@ -170,15 +169,9 @@ impl DatabasesComponent {
let items = tree
.iterate(self.scroll.get_top(), tree_height)
.map(|(item, selected)| Self::tree_item_to_span(item.clone(), selected, area.width))
.collect::<Vec<Span>>();
.map(|(item, selected)| Self::tree_item_to_span(item.clone(), selected, area.width));
draw_list_block(
f,
chunks[1],
Block::default().borders(Borders::NONE),
items.into_iter(),
);
draw_list_block(f, chunks[1], Block::default().borders(Borders::NONE), items);
self.scroll.draw(f, area);
if let FocusBlock::Filter = self.focus_block {
f.set_cursor(area.x + self.input_cursor_position + 1, area.y + 1)

@ -123,7 +123,7 @@ impl HelpComponent {
for command_info in group {
txt.push(Spans::from(Span::styled(
format!("{}", command_info.text.name),
command_info.text.name.to_string(),
Style::default(),
)));
}

@ -29,22 +29,6 @@ use std::convert::TryInto;
use tui::{backend::Backend, layout::Rect, Frame};
use unicode_width::UnicodeWidthChar;
#[derive(Copy, Clone)]
pub enum ScrollType {
Up,
Down,
Home,
End,
PageUp,
PageDown,
}
#[derive(Copy, Clone)]
pub enum Direction {
Up,
Down,
}
#[derive(PartialEq)]
pub enum EventState {
Consumed,

@ -1,4 +1,4 @@
use crate::{components::ScrollType, ui::scrollbar::draw_scrollbar};
use crate::ui::scrollbar::draw_scrollbar;
use std::cell::Cell;
use tui::{backend::Backend, layout::Rect, Frame};
@ -23,29 +23,6 @@ impl VerticalScroll {
self.top.set(0);
}
pub fn _move_top(&self, move_type: ScrollType) -> bool {
let old = self.top.get();
let max = self.max_top.get();
let new_scroll_top = match move_type {
ScrollType::Down => old.saturating_add(1),
ScrollType::Up => old.saturating_sub(1),
ScrollType::Home => 0,
ScrollType::End => max,
_ => old,
};
let new_scroll_top = new_scroll_top.clamp(0, max);
if new_scroll_top == old {
return false;
}
self.top.set(new_scroll_top);
true
}
pub fn update(&self, selection: usize, selection_max: usize, visual_height: usize) -> usize {
let new_top = calc_scroll_top(self.get_top(), visual_height, selection, selection_max);
self.top.set(new_top);
@ -60,10 +37,6 @@ impl VerticalScroll {
new_top
}
pub fn _update_no_selection(&self, line_count: usize, visual_height: usize) -> usize {
self.update(self.get_top(), line_count, visual_height)
}
pub fn draw<B: Backend>(&self, f: &mut Frame<B>, r: Rect) {
draw_scrollbar(f, r, self.max_top.get(), self.top.get());
}

Loading…
Cancel
Save