mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-15 04:05:48 -07:00
Support ANSI escape sequence for clearing display in preview window
fzf --preview 'for i in $(seq 100000); do (( i % 200 == 0 )) && printf "\033[2J" echo "$i" sleep 0.01 done'
This commit is contained in:
@@ -26,6 +26,7 @@ var numericPrefix *regexp.Regexp
|
||||
var activeTempFiles []string
|
||||
|
||||
const ellipsis string = ".."
|
||||
const clearCode string = "\x1b[2J"
|
||||
|
||||
func init() {
|
||||
placeholder = regexp.MustCompile(`\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\+?f?nf?})`)
|
||||
@@ -1834,6 +1835,13 @@ func (t *Terminal) Loop() {
|
||||
line := eachLine.line
|
||||
err := eachLine.err
|
||||
if len(line) > 0 {
|
||||
clearIndex := strings.Index(line, clearCode)
|
||||
if clearIndex >= 0 {
|
||||
lines = []string{}
|
||||
line = line[clearIndex+len(clearCode):]
|
||||
version--
|
||||
offset = 0
|
||||
}
|
||||
lines = append(lines, line)
|
||||
}
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user