Implement FindPrevious on shift+enter
This commit is contained in:
parent
c7329b4dd3
commit
6779e5eadf
1 changed files with 17 additions and 4 deletions
21
src/main.rs
21
src/main.rs
|
|
@ -8,7 +8,8 @@ use cosmic::{
|
||||||
iced::{
|
iced::{
|
||||||
clipboard, event,
|
clipboard, event,
|
||||||
futures::{self, SinkExt},
|
futures::{self, SinkExt},
|
||||||
keyboard, subscription,
|
keyboard::{self, Modifiers},
|
||||||
|
subscription,
|
||||||
widget::{row, text},
|
widget::{row, text},
|
||||||
window, Alignment, Background, Color, Length, Point,
|
window, Alignment, Background, Color, Length, Point,
|
||||||
},
|
},
|
||||||
|
|
@ -186,7 +187,8 @@ pub enum Message {
|
||||||
FindReplaceValueChanged(String),
|
FindReplaceValueChanged(String),
|
||||||
FindSearchValueChanged(String),
|
FindSearchValueChanged(String),
|
||||||
GitProjectStatus(Vec<(String, PathBuf, Vec<GitStatus>)>),
|
GitProjectStatus(Vec<(String, PathBuf, Vec<GitStatus>)>),
|
||||||
Key(keyboard::Modifiers, keyboard::KeyCode),
|
Key(Modifiers, keyboard::KeyCode),
|
||||||
|
Modifiers(Modifiers),
|
||||||
NewFile,
|
NewFile,
|
||||||
NewWindow,
|
NewWindow,
|
||||||
NotifyEvent(notify::Event),
|
NotifyEvent(notify::Event),
|
||||||
|
|
@ -276,6 +278,7 @@ pub struct App {
|
||||||
project_search_value: String,
|
project_search_value: String,
|
||||||
project_search_result: Option<ProjectSearchResult>,
|
project_search_result: Option<ProjectSearchResult>,
|
||||||
watcher_opt: Option<notify::RecommendedWatcher>,
|
watcher_opt: Option<notify::RecommendedWatcher>,
|
||||||
|
modifiers: Modifiers,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
|
@ -981,6 +984,7 @@ impl Application for App {
|
||||||
project_search_value: String::new(),
|
project_search_value: String::new(),
|
||||||
project_search_result: None,
|
project_search_result: None,
|
||||||
watcher_opt: None,
|
watcher_opt: None,
|
||||||
|
modifiers: Modifiers::empty(),
|
||||||
};
|
};
|
||||||
|
|
||||||
for arg in env::args().skip(1) {
|
for arg in env::args().skip(1) {
|
||||||
|
|
@ -1278,6 +1282,9 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::Modifiers(modifiers) => {
|
||||||
|
self.modifiers = modifiers;
|
||||||
|
}
|
||||||
Message::NewFile => {
|
Message::NewFile => {
|
||||||
self.open_tab(None);
|
self.open_tab(None);
|
||||||
return self.update_tab();
|
return self.update_tab();
|
||||||
|
|
@ -1900,8 +1907,11 @@ impl Application for App {
|
||||||
widget::text_input::text_input(fl!("find-placeholder"), &self.find_search_value)
|
widget::text_input::text_input(fl!("find-placeholder"), &self.find_search_value)
|
||||||
.id(self.find_search_id.clone())
|
.id(self.find_search_id.clone())
|
||||||
.on_input(Message::FindSearchValueChanged)
|
.on_input(Message::FindSearchValueChanged)
|
||||||
//TODO: shift+enter for FindPrevious
|
.on_submit(if self.modifiers.contains(Modifiers::SHIFT) {
|
||||||
.on_submit(Message::FindNext)
|
Message::FindPrevious
|
||||||
|
} else {
|
||||||
|
Message::FindNext
|
||||||
|
})
|
||||||
.width(Length::Fixed(320.0))
|
.width(Length::Fixed(320.0))
|
||||||
.trailing_icon(
|
.trailing_icon(
|
||||||
button(icon_cache_get("edit-clear-symbolic", 16))
|
button(icon_cache_get("edit-clear-symbolic", 16))
|
||||||
|
|
@ -2007,6 +2017,9 @@ impl Application for App {
|
||||||
modifiers,
|
modifiers,
|
||||||
key_code,
|
key_code,
|
||||||
}) => Some(Message::Key(modifiers, key_code)),
|
}) => Some(Message::Key(modifiers, key_code)),
|
||||||
|
event::Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => {
|
||||||
|
Some(Message::Modifiers(modifiers))
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}),
|
}),
|
||||||
subscription::channel(
|
subscription::channel(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue