m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 16:45:38 -05:00

Add 'bell' action to ring the terminal bell

This commit is contained in:
Junegunn Choi
2025-01-25 11:22:32 +09:00
parent 02199cd609
commit 04017c25bb
8 changed files with 22 additions and 0 deletions

View File

@@ -1586,6 +1586,8 @@ func parseActionList(masked string, original string, prevActions []*action, putA
} else {
return nil, errors.New("unable to put non-printable character")
}
case "bell":
appendAction(actBell)
default:
t := isExecuteAction(specLower)
if t == actIgnore {

View File

@@ -567,6 +567,7 @@ const (
actBecome
actShowHeader
actHideHeader
actBell
)
func (a actionType) Name() string {
@@ -4704,6 +4705,8 @@ func (t *Terminal) Loop() error {
t.executor.Become(t.ttyin, t.environ(), command)
}
}
case actBell:
t.tui.Bell()
case actExecute, actExecuteSilent:
t.executeCommand(a.a, false, a.t == actExecuteSilent, false, false, "")
case actExecuteMulti:

View File

@@ -44,6 +44,7 @@ func (r *FullscreenRenderer) PassThrough(string) {}
func (r *FullscreenRenderer) Clear() {}
func (r *FullscreenRenderer) NeedScrollbarRedraw() bool { return false }
func (r *FullscreenRenderer) ShouldEmitResizeEvent() bool { return false }
func (r *FullscreenRenderer) Bell() {}
func (r *FullscreenRenderer) Refresh() {}
func (r *FullscreenRenderer) Close() {}
func (r *FullscreenRenderer) Size() TermSize { return TermSize{} }

View File

@@ -32,6 +32,10 @@ const consoleDevice string = "/dev/tty"
var offsetRegexp = regexp.MustCompile("(.*)\x1b\\[([0-9]+);([0-9]+)R")
var offsetRegexpBegin = regexp.MustCompile("^\x1b\\[[0-9]+;[0-9]+R")
func (r *LightRenderer) Bell() {
r.flushRaw("\a")
}
func (r *LightRenderer) PassThrough(str string) {
r.queued.WriteString("\x1b7" + str + "\x1b8")
}

View File

@@ -100,6 +100,10 @@ const (
BoldForce = Attr(1 << 10)
)
func (r *FullscreenRenderer) Bell() {
_screen.Beep()
}
func (r *FullscreenRenderer) PassThrough(str string) {
// No-op
// https://github.com/gdamore/tcell/pull/650#issuecomment-1806442846

View File

@@ -580,6 +580,7 @@ type Renderer interface {
PassThrough(string)
NeedScrollbarRedraw() bool
ShouldEmitResizeEvent() bool
Bell()
GetChar() Event