15.04.2026 Update

This commit is contained in:
2026-04-15 12:25:39 +03:00
parent f50d79fab3
commit 91b4585175
5 changed files with 709 additions and 11 deletions

45
setup/termios_linux.go Normal file
View File

@@ -0,0 +1,45 @@
package setup
import (
"syscall"
"unsafe"
)
type termios struct {
Iflag uint32
Oflag uint32
Cflag uint32
Lflag uint32
Cc [20]byte
Ispeed uint32
Ospeed uint32
}
const (
tcgetattr = 0x5401
tcsetattr = 0x5402
TCSAFLUSH = 2
ECHO = 0x8
ICANON = 0x100
)
func termiosGetState(fd int) (*termios, bool) {
var state termios
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(tcgetattr), uintptr(unsafe.Pointer(&state))); err != 0 {
return nil, false
}
return &state, true
}
func termiosDisableEcho(fd int) {
var state termios
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(tcgetattr), uintptr(unsafe.Pointer(&state))); err != 0 {
return
}
state.Lflag &^= ECHO | ICANON
syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(tcsetattr), uintptr(unsafe.Pointer(&state)))
}
func termiosRestore(fd int, state *termios) {
syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(tcsetattr), uintptr(unsafe.Pointer(state)))
}