Compare commits

..

View file

@ -44,8 +44,6 @@ struct State {
columns: usize,
key: usize,
error: Option<String>,
}
@ -53,10 +51,9 @@ impl State {
fn new() -> (Self, Task<Message>) {
(
Self {
images: BTreeMap::new(),
columns: 3,
key: 0,
error: None,
images: BTreeMap::new(),
},
Task::done(Message::OpenPath(Some(
env::args()
@ -110,7 +107,7 @@ impl State {
.arg(path)
.spawn()
.map_err(|e| e.to_string())
.err();
.err()
}
Message::OpenPath(opt_path) => {
@ -120,7 +117,6 @@ impl State {
};
if let Some(path) = opt_path {
self.key += 1;
self.open_path(path);
}
}
@ -142,31 +138,6 @@ impl State {
);
}
keyboard::Key::Character("j")
| keyboard::Key::Named(
keyboard::key::Named::ArrowDown | keyboard::key::Named::PageDown,
) => {
return widget::operation::scroll_by(
"main",
widget::operation::AbsoluteOffset {
x: 0.,
y: if modifiers.shift() { 100. } else { 30. },
},
);
}
keyboard::Key::Character("k")
| keyboard::Key::Named(
keyboard::key::Named::ArrowUp | keyboard::key::Named::PageUp,
) => {
return widget::operation::scroll_by(
"main",
widget::operation::AbsoluteOffset {
x: 0.,
y: if modifiers.shift() { -100. } else { -30. },
},
);
}
keyboard::Key::Character("=" | "+") => {
self.columns = (self.columns + 1).clamp(1, 10)
}
@ -193,7 +164,6 @@ impl State {
|| Element::from(widget::space()),
|handle| widget::image(handle).into(),
))
.key(self.key)
.anticipate(2000)
.on_show(|_size| Message::LoadImage(path.clone()))
.on_hide(Message::UnloadImage(path.clone())),
@ -215,7 +185,6 @@ impl State {
}))
.columns(self.columns),
)
.id("main")
.height(Length::Fill)
.into(),
self.error.as_ref().map_or_else(