Compare commits
1 changed files with 2 additions and 33 deletions
|
|
@ -44,8 +44,6 @@ struct State {
|
||||||
|
|
||||||
columns: usize,
|
columns: usize,
|
||||||
|
|
||||||
key: usize,
|
|
||||||
|
|
||||||
error: Option<String>,
|
error: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,10 +51,9 @@ impl State {
|
||||||
fn new() -> (Self, Task<Message>) {
|
fn new() -> (Self, Task<Message>) {
|
||||||
(
|
(
|
||||||
Self {
|
Self {
|
||||||
images: BTreeMap::new(),
|
|
||||||
columns: 3,
|
columns: 3,
|
||||||
key: 0,
|
|
||||||
error: None,
|
error: None,
|
||||||
|
images: BTreeMap::new(),
|
||||||
},
|
},
|
||||||
Task::done(Message::OpenPath(Some(
|
Task::done(Message::OpenPath(Some(
|
||||||
env::args()
|
env::args()
|
||||||
|
|
@ -110,7 +107,7 @@ impl State {
|
||||||
.arg(path)
|
.arg(path)
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
.err();
|
.err()
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::OpenPath(opt_path) => {
|
Message::OpenPath(opt_path) => {
|
||||||
|
|
@ -120,7 +117,6 @@ impl State {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(path) = opt_path {
|
if let Some(path) = opt_path {
|
||||||
self.key += 1;
|
|
||||||
self.open_path(path);
|
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("=" | "+") => {
|
keyboard::Key::Character("=" | "+") => {
|
||||||
self.columns = (self.columns + 1).clamp(1, 10)
|
self.columns = (self.columns + 1).clamp(1, 10)
|
||||||
}
|
}
|
||||||
|
|
@ -193,7 +164,6 @@ impl State {
|
||||||
|| Element::from(widget::space()),
|
|| Element::from(widget::space()),
|
||||||
|handle| widget::image(handle).into(),
|
|handle| widget::image(handle).into(),
|
||||||
))
|
))
|
||||||
.key(self.key)
|
|
||||||
.anticipate(2000)
|
.anticipate(2000)
|
||||||
.on_show(|_size| Message::LoadImage(path.clone()))
|
.on_show(|_size| Message::LoadImage(path.clone()))
|
||||||
.on_hide(Message::UnloadImage(path.clone())),
|
.on_hide(Message::UnloadImage(path.clone())),
|
||||||
|
|
@ -215,7 +185,6 @@ impl State {
|
||||||
}))
|
}))
|
||||||
.columns(self.columns),
|
.columns(self.columns),
|
||||||
)
|
)
|
||||||
.id("main")
|
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
.into(),
|
.into(),
|
||||||
self.error.as_ref().map_or_else(
|
self.error.as_ref().map_or_else(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue