diff --git a/src/core.go b/src/core.go index e21e8c0a..b9884823 100644 --- a/src/core.go +++ b/src/core.go @@ -72,6 +72,7 @@ func Run(opts *Options, version string, revision string) { } item.text, item.colors = ansiProcessor(data) item.text.Index = itemIndex + item.origText = &data itemIndex++ return true }) diff --git a/src/options.go b/src/options.go index 3f4b5e92..9dc068bd 100644 --- a/src/options.go +++ b/src/options.go @@ -288,6 +288,7 @@ type Options struct { Criteria []criterion Multi int Ansi bool + KeepAnsi bool Mouse bool Theme *tui.ColorTheme Black bool @@ -1633,6 +1634,8 @@ func parseOptions(opts *Options, allArgs []string) { opts.Multi = 0 case "--ansi": opts.Ansi = true + case "--keep-ansi": + opts.KeepAnsi = true case "--no-ansi": opts.Ansi = false case "--no-mouse": diff --git a/src/terminal.go b/src/terminal.go index c7e86209..349082d0 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -202,6 +202,7 @@ type Terminal struct { scrollbar string previewScrollbar string ansi bool + keepAnsi bool tabstop int margin [4]sizeSpec padding [4]sizeSpec @@ -631,6 +632,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { header0: opts.Header, ellipsis: opts.Ellipsis, ansi: opts.Ansi, + keepAnsi: opts.KeepAnsi, tabstop: opts.Tabstop, hasLoadActions: false, triggerLoad: false, @@ -985,16 +987,17 @@ func (t *Terminal) output() bool { if len(t.expect) > 0 { t.printer(t.pressed) } + stripAnsi := t.ansi && (!t.keepAnsi) found := len(t.selected) > 0 if !found { current := t.currentItem() if current != nil { - t.printer(current.AsString(t.ansi)) + t.printer(current.AsString(stripAnsi)) found = true } } else { for _, sel := range t.sortSelected() { - t.printer(sel.item.AsString(t.ansi)) + t.printer(sel.item.AsString(stripAnsi)) } } return found