diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2025-05-30 20:26:07 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2025-05-30 20:26:53 +0900 |
| commit | 835906d392aa6a3c8596d2c81414f0d73eaf99aa (patch) | |
| tree | 41bc95c1b6f896259ea880c51c797d9ef415dafe | |
| parent | 1721e6a1eddd4cdc44fc78e09eb2192bc56b895c (diff) | |
| download | fzf-835906d392aa6a3c8596d2c81414f0d73eaf99aa.tar.gz | |
--no-color: Keep ANSI attributes in preview window
Example:
fzf --preview 'echo -e "\x1b[33;3mfoo \x1b[34;4mbar\x1b[m baz"' --no-color
| -rw-r--r-- | src/terminal.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/terminal.go b/src/terminal.go index 6f65f52e..8ffe9cef 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -3559,10 +3559,15 @@ Loop: str, width := t.processTabs(trimmed, prefixWidth) if width > prefixWidth { prefixWidth = width - if t.theme.Colored && ansi != nil && ansi.colored() { + colored := ansi != nil && ansi.colored() + if t.theme.Colored && colored { fillRet = t.pwindow.CFill(ansi.fg, ansi.bg, ansi.attr, str) } else { - fillRet = t.pwindow.CFill(tui.ColPreview.Fg(), tui.ColPreview.Bg(), tui.AttrRegular, str) + attr := tui.AttrRegular + if colored { + attr = ansi.attr + } + fillRet = t.pwindow.CFill(tui.ColPreview.Fg(), tui.ColPreview.Bg(), attr, str) } } return !isTrimmed && |
