Skip to content

Commit

Permalink
feat(ansi): kitty: add DoNotMoveCursor option
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Jan 17, 2025
1 parent 8cddaf3 commit dd310ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 8 additions & 0 deletions ansi/kitty/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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))
}
Expand Down
13 changes: 7 additions & 6 deletions ansi/kitty/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
}

Expand Down

0 comments on commit dd310ff

Please sign in to comment.