From dd310ffa755338cf0a40973706f05a29dcdf3c94 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Fri, 17 Jan 2025 17:28:27 +0300 Subject: [PATCH] feat(ansi): kitty: add DoNotMoveCursor option --- ansi/kitty/options.go | 8 ++++++++ ansi/kitty/options_test.go | 13 +++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ansi/kitty/options.go b/ansi/kitty/options.go index 9e0cfa5d..a8d907bd 100644 --- a/ansi/kitty/options.go +++ b/ansi/kitty/options.go @@ -113,6 +113,10 @@ type Options struct { // with Unicode [Placeholder] to display images. VirtualPlacement bool + // DoNotMoveCursor (C=0) whether to move the cursor after displaying the + // image. + DoNotMoveCursor bool + // ParentID (P=0) is the parent image ID. The parent ID is the ID of the // image that is the parent of the current image. This is used with Unicode // [Placeholder] to display images relative to the parent image. @@ -207,6 +211,10 @@ func (o *Options) Options() (opts []string) { opts = append(opts, "U=1") } + if o.DoNotMoveCursor { + opts = append(opts, "C=1") + } + if o.ParentID > 0 { opts = append(opts, fmt.Sprintf("P=%d", o.ParentID)) } diff --git a/ansi/kitty/options_test.go b/ansi/kitty/options_test.go index 5d172943..896fed55 100644 --- a/ansi/kitty/options_test.go +++ b/ansi/kitty/options_test.go @@ -268,13 +268,14 @@ func TestOptions_MarshalText(t *testing.T) { { name: "marshal with values", o: Options{ - Action: 'A', - ID: 123, - Width: 400, - Height: 500, - Quite: 2, + Action: 'A', + ID: 123, + Width: 400, + Height: 500, + Quite: 2, + DoNotMoveCursor: true, }, - want: []byte("q=2,i=123,w=400,h=500,a=A"), + want: []byte("q=2,i=123,C=1,w=400,h=500,a=A"), }, }