From c3d73e7ecbe56358949400f5314fee2d6976885a Mon Sep 17 00:00:00 2001 From: jpcrs Date: Tue, 17 Jan 2023 18:43:02 +0000 Subject: [PATCH] Add change-border-label and change-preview-label actions, update man --- man/man1/fzf.1 | 2 ++ src/options.go | 6 +++++- src/terminal.go | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 index 846a5bd0..832524f5 100644 --- a/man/man1/fzf.1 +++ b/man/man1/fzf.1 @@ -985,7 +985,9 @@ A key or an event can be bound to one or more of the following actions. \fBcancel\fR (clear query string if not empty, abort fzf otherwise) \fBchange-preview(...)\fR (change \fB--preview\fR option) \fBchange-preview-window(...)\fR (change \fB--preview-window\fR option; rotate through the multiple option sets separated by '|') + \fBchange-preview-label(...)\fR (change \fB--preview-label\fR to the given string) \fBchange-prompt(...)\fR (change prompt to the given string) + \fBchange-border-label(...)\fR (change \fB--border-label\fR to the given string) \fBchange-query(...)\fR (change query string to the given string) \fBclear-screen\fR \fIctrl-l\fR \fBclear-selection\fR (clear multi-selection) diff --git a/src/options.go b/src/options.go index 39b1b0e1..f22e767a 100644 --- a/src/options.go +++ b/src/options.go @@ -912,7 +912,7 @@ const ( func init() { executeRegexp = regexp.MustCompile( - `(?si)[:+](execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|transform)-(?:query|prompt)|change-preview-window|change-preview|(?:re|un)bind|pos|put)`) + `(?si)[:+](execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|transform)-(?:query|prompt)|change-preview-window|change-preview-label|change-border-label|change-preview|(?:re|un)bind|pos|put)`) splitRegexp = regexp.MustCompile("[,:]+") actionNameRegexp = regexp.MustCompile("(?i)^[a-z-]+") } @@ -1224,8 +1224,12 @@ func isExecuteAction(str string) actionType { return actChangePreviewWindow case "change-preview": return actChangePreview + case "change-preview-label": + return actChangePreviewLabel case "change-prompt": return actChangePrompt + case "change-border-label": + return actChangeBorderLabel case "change-query": return actChangeQuery case "pos": diff --git a/src/terminal.go b/src/terminal.go index b21aca73..5b03f6d7 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -306,6 +306,8 @@ const ( actBackwardDeleteCharEOF actBackwardWord actCancel + actChangeBorderLabel + actChangePreviewLabel actChangePrompt actChangeQuery actClearScreen @@ -2909,6 +2911,12 @@ func (t *Terminal) Loop() { case actChangeQuery: t.input = []rune(a.a) t.cx = len(t.input) + case actChangeBorderLabel: + t.borderLabel, t.borderLabelLen = t.ansiLabelPrinter(a.a, &tui.ColBorderLabel, false) + req(reqFullRedraw) + case actChangePreviewLabel: + t.previewLabel, t.previewLabelLen = t.ansiLabelPrinter(a.a, &tui.ColPreviewLabel, false) + req(reqFullRedraw) case actChangePrompt: t.prompt, t.promptLen = t.parsePrompt(a.a) req(reqPrompt)