| 1 |
package ansi |
| 2 |
|
| 3 |
import "fmt" |
| 4 |
|
| 5 |
// InBandResize encodes an in-band terminal resize event sequence. |
| 6 |
// |
| 7 |
// CSI 48 ; height_cells ; widht_cells ; height_pixels ; width_pixels t |
| 8 |
// |
| 9 |
// See https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83 |
| 10 |
func InBandResize(heightCells, widthCells, heightPixels, widthPixels int) string { |
| 11 |
if heightCells < 0 { |
| 12 |
heightCells = 0 |
| 13 |
} |
| 14 |
if widthCells < 0 { |
| 15 |
widthCells = 0 |
| 16 |
} |
| 17 |
if heightPixels < 0 { |
| 18 |
heightPixels = 0 |
| 19 |
} |
| 20 |
if widthPixels < 0 { |
| 21 |
widthPixels = 0 |
| 22 |
} |
| 23 |
return fmt.Sprintf("\x1b[48;%d;%d;%d;%dt", heightCells, widthCells, heightPixels, widthPixels) |
| 24 |
} |