mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 04:49:10 +08:00
builtin bind: make function keys lowercase (f1 instead of F1)
All other key names are lowercase so this inconsistency is weird.
This commit is contained in:
parent
4869b98482
commit
de7f39d627
|
@ -1141,7 +1141,7 @@ New or improved bindings
|
|||
- The binding for :kbd:`",*,y` now uses ``fish_clipboard_copy``, allowing it to support more than just ``xsel``.
|
||||
- The :kbd:`ctrl-space` binding can be correctly customised (:issue:`7922`).
|
||||
- ``exit`` works correctly in bindings (:issue:`7967`).
|
||||
- The :kbd:`F1` binding, which opens the manual page for the current command, now works around a bug in certain ``less`` versions that fail to clear the screen (:issue:`7863`).
|
||||
- The :kbd:`f1` binding, which opens the manual page for the current command, now works around a bug in certain ``less`` versions that fail to clear the screen (:issue:`7863`).
|
||||
- The binding for :kbd:`alt-s` now toggles whether ``sudo`` is prepended, even when it took the commandline from history instead of only adding it.
|
||||
- The new functions ``fish_commandline_prepend`` and ``fish_commandline_append`` allow toggling the presence of a prefix/suffix on the current commandline. (:issue:`7905`).
|
||||
- ``backward-kill-path-component`` :kbd:`ctrl-w`) no longer erases parts of two tokens when the cursor is positioned immediately after ``/``. (:issue:`6258`).
|
||||
|
@ -3547,7 +3547,7 @@ Other notable fixes and improvements
|
|||
- ``type`` has a new ``-q`` option to suppress output (:issue:`1540` and, like
|
||||
other shells, ``type -a`` now prints all matches for a command
|
||||
(:issue:`261`).
|
||||
- Pressing F1 now shows the manual page for the current command
|
||||
- Pressing :kbd:`f1` now shows the manual page for the current command
|
||||
(:issue:`1063`).
|
||||
- ``fish_title`` functions have access to the arguments of the
|
||||
currently running argument as ``$argv[1]`` (:issue:`1542`).
|
||||
|
|
|
@ -38,7 +38,7 @@ They are:
|
|||
- ``end``,
|
||||
- ``enter``,
|
||||
- ``escape``,
|
||||
- ``F1`` through ``F12``.
|
||||
- ``f1`` through ``f12``.
|
||||
- ``home``,
|
||||
- ``insert``,
|
||||
- ``minus`` (``-``),
|
||||
|
|
|
@ -327,7 +327,7 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit
|
|||
|
||||
- :kbd:`alt-d` moves the next word to the :ref:`killring`.
|
||||
|
||||
- :kbd:`alt-h` (or :kbd:`F1`) shows the manual page for the current command, if one exists.
|
||||
- :kbd:`alt-h` (or :kbd:`f1`) shows the manual page for the current command, if one exists.
|
||||
|
||||
- :kbd:`alt-l` lists the contents of the current directory, unless the cursor is over a directory argument, in which case the contents of that directory will be listed.
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ function __fish_bind_complete
|
|||
printf '%sshift-\tShift modifier…\n' $prefix
|
||||
set -l key_names minus comma backspace delete escape \
|
||||
enter up down left right pageup pagedown home end insert tab \
|
||||
space F(seq 12)
|
||||
space f(seq 12)
|
||||
printf '%s\tNamed key\n' $prefix$key_names
|
||||
end
|
||||
end
|
||||
|
|
|
@ -82,8 +82,8 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
|||
|
||||
bind --preset $argv alt-s 'for cmd in sudo doas please; if command -q $cmd; fish_commandline_prepend $cmd; break; end; end'
|
||||
|
||||
# Allow reading manpages by pressing F1 (many GUI applications) or Alt+h (like in zsh).
|
||||
bind --preset $argv F1 __fish_man_page
|
||||
# Allow reading manpages by pressing f1 (many GUI applications) or Alt+h (like in zsh).
|
||||
bind --preset $argv f1 __fish_man_page
|
||||
$legacy_bind --preset $argv -k f1 __fish_man_page
|
||||
bind --preset $argv alt-h __fish_man_page
|
||||
|
||||
|
|
11
src/key.rs
11
src/key.rs
|
@ -245,7 +245,8 @@ pub(crate) fn parse_keys(value: &wstr) -> Result<Vec<Key>, WString> {
|
|||
&& !value.contains('-')
|
||||
&& !value.contains(KEY_SEPARATOR)
|
||||
&& !KEY_NAMES.iter().any(|(_codepoint, name)| name == value)
|
||||
&& value.as_char_slice()[0] != 'F')
|
||||
&& value.as_char_slice()[0] != 'F'
|
||||
&& !(value.as_char_slice()[0] == 'f' && value.char_at(1).is_ascii_digit()))
|
||||
|| first < ' '
|
||||
{
|
||||
// Hack: treat as legacy syntax (meaning: not comma separated) if
|
||||
|
@ -290,13 +291,13 @@ pub(crate) fn parse_keys(value: &wstr) -> Result<Vec<Key>, WString> {
|
|||
modifiers,
|
||||
codepoint,
|
||||
})?
|
||||
} else if codepoint.is_none() && key_name.starts_with('F') && key_name.len() <= 3 {
|
||||
let num = key_name.strip_prefix('F').unwrap();
|
||||
} else if codepoint.is_none() && key_name.starts_with('f') && key_name.len() <= 3 {
|
||||
let num = key_name.strip_prefix('f').unwrap();
|
||||
let codepoint = match fish_wcstoi(num) {
|
||||
Ok(n) if (1..=12).contains(&n) => function_key(u32::try_from(n).unwrap()),
|
||||
_ => {
|
||||
return Err(wgettext_fmt!(
|
||||
"only F1 through F12 are supported, not 'F%s'",
|
||||
"only f1 through f12 are supported, not 'f%s'",
|
||||
num,
|
||||
));
|
||||
}
|
||||
|
@ -391,7 +392,7 @@ impl From<Key> for WString {
|
|||
.contains(&key.codepoint)
|
||||
.then(|| {
|
||||
sprintf!(
|
||||
"F%d",
|
||||
"f%d",
|
||||
u32::from(key.codepoint) - u32::from(function_key(1)) + 1
|
||||
)
|
||||
})
|
||||
|
|
|
@ -11,9 +11,10 @@ fn test_parse_key() {
|
|||
assert_eq!(parse_keys(L!("ctrl-a")), Ok(vec![ctrl('a')]));
|
||||
assert_eq!(parse_keys(L!("c-a")), Ok(vec![ctrl('a')]));
|
||||
assert_eq!(parse_keys(L!("\x01")), Ok(vec![ctrl('a')]));
|
||||
assert!(parse_keys(L!("F0")).is_err());
|
||||
assert!(parse_keys(L!("f0")).is_err());
|
||||
assert_eq!(
|
||||
parse_keys(L!("F1")),
|
||||
parse_keys(L!("f1")),
|
||||
Ok(vec![Key::from_raw(function_key(1))])
|
||||
);
|
||||
assert!(parse_keys(L!("F1")).is_err());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user