Debian Codegraph @

writer/terminal/helper.go

raw
1 package terminal
2
3 //
4 //import (
5 // "image/color"
6 // "os"
7 // "syscall"
8 // "unsafe"
9 //)
10 //
11 //const defaultRatio float64 = 7.0 / 3.0 // The terminal's default cursor width/height ratio
12 //
13 //func terminalSize() (int, int, float64) {
14 // var size [4]uint16
15 // if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL,
16 // uintptr(os.Stdout.Fd()), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&size)),
17 // 0, 0, 0); err != 0 {
18 // panic(err)
19 // }
20 // rows, cols, width, height := size[0], size[1], size[2], size[3]
21 //
22 // whratio := defaultRatio
23 // if width > 0 && height > 0 {
24 // whratio = float64(height/rows) / float64(width/cols)
25 // }
26 //
27 // return int(cols), int(rows), whratio
28 //}
29 //
30 //func terminalColor(rgb color.RGBA) uint16 {
31 // r := (((rgb.R * 5) + 127) / 255) * 36
32 // g := (((rgb.G * 5) + 127) / 255) * 6
33 // b := ((rgb.B * 5) + 127) / 255
34 //
35 // return uint16(r+g+b) + 16 + 1 // termbox default color offset
36 //}