bubbletea
bubbletea copied to clipboard
Windows use `window.getConsoleMode` results is not expected
On Windows run tea.program use windows.GetConsoleMode
-> 992
but default mode is 503
, so after running, the input direction key will be recognized as [[A
code:
package main
import (
"fmt"
"golang.org/x/sys/windows"
"unicode/utf16"
)
var fileShareValidFlags uint32 = 0x00000007
func main() {
var originalMode uint32
handle, _ := windows.CreateFile(
&(utf16.Encode([]rune("CONIN$\x00"))[0]), windows.GENERIC_READ|windows.GENERIC_WRITE,
fileShareValidFlags, nil, windows.OPEN_EXISTING, windows.FILE_FLAG_OVERLAPPED, 0)
_ = windows.GetConsoleMode(handle, &originalMode)
// 503
fmt.Println(originalMode)
// problematic mode
//windows.SetConsoleMode(handle, 992)
}
ζεη± fzdwx ε¨ https://github.com/charmbracelet/bubbletea/issues/393#issuecomment-1220136297 εεΈ
Just to make sure weβre understanding correctly, you're saying that arrow keys don't work properly after a Bubble Tea program exits, right?
Just so we understand correctly, you're saying that arrow keys don't work properly after a Bubble Tea program exits, right?
Yes, my English may not be good, the description is not very accurate, sorry
Yes, my English may not be good, the description is not very accurate, sorry
Don't worry, I think I see the problem and will provide a fix soon!
This should be fixed by #455. We try to restore the original mode on shutdown now. Please let us know if this works for you!
The problem seems to still exist...
git clone https://github.com/charmbracelet/bubbletea.git
cd bubbletea\examples\textinput && go run .
press <Up>
-> ^[[A
Do I need to wait until release to test?
No, that test was fine, and clearly there's still something wrong then. I'll re-open and investigate. How do you exit the textinput example?
No, that test was fine, and clearly there's still something wrong then. I'll re-open and investigate. How do you exit the textinput example?
When I'm done typing, hit enter.
The originalMode read under normal circumstances should be 503, but this value is not read in tea.
https://github.com/fzdwx/infinite/issues/29#issuecomment-1217981955
OK, it works, Thanks!
OK, it works, Thanks!
Thanks for confirming!