1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

add RestoreInputMode

This commit is contained in:
源文雨 2023-02-28 22:47:23 +08:00
parent d867451ef6
commit 377d7af2c1
3 changed files with 18 additions and 0 deletions

View File

@ -2,6 +2,11 @@
package terminal
// RestoreInputMode 还原输入模式非Windows系统永远返回nil
func RestoreInputMode() error {
return nil
}
// DisableQuickEdit 禁用快速编辑非Windows系统永远返回nil
func DisableQuickEdit() error {
return nil

View File

@ -6,6 +6,17 @@ import (
"golang.org/x/sys/windows"
)
var inputmode uint32
// RestoreInputMode 还原输入模式
func RestoreInputMode() error {
if inputmode == 0 {
return nil
}
stdin := windows.Handle(os.Stdin.Fd())
return windows.SetConsoleMode(stdin, mode)
}
// DisableQuickEdit 禁用快速编辑
func DisableQuickEdit() error {
stdin := windows.Handle(os.Stdin.Fd())
@ -15,6 +26,7 @@ func DisableQuickEdit() error {
if err != nil {
return err
}
inputmode = mode
mode &^= windows.ENABLE_QUICK_EDIT_MODE // 禁用快速编辑模式
mode |= windows.ENABLE_EXTENDED_FLAGS // 启用扩展标志

View File

@ -18,4 +18,5 @@ func main() {
_ = terminal.DisableQuickEdit()
_ = terminal.EnableVT100()
gocq.Main()
_ = terminal.RestoreInputMode()
}