Skip to content
Myr

Avoid printing ANSI reset codes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fzf --border --bind 'start:transform-border-label:echo -e "\x1b[0mfoo"'

authored by Junegunn Choi · committed by Junegunn Choi · parent 2faffbd · Browse files · 1 file+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−4 removed

  • other:+4 added−4 removed

1 file+4 added−4 removed

modified:src/terminal.go+4 added-4 removed
1004 unmodified lines
1005 text, colors, _ := extractColor(str, nil, nil)1006 runes := []rune(text)10071008 // Simpler printer for strings without ANSI colors or tab characters1009 if colors == nil && !strings.ContainsRune(str, '\t') {1010 length := util.StringWidth(str)1009 if colors == nil && !strings.ContainsRune(text, '\t') {1010 length := util.StringWidth(text)1011 if length == 0 {1012 return nil, 01013 }1014 printFn := func(window tui.Window, limit int) {1015 if length > limit {1016 trimmedRunes, _ := t.trimRight(runes, limit)1017 window.CPrint(*color, string(trimmedRunes))1018 } else if fill {1019 window.CPrint(*color, util.RepeatToFill(str, length, limit))1019 window.CPrint(*color, util.RepeatToFill(text, length, limit))1020 } else {1021 window.CPrint(*color, str)1021 window.CPrint(*color, text)1022 }1023 }1024 return printFn, length1025 }
3992 unmodified lines