icat: Add an option to leave the cursor to the right of the image

Fixes #7574
This commit is contained in:
Kovid Goyal 2024-06-25 13:06:46 +05:30
parent 190566be8e
commit 5bb8378dc1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 11 additions and 3 deletions

View File

@ -76,6 +76,8 @@ Detailed list of changes
- Wayland: Fix specifying the output name for the panel kitten not working (:iss:`7573`)
- icat kitten: Add an option :option:`kitty +kitten icat --no-trailing-newline` to leave the cursor to the right of the image (:iss:`7574`)
0.35.2 [2024-06-22]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -292,7 +292,7 @@ func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
if imgd.err != nil {
print_error("Failed to process \x1b[31m%s\x1b[39m: %s\r\n", imgd.source_name, imgd.err)
} else {
transmit_image(imgd)
transmit_image(imgd, opts.NoTrailingNewline)
if imgd.err != nil {
print_error("Failed to transmit \x1b[31m%s\x1b[39m: %s\r\n", imgd.source_name, imgd.err)
}

View File

@ -155,6 +155,12 @@
The graphics protocol id to use for the created image. Normally, a random id is created if needed.
This option allows control of the id. When multiple images are sent, sequential ids starting from the specified id
are used. Valid ids are from 1 to 4294967295. Numbers outside this range are automatically wrapped.
--no-trailing-newline -n
type=bool-set
By default, the cursor is moved to the next line after displaying an image. This option, prevents that. Should not be used
when catting multiple images. Also has no effect when the :option:`--place` option is used.
'''
help_text = (

View File

@ -278,7 +278,7 @@ func write_unicode_placeholder(imgd *image_data) {
var seen_image_ids *utils.Set[uint32]
func transmit_image(imgd *image_data) {
func transmit_image(imgd *image_data, no_trailing_newline bool) {
if seen_image_ids == nil {
seen_image_ids = utils.NewSet[uint32](32)
}
@ -406,7 +406,7 @@ func transmit_image(imgd *image_data) {
return
}
}
if imgd.move_to.x == 0 {
if imgd.move_to.x == 0 && !no_trailing_newline {
fmt.Println() // ensure cursor is on new line
}
}