mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
More linter fixes
This commit is contained in:
@@ -38,14 +38,14 @@ func DetectSupport(timeout time.Duration) (memory, files, direct bool, err error
|
||||
}
|
||||
if len(shm_files_to_delete) > 0 && transfer_by_memory != supported {
|
||||
for _, name := range shm_files_to_delete {
|
||||
name.Unlink()
|
||||
_ = name.Unlink()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
lp.OnInitialize = func() (string, error) {
|
||||
var iid uint32
|
||||
lp.AddTimer(timeout, false, func(loop.IdType) error {
|
||||
_, _ = lp.AddTimer(timeout, false, func(loop.IdType) error {
|
||||
return fmt.Errorf("Timed out waiting for a response form the terminal: %w", os.ErrDeadlineExceeded)
|
||||
})
|
||||
|
||||
@@ -54,7 +54,7 @@ func DetectSupport(timeout time.Duration) (memory, files, direct bool, err error
|
||||
g1 := &graphics.GraphicsCommand{}
|
||||
g1.SetTransmission(t).SetAction(graphics.GRT_action_query).SetImageId(iid).SetDataWidth(1).SetDataHeight(1).SetFormat(
|
||||
graphics.GRT_format_rgb).SetDataSize(uint64(len(payload)))
|
||||
g1.WriteWithPayloadToLoop(lp, utils.UnsafeStringToBytes(payload))
|
||||
_ = g1.WriteWithPayloadToLoop(lp, utils.UnsafeStringToBytes(payload))
|
||||
return iid
|
||||
}
|
||||
|
||||
@@ -63,7 +63,9 @@ func DetectSupport(timeout time.Duration) (memory, files, direct bool, err error
|
||||
if err == nil {
|
||||
file_query_id = g(graphics.GRT_transmission_tempfile, tf.Name())
|
||||
temp_files_to_delete = append(temp_files_to_delete, tf.Name())
|
||||
tf.Write([]byte{1, 2, 3})
|
||||
if _, err = tf.Write([]byte{1, 2, 3}); err != nil {
|
||||
print_error("Failed to write to temporary file for data transfer, file based transfer is disabled. Error: %v", err)
|
||||
}
|
||||
tf.Close()
|
||||
} else {
|
||||
print_error("Failed to create temporary file for data transfer, file based transfer is disabled. Error: %v", err)
|
||||
|
||||
@@ -42,7 +42,7 @@ const (
|
||||
supported
|
||||
)
|
||||
|
||||
var transfer_by_file, transfer_by_memory, transfer_by_stream transfer_mode
|
||||
var transfer_by_file, transfer_by_memory transfer_mode
|
||||
|
||||
var files_channel chan input_arg
|
||||
var output_channel chan *image_data
|
||||
@@ -162,7 +162,9 @@ func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
if opts.Clear {
|
||||
cc := &graphics.GraphicsCommand{}
|
||||
cc.SetAction(graphics.GRT_action_delete).SetDelete(graphics.GRT_free_visible)
|
||||
cc.WriteWithPayloadTo(os.Stdout, nil)
|
||||
if err = cc.WriteWithPayloadTo(os.Stdout, nil); err != nil {
|
||||
return 1, err
|
||||
}
|
||||
}
|
||||
if screen_size.Xpixel == 0 || screen_size.Ypixel == 0 {
|
||||
return 1, fmt.Errorf("Terminal does not support reporting screen sizes in pixels, use a terminal such as kitty, WezTerm, Konsole, etc. that does.")
|
||||
@@ -224,7 +226,6 @@ func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
// tmux doesn't allow responses from the terminal so we can't detect if memory or file based transferring is supported
|
||||
transfer_by_memory = unsupported
|
||||
transfer_by_file = unsupported
|
||||
transfer_by_stream = supported
|
||||
}
|
||||
if opts.DetectSupport {
|
||||
if transfer_by_memory == supported {
|
||||
|
||||
@@ -123,6 +123,7 @@ func load_one_frame_image(ctx *images.Context, imgd *image_data, src *opened_inp
|
||||
}
|
||||
|
||||
var debugprintln = tty.DebugPrintln
|
||||
var _ = debugprintln
|
||||
|
||||
func (frame *image_frame) set_disposal(anchor_frame int, disposal byte) int {
|
||||
anchor_frame, frame.compose_onto = images.SetGIFFrameDisposal(frame.number, anchor_frame, disposal)
|
||||
|
||||
@@ -93,7 +93,7 @@ func process_dirs(args ...string) (results []input_arg, err error) {
|
||||
return nil, &fs.PathError{Op: "Stat", Path: arg, Err: err}
|
||||
}
|
||||
if s.IsDir() {
|
||||
filepath.WalkDir(arg, func(path string, d fs.DirEntry, walk_err error) error {
|
||||
if err = filepath.WalkDir(arg, func(path string, d fs.DirEntry, walk_err error) error {
|
||||
if walk_err != nil {
|
||||
if d == nil {
|
||||
err = &fs.PathError{Op: "Stat", Path: arg, Err: walk_err}
|
||||
@@ -107,7 +107,9 @@ func process_dirs(args ...string) (results []input_arg, err error) {
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
results = append(results, input_arg{arg: arg, value: arg})
|
||||
}
|
||||
@@ -124,7 +126,7 @@ type opened_input struct {
|
||||
|
||||
func (self *opened_input) Rewind() {
|
||||
if self.file != nil {
|
||||
self.file.Seek(0, io.SeekStart)
|
||||
_, _ = self.file.Seek(0, io.SeekStart)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ func transmit_shm(imgd *image_data, frame_num int, frame *image_frame) (err erro
|
||||
}
|
||||
defer f.Close()
|
||||
data_size, _ = f.Seek(0, io.SeekEnd)
|
||||
f.Seek(0, io.SeekStart)
|
||||
_, _ = f.Seek(0, io.SeekStart)
|
||||
mmap, err = shm.CreateTemp("icat-*", uint64(data_size))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create a SHM file for transmission: %w", err)
|
||||
@@ -108,7 +108,7 @@ func transmit_shm(imgd *image_data, frame_num int, frame *image_frame) (err erro
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
}
|
||||
mmap.Unlink()
|
||||
_ = mmap.Unlink()
|
||||
return fmt.Errorf("Failed to read data from image output data file: %w", err)
|
||||
}
|
||||
}
|
||||
@@ -128,10 +128,10 @@ func transmit_shm(imgd *image_data, frame_num int, frame *image_frame) (err erro
|
||||
gc := gc_for_image(imgd, frame_num, frame)
|
||||
gc.SetTransmission(graphics.GRT_transmission_sharedmem)
|
||||
gc.SetDataSize(uint64(data_size))
|
||||
gc.WriteWithPayloadTo(os.Stdout, utils.UnsafeStringToBytes(mmap.Name()))
|
||||
err = gc.WriteWithPayloadTo(os.Stdout, utils.UnsafeStringToBytes(mmap.Name()))
|
||||
mmap.Close()
|
||||
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
func transmit_file(imgd *image_data, frame_num int, frame *image_frame) (err error) {
|
||||
@@ -174,8 +174,7 @@ func transmit_file(imgd *image_data, frame_num int, frame *image_frame) (err err
|
||||
if data_size > 0 {
|
||||
gc.SetDataSize(uint64(data_size))
|
||||
}
|
||||
gc.WriteWithPayloadTo(os.Stdout, utils.UnsafeStringToBytes(fname))
|
||||
return nil
|
||||
return gc.WriteWithPayloadTo(os.Stdout, utils.UnsafeStringToBytes(fname))
|
||||
}
|
||||
|
||||
func transmit_stream(imgd *image_data, frame_num int, frame *image_frame) (err error) {
|
||||
@@ -192,8 +191,7 @@ func transmit_stream(imgd *image_data, frame_num int, frame *image_frame) (err e
|
||||
}
|
||||
}
|
||||
gc := gc_for_image(imgd, frame_num, frame)
|
||||
gc.WriteWithPayloadTo(os.Stdout, data)
|
||||
return nil
|
||||
return gc.WriteWithPayloadTo(os.Stdout, data)
|
||||
}
|
||||
|
||||
func calculate_in_cell_x_offset(width, cell_width int) int {
|
||||
@@ -291,7 +289,7 @@ func transmit_image(imgd *image_data) {
|
||||
frame.filename = ""
|
||||
}
|
||||
if frame.shm != nil {
|
||||
frame.shm.Unlink()
|
||||
_ = frame.shm.Unlink()
|
||||
frame.shm.Close()
|
||||
frame.shm = nil
|
||||
}
|
||||
@@ -386,11 +384,15 @@ func transmit_image(imgd *image_data) {
|
||||
case opts.Loop > 0:
|
||||
c.SetNumberOfLoops(uint64(opts.Loop) + 1)
|
||||
}
|
||||
c.WriteWithPayloadTo(os.Stdout, nil)
|
||||
if imgd.err = c.WriteWithPayloadTo(os.Stdout, nil); imgd.err != nil {
|
||||
return
|
||||
}
|
||||
case 1:
|
||||
c := frame_control_cmd
|
||||
c.SetAnimationControl(2) // set animation to loading mode
|
||||
c.WriteWithPayloadTo(os.Stdout, nil)
|
||||
if imgd.err = c.WriteWithPayloadTo(os.Stdout, nil); imgd.err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +402,9 @@ func transmit_image(imgd *image_data) {
|
||||
if is_animated {
|
||||
c := frame_control_cmd
|
||||
c.SetAnimationControl(3) // set animation to normal mode
|
||||
c.WriteWithPayloadTo(os.Stdout, nil)
|
||||
if imgd.err = c.WriteWithPayloadTo(os.Stdout, nil); imgd.err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
if imgd.move_to.x == 0 {
|
||||
fmt.Println() // ensure cursor is on new line
|
||||
|
||||
Reference in New Issue
Block a user