E.L.K 4 weeks ago committed by GitHub
commit ea05ce8cdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -75,6 +75,7 @@ func Run(opts *Options) (int, error) {
} }
item.text, item.colors = ansiProcessor(data) item.text, item.colors = ansiProcessor(data)
item.text.Index = itemIndex item.text.Index = itemIndex
item.origText = &data
itemIndex++ itemIndex++
return true return true
}) })

@ -315,6 +315,7 @@ type Options struct {
Criteria []criterion Criteria []criterion
Multi int Multi int
Ansi bool Ansi bool
KeepAnsi bool
Mouse bool Mouse bool
Theme *tui.ColorTheme Theme *tui.ColorTheme
Black bool Black bool
@ -1926,6 +1927,8 @@ func parseOptions(opts *Options, allArgs []string) error {
opts.Multi = 0 opts.Multi = 0
case "--ansi": case "--ansi":
opts.Ansi = true opts.Ansi = true
case "--keep-ansi":
opts.KeepAnsi = true
case "--no-ansi": case "--no-ansi":
opts.Ansi = false opts.Ansi = false
case "--no-mouse": case "--no-mouse":

@ -245,6 +245,7 @@ type Terminal struct {
scrollbar string scrollbar string
previewScrollbar string previewScrollbar string
ansi bool ansi bool
keepAnsi bool
tabstop int tabstop int
margin [4]sizeSpec margin [4]sizeSpec
padding [4]sizeSpec padding [4]sizeSpec
@ -769,6 +770,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
header0: opts.Header, header0: opts.Header,
ellipsis: opts.Ellipsis, ellipsis: opts.Ellipsis,
ansi: opts.Ansi, ansi: opts.Ansi,
keepAnsi: opts.KeepAnsi,
tabstop: opts.Tabstop, tabstop: opts.Tabstop,
hasResultActions: false, hasResultActions: false,
hasFocusActions: false, hasFocusActions: false,
@ -1163,16 +1165,17 @@ func (t *Terminal) output() bool {
if len(t.expect) > 0 { if len(t.expect) > 0 {
t.printer(t.pressed) t.printer(t.pressed)
} }
stripAnsi := t.ansi && (!t.keepAnsi)
found := len(t.selected) > 0 found := len(t.selected) > 0
if !found { if !found {
current := t.currentItem() current := t.currentItem()
if current != nil { if current != nil {
t.printer(current.AsString(t.ansi)) t.printer(current.AsString(stripAnsi))
found = true found = true
} }
} else { } else {
for _, sel := range t.sortSelected() { for _, sel := range t.sortSelected() {
t.printer(sel.item.AsString(t.ansi)) t.printer(sel.item.AsString(stripAnsi))
} }
} }
return found return found

Loading…
Cancel
Save