mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
56e4c9bb2e
commit
7aebb8b548
6 changed files with 29 additions and 14 deletions
|
|
@ -192,11 +192,11 @@ keymap = [
|
|||
{ on = [ "<C-f>" ], exec = "move 1", desc = "Move forward a character" },
|
||||
|
||||
# Word-wise movement
|
||||
{ on = [ "b" ], exec = "backward", desc = "Move back to the start of the current or previous word" },
|
||||
{ on = [ "w" ], exec = "forward", desc = "Move forward to the start of the next word" },
|
||||
{ on = [ "e" ], exec = "forward --end-of-word", desc = "Move forward to the end of the current or next word" },
|
||||
{ on = [ "<A-b>" ], exec = "backward", desc = "Move back to the start of the current or previous word" },
|
||||
{ on = [ "<A-f>" ], exec = "forward --after-last-char", desc = "Move forward to the end of the current or next word" },
|
||||
{ on = [ "b" ], exec = "backward", desc = "Move back to the start of the current or previous word" },
|
||||
{ on = [ "w" ], exec = "forward", desc = "Move forward to the start of the next word" },
|
||||
{ on = [ "e" ], exec = "forward --end-of-word", desc = "Move forward to the end of the current or next word" },
|
||||
{ on = [ "<A-b>" ], exec = "backward", desc = "Move back to the start of the current or previous word" },
|
||||
{ on = [ "<A-f>" ], exec = "forward --end-of-word", desc = "Move forward to the end of the current or next word" },
|
||||
|
||||
# Line-wise movement
|
||||
{ on = [ "0" ], exec = "move -999", desc = "Move to the BOL" },
|
||||
|
|
|
|||
|
|
@ -32,3 +32,8 @@ impl TryFrom<Vec<i16>> for Offset {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Offset {
|
||||
#[inline]
|
||||
pub fn line() -> Self { Self { x: 0, y: 0, width: u16::MAX, height: 1 } }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_config::keymap::Exec;
|
||||
use yazi_config::{keymap::Exec, popup::{Offset, Origin, Position}};
|
||||
|
||||
use crate::help::Help;
|
||||
use crate::{help::Help, input::Input};
|
||||
|
||||
pub struct Opt;
|
||||
|
||||
|
|
@ -10,7 +10,10 @@ impl From<&Exec> for Opt {
|
|||
|
||||
impl Help {
|
||||
pub fn filter(&mut self, _: impl Into<Opt>) -> bool {
|
||||
self.in_filter = Some(Default::default());
|
||||
let mut input = Input::default();
|
||||
input.position = Position::new(Origin::BottomLeft, Offset::line());
|
||||
|
||||
self.in_filter = Some(input);
|
||||
self.filter_apply();
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use crossterm::event::KeyCode;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
use yazi_config::{keymap::{Control, Key, KeymapLayer}, KEYMAP};
|
||||
use yazi_shared::Term;
|
||||
|
|
@ -65,11 +66,14 @@ impl Help {
|
|||
return true;
|
||||
}
|
||||
|
||||
if input.type_(key) {
|
||||
return self.filter_apply();
|
||||
}
|
||||
let b = match &key {
|
||||
Key { code: KeyCode::Backspace, shift: false, ctrl: false, alt: false } => {
|
||||
input.backspace(false)
|
||||
}
|
||||
_ => input.type_(key),
|
||||
};
|
||||
|
||||
false
|
||||
if b { self.filter_apply() } else { false }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ pub struct Opt {
|
|||
impl From<&Exec> for Opt {
|
||||
fn from(e: &Exec) -> Self { Self { under: e.named.contains_key("under") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(under: bool) -> Self { Self { under } }
|
||||
}
|
||||
|
||||
impl Input {
|
||||
pub fn backspace(&mut self, opt: impl Into<Opt>) -> bool {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ impl<'a> Executor<'a> {
|
|||
if self.cx.which.visible {
|
||||
return self.cx.which.press(key);
|
||||
}
|
||||
if self.cx.input.visible && self.cx.input.type_(&key) {
|
||||
if self.cx.help.visible && self.cx.help.type_(&key) {
|
||||
return true;
|
||||
}
|
||||
if self.cx.help.visible && self.cx.help.type_(&key) {
|
||||
if self.cx.input.visible && self.cx.input.type_(&key) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue