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:
parent
d867451ef6
commit
377d7af2c1
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
package terminal
|
package terminal
|
||||||
|
|
||||||
|
// RestoreInputMode 还原输入模式,非Windows系统永远返回nil
|
||||||
|
func RestoreInputMode() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// DisableQuickEdit 禁用快速编辑,非Windows系统永远返回nil
|
// DisableQuickEdit 禁用快速编辑,非Windows系统永远返回nil
|
||||||
func DisableQuickEdit() error {
|
func DisableQuickEdit() error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -6,6 +6,17 @@ import (
|
|||||||
"golang.org/x/sys/windows"
|
"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 禁用快速编辑
|
// DisableQuickEdit 禁用快速编辑
|
||||||
func DisableQuickEdit() error {
|
func DisableQuickEdit() error {
|
||||||
stdin := windows.Handle(os.Stdin.Fd())
|
stdin := windows.Handle(os.Stdin.Fd())
|
||||||
@ -15,6 +26,7 @@ func DisableQuickEdit() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
inputmode = mode
|
||||||
|
|
||||||
mode &^= windows.ENABLE_QUICK_EDIT_MODE // 禁用快速编辑模式
|
mode &^= windows.ENABLE_QUICK_EDIT_MODE // 禁用快速编辑模式
|
||||||
mode |= windows.ENABLE_EXTENDED_FLAGS // 启用扩展标志
|
mode |= windows.ENABLE_EXTENDED_FLAGS // 启用扩展标志
|
||||||
|
Loading…
x
Reference in New Issue
Block a user