From 613cbd15c8dfd9fb0eb0570b2e87866ab0c5241f Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Tue, 11 Apr 2023 20:36:50 -0400 Subject: [PATCH 1/5] textfield: allow closing with ctrl+c --- src/ui/views/tui_textfield.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ui/views/tui_textfield.rs b/src/ui/views/tui_textfield.rs index b080710bd..a3423aa5b 100644 --- a/src/ui/views/tui_textfield.rs +++ b/src/ui/views/tui_textfield.rs @@ -215,6 +215,10 @@ impl<'a> TuiTextField<'a> { let _ = terminal.hide_cursor(); return None; } + Key::Ctrl('c') => { + let _ = terminal.hide_cursor(); + return None; + } Key::Char('\t') => autocomplete( &mut line_buffer, &mut completion_tracker, From 002bc713ae611c75d2585ea83cea7421d7e1a6b0 Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Tue, 11 Apr 2023 20:38:14 -0400 Subject: [PATCH 2/5] autocomplete: assume selection when there's only one candidate --- src/ui/views/tui_textfield.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ui/views/tui_textfield.rs b/src/ui/views/tui_textfield.rs index a3423aa5b..39fbfd73c 100644 --- a/src/ui/views/tui_textfield.rs +++ b/src/ui/views/tui_textfield.rs @@ -324,9 +324,14 @@ fn autocomplete( }; let candidate = &ct.candidates[ct.index]; - completer.update(line_buffer, ct.pos, candidate.display()); + completer.update(line_buffer, ct.pos, candidate.replacement()); } else if let Some((pos, mut candidates)) = get_candidates(completer, line_buffer) { if !candidates.is_empty() { + if candidates.len() == 1 && candidates[0].replacement().ends_with('/') { + completer.update(line_buffer, pos, &candidates[0].replacement()); + return false; + } + candidates.sort_by(|x, y| { x.display() .partial_cmp(y.display()) @@ -334,7 +339,7 @@ fn autocomplete( }); let first_idx = if reversed { candidates.len() - 1 } else { 0 }; - let first = candidates[first_idx].display().to_string(); + let first = candidates[first_idx].replacement().to_string(); let mut ct = CompletionTracker::new(pos, candidates, String::from(line_buffer.as_str())); From c98fe668a36f5fa0792897b7f309d20de1d9a3f7 Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Tue, 11 Apr 2023 20:51:41 -0400 Subject: [PATCH 3/5] autocomplete: cycle back to first candidate --- src/ui/views/tui_textfield.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ui/views/tui_textfield.rs b/src/ui/views/tui_textfield.rs index 39fbfd73c..57929eef4 100644 --- a/src/ui/views/tui_textfield.rs +++ b/src/ui/views/tui_textfield.rs @@ -317,10 +317,8 @@ fn autocomplete( if let Some(ref mut ct) = completion_tracker { ct.index = if reversed { ct.index.checked_sub(1).unwrap_or(ct.candidates.len() - 1) - } else if ct.index + 1 < ct.candidates.len() { - ct.index + 1 } else { - ct.index + (ct.index + 1) % ct.candidates.len() }; let candidate = &ct.candidates[ct.index]; From 876c5a458414aa836242cccc73516d0e185f04bd Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Tue, 11 Apr 2023 20:52:49 -0400 Subject: [PATCH 4/5] impl_from_str.rs: remove stray print --- src/key_command/impl_from_str.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/key_command/impl_from_str.rs b/src/key_command/impl_from_str.rs index b88af8cd6..d684bf983 100644 --- a/src/key_command/impl_from_str.rs +++ b/src/key_command/impl_from_str.rs @@ -248,7 +248,6 @@ impl std::str::FromStr for Command { } else if command == CMD_DELETE_FILES { let (mut permanently, mut background) = (false, false); for arg in arg.split_whitespace() { - eprintln!("arg: {:?}", arg); match arg { "--background=true" => background = true, "--background=false" => background = false, From b952351e4c27b838eee0d9d0b67b297e280d997f Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Tue, 11 Apr 2023 21:14:40 -0400 Subject: [PATCH 5/5] docs/image_previews.md: fix typo in kitty guide --- docs/image_previews.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/image_previews.md b/docs/image_previews.md index 41e05e845..40c074f98 100644 --- a/docs/image_previews.md +++ b/docs/image_previews.md @@ -265,7 +265,7 @@ case "$mimetype" in esac ``` -`~/.config/joshuto/on_preview_removed.sh`: +`~/.config/joshuto/on_preview_removed`: ```shell #!/usr/bin/env bash