Skip to content

Commit

Permalink
Revert original's PR 42 and 40
Browse files Browse the repository at this point in the history
  • Loading branch information
hymkor committed Feb 17, 2021
1 parent 1452421 commit ece7337
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions internal/github.com/mattn/go-tty/tty_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ var (
procScrollConsoleScreenBuffer = kernel32.NewProc("ScrollConsoleScreenBufferW")
)

const (
bitAltPressed = 1
bitNumPadPressed = 2
bitAltNumPadPressed = bitAltPressed | bitNumPadPressed
)

type wchar uint16
type short int16
type dword uint32
Expand Down Expand Up @@ -137,7 +131,7 @@ type TTY struct {
ws chan WINSIZE
sigwinchCtx context.Context
sigwinchCtxCancel context.CancelFunc
withAltNumPad int
readNextKeyUp bool
}

func readConsoleInput(fd uintptr, record *inputRecord) (err error) {
Expand Down Expand Up @@ -239,8 +233,8 @@ func (tty *TTY) readRune() (rune, error) {
case keyEvent:
kr := (*keyEventRecord)(unsafe.Pointer(&ir.event))
if kr.keyDown == 0 {
if kr.unicodeChar != 0 && tty.withAltNumPad == bitAltNumPadPressed {
tty.withAltNumPad = 0
if kr.unicodeChar != 0 && tty.readNextKeyUp {
tty.readNextKeyUp = false
return rune(kr.unicodeChar), nil
}
} else {
Expand Down Expand Up @@ -293,12 +287,7 @@ func (tty *TTY) readRune() (rune, error) {
switch vk {
case 0x12: // menu
if kr.controlKeyState&leftAltPressed != 0 {
tty.withAltNumPad = bitAltPressed
}
return 0, nil
case 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69: // numpad
if kr.controlKeyState&leftAltPressed != 0 {
tty.withAltNumPad |= bitNumPadPressed
tty.readNextKeyUp = true
}
return 0, nil
case 0x21: // page-up
Expand Down

0 comments on commit ece7337

Please sign in to comment.