Skip to content

Commit 858ad8d

Browse files
committed
feat(termimg): add ClearAllString function for Kitty protocol image clearing
1 parent 46704b6 commit 858ad8d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

termimg.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@ func ClearAll() error {
338338
return err
339339
}
340340

341+
// ClearAllString returns a command to clear all images drawn by the Kitty protocol as a string.
342+
func ClearAllString() string {
343+
// This command is specific to the Kitty renderer, but it's safe to send
344+
// as other terminals will ignore it.
345+
control := "a=d"
346+
output := fmt.Sprintf("\x1b_G%s\x1b", control)
347+
if inTmux() {
348+
output = wrapTmuxPassthrough(output)
349+
}
350+
return output
351+
}
352+
341353
// Clear removes the image from the terminal
342354
func (i *Image) Clear(opts ClearOptions) error {
343355
renderer, err := i.getRenderer()

0 commit comments

Comments
 (0)