本文整理匯總了Golang中syscall.Termios.Iflag方法的典型用法代碼示例。如果您正苦於以下問題:Golang Termios.Iflag方法的具體用法?Golang Termios.Iflag怎麽用?Golang Termios.Iflag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類syscall.Termios
的用法示例。
在下文中一共展示了Termios.Iflag方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Init
func (s *Screen) Init() error {
var err error
ttyIn, err = os.OpenFile("/dev/tty", os.O_RDWR, 0666)
if err != nil {
return err
}
ttyOut, err = os.OpenFile("/dev/tty", os.O_RDONLY, 0666)
if err != nil {
return err
}
orig = new(syscall.Termios)
err = tcgetattr(ttyIn.Fd(), orig)
if err != nil {
return err
}
tios := new(syscall.Termios)
*tios = *orig
tios.Iflag &= ^uint32(syscall.ECHO | syscall.ICANON | syscall.IEXTEN | syscall.ISIG)
tios.Iflag &= ^uint32(syscall.BRKINT | syscall.ICRNL | syscall.ISTRIP | syscall.IXON)
tios.Cflag &= ^uint32(syscall.CSIZE | syscall.PARENB)
tios.Cflag |= syscall.CS8
tios.Oflag &= ^uint32(syscall.OPOST)
tios.Cc[syscall.VMIN] = 1
tios.Cc[syscall.VTIME] = 0
err = tcsetattr(ttyIn.Fd(), tios)
if err != nil {
return err
}
s.HideCursor()
s.Clear()
return nil
}
示例2: Set
func (i *iflagSetter) Set(pty *os.File, termios *syscall.Termios, value uint32) error {
if value == 0 {
termios.Iflag &^= i.Flag
} else {
termios.Iflag |= i.Flag
}
return SetAttr(pty, termios)
}
示例3: Cfmakeraw
// Cfmakeraw modifies attr for raw mode.
func Cfmakeraw(attr *syscall.Termios) {
attr.Iflag &^= syscall.BRKINT | syscall.ICRNL | syscall.INPCK | syscall.ISTRIP | syscall.IXON
attr.Oflag &^= syscall.OPOST
attr.Cflag &^= syscall.CSIZE | syscall.PARENB
attr.Cflag |= syscall.CS8
attr.Lflag &^= syscall.ECHO | syscall.ICANON | syscall.IEXTEN | syscall.ISIG
attr.Cc[syscall.VMIN] = 1
attr.Cc[syscall.VTIME] = 0
}
示例4: rawModeTerm
// returns non-canonical mode term for keybind
func rawModeTerm(term syscall.Termios) syscall.Termios {
term.Iflag &= syscall.IGNCR // ignore received CR
term.Lflag ^= syscall.ICANON // disable canonical mode
term.Lflag ^= syscall.ECHO // disable echo of input
term.Lflag ^= syscall.ISIG // disable signal
term.Cc[syscall.VMIN] = 1 // number of bytes to read()
term.Cc[syscall.VTIME] = 0 // timeout of read()
return term
}
示例5: setTermSettingsParity
func setTermSettingsParity(parity Parity, settings *syscall.Termios) error {
switch parity {
case NoParity:
settings.Cflag &= ^termiosMask(syscall.PARENB | syscall.PARODD | tcCMSPAR)
settings.Iflag &= ^termiosMask(syscall.INPCK)
case OddParity:
settings.Cflag |= termiosMask(syscall.PARENB | syscall.PARODD)
settings.Cflag &= ^termiosMask(tcCMSPAR)
settings.Iflag |= termiosMask(syscall.INPCK)
case EvenParity:
settings.Cflag &= ^termiosMask(syscall.PARODD | tcCMSPAR)
settings.Cflag |= termiosMask(syscall.PARENB)
settings.Iflag |= termiosMask(syscall.INPCK)
case MarkParity:
settings.Cflag |= termiosMask(syscall.PARENB | syscall.PARODD | tcCMSPAR)
settings.Iflag |= termiosMask(syscall.INPCK)
case SpaceParity:
settings.Cflag &= ^termiosMask(syscall.PARODD)
settings.Cflag |= termiosMask(syscall.PARENB | tcCMSPAR)
settings.Iflag |= termiosMask(syscall.INPCK)
}
return nil
}
示例6: setTermSettingsParity
func setTermSettingsParity(parity Parity, settings *syscall.Termios) error {
switch parity {
case PARITY_NONE:
settings.Cflag &= ^termiosMask(syscall.PARENB | syscall.PARODD | tc_CMSPAR)
settings.Iflag &= ^termiosMask(syscall.INPCK)
case PARITY_ODD:
settings.Cflag |= termiosMask(syscall.PARENB | syscall.PARODD)
settings.Cflag &= ^termiosMask(tc_CMSPAR)
settings.Iflag |= termiosMask(syscall.INPCK)
case PARITY_EVEN:
settings.Cflag &= ^termiosMask(syscall.PARODD | tc_CMSPAR)
settings.Cflag |= termiosMask(syscall.PARENB)
settings.Iflag |= termiosMask(syscall.INPCK)
case PARITY_MARK:
settings.Cflag |= termiosMask(syscall.PARENB | syscall.PARODD | tc_CMSPAR)
settings.Iflag |= termiosMask(syscall.INPCK)
case PARITY_SPACE:
settings.Cflag &= ^termiosMask(syscall.PARODD)
settings.Cflag |= termiosMask(syscall.PARENB | tc_CMSPAR)
settings.Iflag |= termiosMask(syscall.INPCK)
}
return nil
}
示例7: setRawMode
func setRawMode(settings *syscall.Termios) {
// Set local mode
settings.Cflag |= termiosMask(syscall.CREAD | syscall.CLOCAL)
// Set raw mode
settings.Lflag &= ^termiosMask(syscall.ICANON | syscall.ECHO | syscall.ECHOE | syscall.ECHOK |
syscall.ECHONL | syscall.ECHOCTL | syscall.ECHOPRT | syscall.ECHOKE | syscall.ISIG | syscall.IEXTEN)
settings.Iflag &= ^termiosMask(syscall.IXON | syscall.IXOFF | syscall.IXANY | syscall.INPCK |
syscall.IGNPAR | syscall.PARMRK | syscall.ISTRIP | syscall.IGNBRK | syscall.BRKINT | syscall.INLCR |
syscall.IGNCR | syscall.ICRNL | tcIUCLC)
settings.Oflag &= ^termiosMask(syscall.OPOST)
// Block reads until at least one char is available (no timeout)
settings.Cc[syscall.VMIN] = 1
settings.Cc[syscall.VTIME] = 0
}
示例8: setRawMode
func setRawMode(settings *syscall.Termios, mode *Mode) {
// Set local mode
settings.Cflag |= termiosMask(syscall.CREAD | syscall.CLOCAL)
// Set raw mode
settings.Lflag &= ^termiosMask(syscall.ICANON | syscall.ECHO | syscall.ECHOE | syscall.ECHOK |
syscall.ECHONL | syscall.ECHOCTL | syscall.ECHOPRT | syscall.ECHOKE | syscall.ISIG | syscall.IEXTEN)
settings.Iflag &= ^termiosMask(syscall.IXON | syscall.IXOFF | syscall.IXANY | syscall.INPCK |
syscall.IGNPAR | syscall.PARMRK | syscall.ISTRIP | syscall.IGNBRK | syscall.BRKINT | syscall.INLCR |
syscall.IGNCR | syscall.ICRNL | tc_IUCLC)
settings.Oflag &= ^termiosMask(syscall.OPOST)
if mode.Vmin == 0 && mode.Vtimeout == 0 {
// Switch to default mode
// Block reads until at least one char is available (no timeout)
mode.Vmin = 1
}
settings.Cc[syscall.VMIN] = mode.Vmin
settings.Cc[syscall.VTIME] = mode.Vtimeout
}