From 4e8aa7ed1d948d3145bf645dafba9736e379759c Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sun, 17 Apr 2022 23:39:53 -0400 Subject: [PATCH] fix(readline): use invert for completion highlight instead of hardcoded colors --- api.go | 1 + readline/codes.go | 1 + readline/comp-grid.go | 2 +- readline/comp-list.go | 2 +- readline/comp-map.go | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api.go b/api.go index dfd413b..527ab43 100644 --- a/api.go +++ b/api.go @@ -325,6 +325,7 @@ func hlprompt(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { return nil, err } typ := "left" + // optional 2nd arg if len(c.Etc()) != 0 { ltyp := c.Etc()[0] var ok bool diff --git a/readline/codes.go b/readline/codes.go index 29d7462..492bc72 100644 --- a/readline/codes.go +++ b/readline/codes.go @@ -85,6 +85,7 @@ const ( seqBold = "\x1b[1m" seqUnderscore = "\x1b[4m" seqBlink = "\x1b[5m" + seqInvert = "\x1b[7m" ) // Text colours diff --git a/readline/comp-grid.go b/readline/comp-grid.go index 8abdc63..2679835 100644 --- a/readline/comp-grid.go +++ b/readline/comp-grid.go @@ -121,7 +121,7 @@ func (g *CompletionGroup) writeGrid(rl *Instance) (comp string) { } if (x == g.tcPosX && y == g.tcPosY) && (g.isCurrent) { - comp += seqCtermFg255 + seqFgBlackBright + comp += seqInvert } comp += fmt.Sprintf("%-"+cellWidth+"s %s", g.Suggestions[i], seqReset) diff --git a/readline/comp-list.go b/readline/comp-list.go index ce158f4..42add2f 100644 --- a/readline/comp-list.go +++ b/readline/comp-list.go @@ -188,7 +188,7 @@ func (g *CompletionGroup) writeList(rl *Instance) (comp string) { // function highlights the cell depending on current selector place. highlight := func(y int, x int) string { if y == g.tcPosY && x == g.tcPosX && g.isCurrent { - return seqCtermFg255 + seqFgBlackBright + return seqInvert } return "" } diff --git a/readline/comp-map.go b/readline/comp-map.go index d183eaa..42b56cf 100644 --- a/readline/comp-map.go +++ b/readline/comp-map.go @@ -101,7 +101,7 @@ func (g *CompletionGroup) writeMap(rl *Instance) (comp string) { // Highlighting function highlight := func(y int) string { if y == g.tcPosY && g.isCurrent { - return seqCtermFg255 + seqFgBlackBright + return seqInvert } return "" }