Hopefully this fixes #2

the position is now calculated with the help of font_pixel_width and
font_pixel_height

font_pixel_width = Total X Pixels / Total Columns
font_pixel_height = Total Y Pixels / Total Rows

which is then multiplied to row and column co-ordinates of preview box to get it's
pixel position.
This commit is contained in:
aditya-K2 2021-10-29 10:08:09 +05:30
parent f1aab8fb36
commit 97b2e4c4bc
1 changed files with 29 additions and 0 deletions

View File

@ -3,8 +3,37 @@ package main
import (
"strconv"
"strings"
"syscall"
"unsafe"
)
type winsize struct {
Row uint16
Col uint16
Xpixel uint16
Ypixel uint16
}
func getWidth() *winsize {
ws := &winsize{}
retCode, _, errno := syscall.Syscall(syscall.SYS_IOCTL,
uintptr(syscall.Stdin),
uintptr(syscall.TIOCGWINSZ),
uintptr(unsafe.Pointer(ws)))
if int(retCode) == -1 {
panic(errno)
}
return ws
}
func getFontWidth() (float32, float32) {
g := getWidth()
fw := (float32(g.Xpixel) / float32(g.Col))
fh := (float32(g.Ypixel) / float32(g.Row))
return fw, fh
}
func strTime(e float64) string {
a := int(e)
var min, seconds string