dir picker key navigation
Dependencies
- [2]
EJPSD5XOshared allowed actions conditions between update and view - [3]
7WCB5YQJrefactor msgs and modules - [4]
AZ5D2LQUallow to set record description - [5]
QUMAQ7IXfix prev focus label - [6]
CULHFNIVadd error report view - [7]
LFEMJYYDstart of to_record selection - [8]
2SLTGWP6add change files diffs to-record selection - [9]
TEDT26JQadd push and pull sub-menus - [10]
YRGDFHABproject dir picker - [11]
LPSUBGUBadd projects picker - [12]
MORKDJUEuse allowed actions binding for key subs - [13]
EIHMXSDRmv crate iced_expl_widget to inflorescence_iced_widget - [14]
23SFYK4Qbig view refactor into a new crate - [*]
6YZAVBWUInitial commit
Change contents
- replacement in inflorescence_view/src/view.rs at line 132
dir_picker::view(picker, theme::Container::Bordered).map(Msg::PickingRepoDir),dir_picker::view(picker,theme::Container::Bordered,theme::Container::NavSelectedSection,theme::Button::Normal,theme::Button::Selected,theme::Scrollable::Normal,theme::Scrollable::Selected,).map(Msg::PickingRepoDir), - replacement in inflorescence_model/src/action.rs at line 4
use inflorescence_iced_widget::nav_scrollable;use inflorescence_iced_widget::{dir_picker, nav_scrollable}; - edit in inflorescence_model/src/action.rs at line 144
impl ModKeys {pub fn iter(&self) -> ModKeysIter<'_> {ModKeysIter { keys: self, ix: 0 }}}pub struct ModKeysIter<'a> {keys: &'a ModKeys,ix: usize,}impl<'a> Iterator for ModKeysIter<'a> {type Item = &'a ModKey;fn next(&mut self) -> Option<Self::Item> {let Self { keys, ix } = self;match keys {ModKeys::One(mod_key) => {if *ix == 0 {*ix += 1;Some(mod_key)} else {None}}ModKeys::Two(mod_key_0, mod_key_1) => {if *ix == 0 {*ix += 1;Some(mod_key_0)} else if *ix == 1 {*ix += 1;Some(mod_key_1)} else {None}}}}} - replacement in inflorescence_model/src/action.rs at line 202
get_allowed_in_picking_repo(sub)get_allowed_in_picking_repo_dir(sub) - replacement in inflorescence_model/src/action.rs at line 207
model::SubState::PickingProject(_sub) =>// TODO{vec![]model::SubState::PickingProject(sub) => {get_allowed_in_picking_project(sub) - replacement in inflorescence_model/src/action.rs at line 245
impl ModKeys {pub fn iter(&self) -> ModKeysIter<'_> {ModKeysIter { keys: self, ix: 0 }fn get_allowed_in_picking_project(state: &model::PickingProject,) -> Vec<Binding> {let model::PickingProject {is_blocking: _,projects,} = state;if projects.is_some() {vec![down(), up()]} else {vec![] - edit in inflorescence_model/src/action.rs at line 259
fn get_allowed_in_picking_repo_dir(state: &model::PickingRepoDir,) -> Vec<Binding> {let model::PickingRepoDir {picker:dir_picker::State {matched_child_dirs,child_dirs,found_repos_dirs_pijul,found_repos_dirs_git,selection,..},} = state; - replacement in inflorescence_model/src/action.rs at line 275
pub struct ModKeysIter<'a> {keys: &'a ModKeys,ix: usize,}let down = || Binding {keys_str: "C-(↓| j)",keys: ModKeys::Two(ModKey {key: Key::Named(Named::ArrowDown),mods: Mods::CTRL,},ModKey {key: Key::Character("j".into()),mods: Mods::CTRL,},),label: "down",msg: Some(FilteredMsg::Selection(selection::Msg::AltPressDir(selection::Dir::Down,))),};let up = || Binding {keys_str: "C-(↑| k)",keys: ModKeys::Two(ModKey {key: Key::Named(Named::ArrowUp),mods: Mods::CTRL,},ModKey {key: Key::Character("k".into()),mods: Mods::CTRL,},),label: "up",msg: Some(FilteredMsg::Selection(selection::Msg::AltPressDir(selection::Dir::Up,))),};let left = || Binding {keys_str: "C-(←| h)",keys: ModKeys::Two(ModKey {key: Key::Named(Named::ArrowLeft),mods: Mods::CTRL,},ModKey {key: Key::Character("h".into()),mods: Mods::CTRL,},),label: "left",msg: Some(FilteredMsg::Selection(selection::Msg::AltPressDir(selection::Dir::Left,))),};let right = || Binding {keys_str: "C-(→| l)",keys: ModKeys::Two(ModKey {key: Key::Named(Named::ArrowRight),mods: Mods::CTRL,},ModKey {key: Key::Character("l".into()),mods: Mods::CTRL,},),label: "right",msg: Some(FilteredMsg::Selection(selection::Msg::AltPressDir(selection::Dir::Right,))),}; - replacement in inflorescence_model/src/action.rs at line 344
impl<'a> Iterator for ModKeysIter<'a> {type Item = &'a ModKey;let mut actions = vec![];let ma = &mut actions; - replacement in inflorescence_model/src/action.rs at line 347
fn next(&mut self) -> Option<Self::Item> {let Self { keys, ix } = self;match keys {ModKeys::One(mod_key) => {if *ix == 0 {*ix += 1;Some(mod_key)} else {None}}ModKeys::Two(mod_key_0, mod_key_1) => {if *ix == 0 {*ix += 1;Some(mod_key_0)} else if *ix == 1 {*ix += 1;Some(mod_key_1)} else {None}}let can_down_or_up = match selection {dir_picker::Selection::Input => {!matched_child_dirs.is_empty() || !child_dirs.is_empty()}dir_picker::Selection::SubDir(_) => true,dir_picker::Selection::ProjectPijul(_)| dir_picker::Selection::ProjectGit(_) => {!found_repos_dirs_pijul.is_empty()|| !found_repos_dirs_git.is_empty() - replacement in inflorescence_model/src/action.rs at line 357
}}}; - replacement in inflorescence_model/src/action.rs at line 359
fn get_allowed_in_picking_repo(_state: &model::PickingRepoDir) -> Vec<Binding> {vec![down(), up()]push_if(can_down_or_up, down, ma);push_if(can_down_or_up, up, ma);push_if(matches!(selection,dir_picker::Selection::ProjectPijul(_)| dir_picker::Selection::ProjectGit(_)),left,ma,);push_if(matches!(selection,dir_picker::Selection::Input | dir_picker::Selection::SubDir(_)),right,ma,);push(focus_next, ma);actions - replacement in inflorescence_model/src/action.rs at line 400
keys_str: "S-(↓| j)",keys_str: "C-(↓| j)", - replacement in inflorescence_model/src/action.rs at line 404
mods: Mods::SHIFT,mods: Mods::CTRL, - replacement in inflorescence_model/src/action.rs at line 408
mods: Mods::SHIFT,mods: Mods::CTRL, - replacement in inflorescence_model/src/action.rs at line 417
keys_str: "S-(↑| k)",keys_str: "C-(↑| k)", - replacement in inflorescence_model/src/action.rs at line 421
mods: Mods::SHIFT,mods: Mods::CTRL, - replacement in inflorescence_model/src/action.rs at line 425
mods: Mods::SHIFT,mods: Mods::CTRL, - edit in inflorescence_model/src/action.rs at line 506[3.8262]→[2.7915:7922](∅→∅),[2.7915]→[2.7915:7922](∅→∅),[2.7922]→[4.3098:3132](∅→∅),[4.3132]→[12.175124:175268](∅→∅),[12.175268]→[4.3152:3224](∅→∅),[4.3152]→[4.3152:3224](∅→∅)
};let focus_next = || Binding {keys_str: "Tab",keys: ModKeys::One(ModKey {key: Key::Named(Named::Tab),mods: Mods::NONE,}),label: "focus next",msg: Some(FilteredMsg::FocusNext), - edit in inflorescence_model/src/action.rs at line 507[4.3231]→[4.3231:3265](∅→∅),[4.3265]→[12.175269:175416](∅→∅),[5.62]→[4.3285:3368](∅→∅),[12.175416]→[4.3285:3368](∅→∅),[4.3285]→[4.3285:3368](∅→∅)
let focus_prev = || Binding {keys_str: "S-Tab",keys: ModKeys::One(ModKey {key: Key::Named(Named::Tab),mods: Mods::SHIFT,}),label: "focus previous",msg: Some(FilteredMsg::FocusPrev),}; - edit in inflorescence_model/src/action.rs at line 1380[9.533520]
fn focus_next() -> Binding {Binding {keys_str: "Tab",keys: ModKeys::One(ModKey {key: Key::Named(Named::Tab),mods: Mods::NONE,}),label: "focus next",msg: Some(FilteredMsg::FocusNext),}}fn focus_prev() -> Binding {Binding {keys_str: "S-Tab",keys: ModKeys::One(ModKey {key: Key::Named(Named::Tab),mods: Mods::SHIFT,}),label: "focus previous",msg: Some(FilteredMsg::FocusPrev),}} - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 21
left_nav: nav_scrollable::State,right_nav: nav_scrollable::State,input: String,current_dir: BasePathBuf,child_dirs: Vec<PathBuf>,matched_child_dirs: Vec<String>,found_repos_dirs_pijul: Vec<PathBuf>,found_repos_dirs_git: Vec<PathBuf>,find_child_dirs_handle: Option<task::Handle>,find_repos_handle: Option<task::Handle>,pub left_nav: nav_scrollable::State,pub right_nav: nav_scrollable::State,pub input: String,pub current_dir: BasePathBuf,pub child_dirs: Vec<PathBuf>,pub matched_child_dirs: Vec<String>,pub found_repos_dirs_pijul: Vec<PathBuf>,pub found_repos_dirs_git: Vec<PathBuf>,pub find_child_dirs_handle: Option<task::Handle>,pub find_repos_handle: Option<task::Handle>, - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 32
matcher: Matcher,pub matcher: Matcher,pub selection: Selection,}#[derive(Debug, Default)]pub enum Selection {#[default]Input,SubDir(usize),ProjectPijul(usize),ProjectGit(usize), - edit in inflorescence_iced_widget/src/dir_picker.rs at line 102
selection: Selection::default(), - edit in inflorescence_iced_widget/src/dir_picker.rs at line 118
// - edit in inflorescence_iced_widget/src/dir_picker.rs at line 252
}#[derive(Debug, Clone, Copy)]pub enum SelectionDir {Down,Up,Left,Right,}pub fn move_selection(state: &mut State, dir: SelectionDir) {let selection = &mut state.selection;match dir {SelectionDir::Down => match selection {Selection::Input => {if !state.matched_child_dirs.is_empty()|| !state.child_dirs.is_empty(){*selection = Selection::SubDir(0);}}Selection::SubDir(ix) => {if (!state.matched_child_dirs.is_empty()&& state.matched_child_dirs.len() - 1 > *ix)|| (!state.child_dirs.is_empty()&& state.child_dirs.len() - 1 > *ix){let new_ix = *ix + 1;*selection = Selection::SubDir(new_ix);} else {*selection = Selection::Input;}}Selection::ProjectPijul(ix) => {if !state.found_repos_dirs_pijul.is_empty() {if state.found_repos_dirs_pijul.len() - 1 > *ix {let new_ix = *ix + 1;*selection = Selection::ProjectPijul(new_ix);} else if !state.found_repos_dirs_git.is_empty() {*selection = Selection::ProjectGit(0);} else {*selection = Selection::ProjectPijul(0);}} else if !state.found_repos_dirs_git.is_empty() {if state.found_repos_dirs_git.len() - 1 > *ix {let new_ix = *ix + 1;*selection = Selection::ProjectGit(new_ix);} else {*selection = Selection::ProjectGit(0);}} else {*selection = Selection::Input;}}Selection::ProjectGit(ix) => {if !state.found_repos_dirs_git.is_empty() {if state.found_repos_dirs_git.len() - 1 > *ix {let new_ix = *ix + 1;*selection = Selection::ProjectGit(new_ix);} else if !state.found_repos_dirs_pijul.is_empty() {*selection = Selection::ProjectPijul(0);} else {*selection = Selection::ProjectGit(0);}} else if !state.found_repos_dirs_pijul.is_empty() {if state.found_repos_dirs_pijul.len() - 1 > *ix {let new_ix = *ix + 1;*selection = Selection::ProjectPijul(new_ix);} else {*selection = Selection::ProjectPijul(0);}} else {*selection = Selection::Input;}}},SelectionDir::Up => match selection {Selection::Input => {if !state.matched_child_dirs.is_empty() {let new_ix = state.matched_child_dirs.len() - 1;*selection = Selection::SubDir(new_ix);} else if !state.child_dirs.is_empty() {let new_ix = state.child_dirs.len() - 1;*selection = Selection::SubDir(new_ix);}}Selection::SubDir(ix) => {if *ix > 0&& (!state.matched_child_dirs.is_empty()|| !state.child_dirs.is_empty()){let new_ix = *ix - 1;*selection = Selection::SubDir(new_ix);} else {*selection = Selection::Input;}}Selection::ProjectPijul(ix) => {if !state.found_repos_dirs_pijul.is_empty() {if *ix > 0 {let new_ix = *ix - 1;*selection = Selection::ProjectPijul(new_ix);} else if !state.found_repos_dirs_git.is_empty() {*selection = Selection::ProjectGit(state.found_repos_dirs_git.len() - 1,);} else {*selection = Selection::ProjectPijul(state.found_repos_dirs_pijul.len() - 1,);}} else if !state.found_repos_dirs_git.is_empty() {if *ix > 0 {let new_ix = *ix - 1;*selection = Selection::ProjectGit(new_ix);} else {*selection = Selection::ProjectGit(state.found_repos_dirs_git.len() - 1,);}} else {*selection = Selection::Input;}}Selection::ProjectGit(ix) => {if !state.found_repos_dirs_git.is_empty() {if *ix > 0 {let new_ix = *ix - 1;*selection = Selection::ProjectGit(new_ix);} else if !state.found_repos_dirs_pijul.is_empty() {*selection = Selection::ProjectPijul(state.found_repos_dirs_pijul.len() - 1,);} else {*selection = Selection::ProjectGit(state.found_repos_dirs_git.len() - 1,);}} else if !state.found_repos_dirs_pijul.is_empty() {if *ix > 0 {let new_ix = *ix - 1;*selection = Selection::ProjectPijul(new_ix);} else {*selection = Selection::ProjectPijul(state.found_repos_dirs_pijul.len() - 1,);}} else {*selection = Selection::Input;}}},SelectionDir::Right | SelectionDir::Left => match selection {Selection::Input | Selection::SubDir(_) => {if !state.found_repos_dirs_pijul.is_empty() {*selection = Selection::ProjectPijul(0);} else if !state.found_repos_dirs_git.is_empty() {*selection = Selection::ProjectGit(0);}}Selection::ProjectPijul(_) => {if !state.matched_child_dirs.is_empty()|| !state.child_dirs.is_empty(){*selection = Selection::SubDir(0);} else {*selection = Selection::Input;}}Selection::ProjectGit(_) => {if !state.matched_child_dirs.is_empty()|| !state.child_dirs.is_empty(){*selection = Selection::SubDir(0);} else {*selection = Selection::Input;}}},} - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 436
bordered_container_class: <Theme as container::Catalog>::Class<'a>,container_class_bordered: <Theme as container::Catalog>::Class<'a>,container_class_bordered_selected: <Theme as container::Catalog>::Class<'a>,button_class_normal: <Theme as button::Catalog>::Class<'a>,button_class_selected: <Theme as button::Catalog>::Class<'a>,scrollable_normal: <Theme as nav_scrollable::Catalog>::Class<'a>,scrollable_selected: <Theme as nav_scrollable::Catalog>::Class<'a>, - edit in inflorescence_iced_widget/src/dir_picker.rs at line 450
<Theme as button::Catalog>::Class<'a>: Copy,<Theme as nav_scrollable::Catalog>::Class<'a>: Copy, - edit in inflorescence_iced_widget/src/dir_picker.rs at line 467
selection, - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 515
.class(bordered_container_class).class(if matches!(selection, Selection::Input) {container_class_bordered_selected} else {container_class_bordered}) - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 545
Element::new(button(text(dir)).on_press_with(move || {Msg::SelectChildDir(current_dir.as_path().join(dir),)},)),Element::new(button(text(dir)).on_press_with(move || {Msg::SelectChildDir(current_dir.as_path().join(dir),)}).class(if let Selection::SubDir(dir_ix) = selection&& *dir_ix == ix{button_class_selected} else {button_class_normal},),), - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 584
.on_press_with(|| Msg::SelectChildDir(dir.clone())),.on_press_with(|| Msg::SelectChildDir(dir.clone())).class(if let Selection::SubDir(dir_ix) = selection&& *dir_ix == ix{button_class_selected} else {button_class_normal},), - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 619
.map(|dir| {.enumerate().map(|(ix, dir)| { - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 623
.on_press_with(|| Msg::SelectRepo(dir.clone())),.on_press_with(|| Msg::SelectRepo(dir.clone())).class(if let Selection::ProjectPijul(dir_ix) = selection&& *dir_ix == ix{button_class_selected} else {button_class_normal},), - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 635
.chain(found_repos_dirs_git.iter().map(|dir| {.chain(found_repos_dirs_git.iter().enumerate().map(|(ix, dir)| { - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 638
.on_press_with(|| Msg::SelectRepo(dir.clone())),.on_press_with(|| Msg::SelectRepo(dir.clone())).class(if let Selection::ProjectGit(dir_ix) = selection&& *dir_ix == ix{button_class_selected} else {button_class_normal},), - edit in inflorescence_iced_widget/src/dir_picker.rs at line 658
.class(if matches!(selection, Selection::SubDir(_)) {scrollable_selected} else {scrollable_normal}) - edit in inflorescence_iced_widget/src/dir_picker.rs at line 675
.class(if matches!(selection,Selection::ProjectPijul(_)| Selection::ProjectGit(_)) {scrollable_selected} else {scrollable_normal},) - edit in inflorescence/src/main.rs at line 309
sub.is_blocking = false; - replacement in inflorescence/src/main.rs at line 556
view::Msg::Action(msg) => {dbg!(msg);Task::none()}view::Msg::UnfilteredSelection(msg) => {dbg!(msg);Task::none()}view::Msg::Action(msg) => match msg {action::FilteredMsg::Selection(msg) => match msg {selection::Msg::PressDir(_) => Task::none(),inflorescence_model::selection::Msg::AltPressDir(dir) => {update_dir_picker_selection(picker, dir);Task::none()}},action::FilteredMsg::FocusNext => task::widget_focus_next(),action::FilteredMsg::Confirm| action::FilteredMsg::Cancel| action::FilteredMsg::PostponeRecord| action::FilteredMsg::SaveRecord| action::FilteredMsg::DiscardRecord| action::FilteredMsg::AddUntrackedFile| action::FilteredMsg::RmChange| action::FilteredMsg::StartRecord| action::FilteredMsg::SelectChannel| action::FilteredMsg::ForkChannel| action::FilteredMsg::RefreshRepo| action::FilteredMsg::ShowEntireLog| action::FilteredMsg::FocusPrev| action::FilteredMsg::ClipboardCopy| action::FilteredMsg::ToggleReports| action::FilteredMsg::ClipboardCopyReports| action::FilteredMsg::ToRecord(_)| action::FilteredMsg::ToRecordToggleSelectedFileOrChange| action::FilteredMsg::EnterSubMenu(_) => Task::none(),},view::Msg::UnfilteredSelection(_msg) => Task::none(), - edit in inflorescence/src/main.rs at line 628
fn update_dir_picker_selection(picker: &mut dir_picker::State,dir: selection::Dir,) {let dir = match dir {selection::Dir::Down => dir_picker::SelectionDir::Down,selection::Dir::Up => dir_picker::SelectionDir::Up,selection::Dir::Right => dir_picker::SelectionDir::Right,selection::Dir::Left => dir_picker::SelectionDir::Left,};dir_picker::move_selection(picker, dir);}