mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-16 13:08:25 +00:00
The hard-coded 0x5402/0x5403/0x5404 are the x86 (generic) values. On powerpc TCSETS, TCSETSW and TCSETSF are 0x802c7414..6, so Tcsetattr failed with ENOTTY and every kitten that sets terminal modes exited at once: on ppc64le the paste confirmation (kitten ask) only flickered and the paste was dropped. x/sys/unix defines the right value per architecture, as already used for TCGETS in Tcgetattr and for TIOCSETA* in tty_bsd.go. Drop the rest of the constant block too: copied from pkg/term, unused, and also x86-only. Verified on ppc64le: kitten ask under script(1) failed with "inappropriate ioctl for device" (strace: ioctl 0x5402 = -ENOTTY); with this change the TCSETS ioctl succeeds and the prompt runs.
24 lines
535 B
Go
24 lines
535 B
Go
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
|
|
|
|
package tty
|
|
|
|
import "golang.org/x/sys/unix"
|
|
|
|
func Tcgetattr(fd int, argp *unix.Termios) error {
|
|
return unix.IoctlSetTermios(fd, unix.TCGETS, argp)
|
|
}
|
|
|
|
func Tcsetattr(fd int, action uintptr, argp *unix.Termios) error {
|
|
var request uint
|
|
switch action {
|
|
case TCSANOW:
|
|
request = unix.TCSETS
|
|
case TCSADRAIN:
|
|
request = unix.TCSETSW
|
|
case TCSAFLUSH:
|
|
request = unix.TCSETSF
|
|
default:
|
|
return unix.EINVAL
|
|
}
|
|
return unix.IoctlSetTermios(fd, request, argp)
|
|
}
|