icat: allow specifying image ids
This commit is contained in:
parent
a56f111f98
commit
88443ef8a5
@ -138,6 +138,14 @@ Whether to surround graphics commands with escape sequences that allow them to p
|
|||||||
programs like tmux. The default is to detect when running inside tmux and automatically use
|
programs like tmux. The default is to detect when running inside tmux and automatically use
|
||||||
the tmux passthrough escape codes. Note that when this option is enabled it implies
|
the tmux passthrough escape codes. Note that when this option is enabled it implies
|
||||||
:option:`--unicode-placeholder` as well.
|
:option:`--unicode-placeholder` as well.
|
||||||
|
|
||||||
|
|
||||||
|
--image-id
|
||||||
|
type=int
|
||||||
|
default=0
|
||||||
|
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.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
help_text = (
|
help_text = (
|
||||||
|
|||||||
@ -240,8 +240,16 @@ func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
|||||||
if passthrough_mode != no_passthrough {
|
if passthrough_mode != no_passthrough {
|
||||||
use_unicode_placeholder = true
|
use_unicode_placeholder = true
|
||||||
}
|
}
|
||||||
|
base_id := uint32(opts.ImageId)
|
||||||
for num_of_items > 0 {
|
for num_of_items > 0 {
|
||||||
imgd := <-output_channel
|
imgd := <-output_channel
|
||||||
|
if base_id != 0 {
|
||||||
|
imgd.image_id = base_id
|
||||||
|
base_id++
|
||||||
|
if base_id == 0 {
|
||||||
|
base_id++
|
||||||
|
}
|
||||||
|
}
|
||||||
imgd.use_unicode_placeholder = use_unicode_placeholder
|
imgd.use_unicode_placeholder = use_unicode_placeholder
|
||||||
imgd.passthrough_mode = passthrough_mode
|
imgd.passthrough_mode = passthrough_mode
|
||||||
num_of_items--
|
num_of_items--
|
||||||
|
|||||||
@ -313,19 +313,21 @@ func transmit_image(imgd *image_data) {
|
|||||||
if f == nil {
|
if f == nil {
|
||||||
f = transmit_stream
|
f = transmit_stream
|
||||||
}
|
}
|
||||||
if imgd.use_unicode_placeholder {
|
if imgd.image_id == 0 {
|
||||||
for imgd.image_id&0xFF000000 == 0 || imgd.image_id&0x00FFFF00 == 0 {
|
if imgd.use_unicode_placeholder {
|
||||||
// Generate a 32-bit image id using rejection sampling such that the most
|
for imgd.image_id&0xFF000000 == 0 || imgd.image_id&0x00FFFF00 == 0 {
|
||||||
// significant byte and the two bytes in the middle are non-zero to avoid
|
// Generate a 32-bit image id using rejection sampling such that the most
|
||||||
// collisions with applications that cannot represent non-zero most
|
// significant byte and the two bytes in the middle are non-zero to avoid
|
||||||
// significant bytes (which is represented by the third combining character)
|
// collisions with applications that cannot represent non-zero most
|
||||||
// or two non-zero bytes in the middle (which requires 24-bit color mode).
|
// significant bytes (which is represented by the third combining character)
|
||||||
imgd.image_id = next_random()
|
// or two non-zero bytes in the middle (which requires 24-bit color mode).
|
||||||
}
|
imgd.image_id = next_random()
|
||||||
} else {
|
}
|
||||||
if len(imgd.frames) > 1 {
|
} else {
|
||||||
for imgd.image_number == 0 {
|
if len(imgd.frames) > 1 {
|
||||||
imgd.image_number = next_random()
|
for imgd.image_number == 0 {
|
||||||
|
imgd.image_number = next_random()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user