added titignore
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
//go:build darwin
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func termWidth() int {
|
||||
var ws struct{ Row, Col, Xpixel, Ypixel uint16 }
|
||||
_, _, e := syscall.Syscall(syscall.SYS_IOCTL, uintptr(os.Stdin.Fd()), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws)))
|
||||
if e != 0 || ws.Col == 0 {
|
||||
return 80
|
||||
}
|
||||
return int(ws.Col)
|
||||
}
|
||||
|
||||
func isTerminal(fd int) bool {
|
||||
var t syscall.Termios
|
||||
_, _, e := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCGETA, uintptr(unsafe.Pointer(&t)))
|
||||
return e == 0
|
||||
}
|
||||
|
||||
func makeRaw(fd int) (func(), error) {
|
||||
var old syscall.Termios
|
||||
if _, _, e := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCGETA, uintptr(unsafe.Pointer(&old))); e != 0 {
|
||||
return nil, e
|
||||
}
|
||||
raw := old
|
||||
raw.Iflag &^= syscall.ICRNL | syscall.IXON | syscall.BRKINT | syscall.INPCK | syscall.ISTRIP
|
||||
raw.Oflag &^= syscall.OPOST
|
||||
raw.Lflag &^= syscall.ECHO | syscall.ICANON | syscall.ISIG | syscall.IEXTEN
|
||||
raw.Cflag |= syscall.CS8
|
||||
if _, _, e := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCSETA, uintptr(unsafe.Pointer(&raw))); e != 0 {
|
||||
return nil, e
|
||||
}
|
||||
return func() {
|
||||
syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCSETA, uintptr(unsafe.Pointer(&old)))
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user