mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-10-26 15:13:22 +03:00
icat: Nicer error when user specifies invalid screen geometry
This commit is contained in:
parent
d08a44ea4c
commit
a3d8be5e2f
@ -182,6 +182,12 @@ func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
return 1, fmt.Errorf("Invalid size specification: %s with error: %w", opts.UseWindowSize, err)
|
||||
}
|
||||
screen_size.Ypixel = uint16(t)
|
||||
if screen_size.Xpixel < screen_size.Col {
|
||||
return 1, fmt.Errorf("Invalid size specification: %s with error: The pixel width is smaller than the number of columns", opts.UseWindowSize)
|
||||
}
|
||||
if screen_size.Ypixel < screen_size.Row {
|
||||
return 1, fmt.Errorf("Invalid size specification: %s with error: The pixel height is smaller than the number of rows", opts.UseWindowSize)
|
||||
}
|
||||
}
|
||||
|
||||
if opts.PrintWindowSize {
|
||||
|
@ -210,8 +210,8 @@ func calculate_in_cell_x_offset(width, cell_width int) int {
|
||||
}
|
||||
|
||||
func place_cursor(imgd *image_data) {
|
||||
cw := int(screen_size.Xpixel) / int(screen_size.Col)
|
||||
ch := int(screen_size.Ypixel) / int(screen_size.Row)
|
||||
cw := max(int(screen_size.Xpixel)/int(screen_size.Col), 1)
|
||||
ch := max(int(screen_size.Ypixel)/int(screen_size.Row), 1)
|
||||
imgd.cell_x_offset = calculate_in_cell_x_offset(imgd.canvas_width, cw)
|
||||
imgd.width_cells = int(math.Ceil(float64(imgd.canvas_width) / float64(cw)))
|
||||
imgd.height_cells = int(math.Ceil(float64(imgd.canvas_height) / float64(ch)))
|
||||
|
Loading…
Reference in New Issue
Block a user