mirror of
https://github.com/hymkor/lispect.git
synced 2026-08-28 04:46:59 -04:00
Replace Ctrl-H to Backspace because Ctrl-H removes all input text on CMD.exe
The reason is unknown
This commit is contained in:
+12
-4
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -26,10 +25,19 @@ func NewWatcher(pty io.ReadWriter) *Watcher {
|
|||||||
for {
|
for {
|
||||||
var buffer [1024]byte
|
var buffer [1024]byte
|
||||||
n, _ := os.Stdin.Read(buffer[:])
|
n, _ := os.Stdin.Read(buffer[:])
|
||||||
pty.Write(buffer[:n])
|
B := buffer[:n]
|
||||||
if bytes.IndexByte(buffer[:n], '\x03') >= 0 {
|
for i, b := range B {
|
||||||
ctrlc <- struct{}{}
|
if b == '\x03' {
|
||||||
|
ctrlc <- struct{}{}
|
||||||
|
return
|
||||||
|
} else if b == '\x08' {
|
||||||
|
// On CMD.exe, Ctrl-H removes all input text.
|
||||||
|
// ( The reason is unknown )
|
||||||
|
// Therefore, replace Ctrl-H to Backspace-key
|
||||||
|
buffer[i] = '\x7F'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
pty.Write(B)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user