github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/pkg/progress/scanbar_unix.go (about) 1 //go:build !windows 2 // +build !windows 3 4 // Copyright 2021 The TrueBlocks Authors. All rights reserved. 5 // Use of this source code is governed by a license that can 6 // be found in the LICENSE file. 7 8 package progress 9 10 import ( 11 "syscall" 12 "unsafe" 13 ) 14 15 func screenWidth() uint { 16 ws := &winsize{} 17 retCode, _, _ := syscall.Syscall(syscall.SYS_IOCTL, 18 uintptr(syscall.Stdin), 19 uintptr(syscall.TIOCGWINSZ), 20 uintptr(unsafe.Pointer(ws))) 21 22 if int(retCode) == -1 { 23 // This is okay if we're debugging in VSCode for example 24 // logger.Error("System call to syscall.SYS_IOCTL returned: ", errno) 25 return 120 // default reasonably 26 } 27 return uint(ws.Col) 28 }