Skip to content

Commit

Permalink
Add "flash" bind function to flash
Browse files Browse the repository at this point in the history
This is something we do regularly in the reader, e.g. when there is no
completion.

This makes it accessible to custom bindings.

E.g. you can e.g. make the
alt-s binding (which toggles a sudo/doas/please prefix) flash instead
of doing anything when the current command is a builtin.
  • Loading branch information
faho committed Jan 22, 2025
1 parent 4e13ce3 commit 2c79690
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc_src/cmds/bind.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ The following special input functions are available:
``exit``
exit the shell

``flash``
makes the commandline flash, like fish does when e.g. there is no completion.

``forward-bigword``
move one whitespace-delimited word to the right

Expand Down
1 change: 1 addition & 0 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ const INPUT_FUNCTION_METADATA: &[InputFunctionMetadata] = &[
make_md(L!("execute"), ReadlineCmd::Execute),
make_md(L!("exit"), ReadlineCmd::Exit),
make_md(L!("expand-abbr"), ReadlineCmd::ExpandAbbr),
make_md(L!("flash"), ReadlineCmd::Flash),
make_md(L!("force-repaint"), ReadlineCmd::ForceRepaint),
make_md(L!("forward-bigword"), ReadlineCmd::ForwardBigword),
make_md(L!("forward-char"), ReadlineCmd::ForwardChar),
Expand Down
1 change: 1 addition & 0 deletions src/input_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub enum ReadlineCmd {
TogglecaseChar,
TogglecaseSelection,
Execute,
Flash,
BeginningOfBuffer,
EndOfBuffer,
RepaintMode,
Expand Down
4 changes: 4 additions & 0 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2911,6 +2911,10 @@ impl<'a> Reader<'a> {
.reset_abandoning_line(usize::try_from(termsize_last().width).unwrap());
}
}
rl::Flash => {
self.flash();
return;
}
rl::HistoryPrefixSearchBackward
| rl::HistoryPrefixSearchForward
| rl::HistorySearchBackward
Expand Down

0 comments on commit 2c79690

Please sign in to comment.