summaryrefslogtreecommitdiff
path: root/src/terminal.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-05-30 20:26:07 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-05-30 20:26:53 +0900
commit835906d392aa6a3c8596d2c81414f0d73eaf99aa (patch)
tree41bc95c1b6f896259ea880c51c797d9ef415dafe /src/terminal.go
parent1721e6a1eddd4cdc44fc78e09eb2192bc56b895c (diff)
downloadfzf-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
Diffstat (limited to 'src/terminal.go')
-rw-r--r--src/terminal.go9
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 &&