bubbletea icon indicating copy to clipboard operation
bubbletea copied to clipboard

Windows use `window.getConsoleMode` results is not expected

Open fzdwx opened this issue 2 years ago β€’ 3 comments

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

image

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 发布

fzdwx avatar Aug 19 '22 15:08 fzdwx

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?

meowgorithm avatar Aug 19 '22 15:08 meowgorithm

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

fzdwx avatar Aug 19 '22 15:08 fzdwx

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!

muesli avatar Aug 19 '22 16:08 muesli

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!

muesli avatar Sep 27 '22 07:09 muesli

The problem seems to still exist...

git clone https://github.com/charmbracelet/bubbletea.git
cd bubbletea\examples\textinput && go run .

press <Up> -> ^[[A

image


Do I need to wait until release to test?

fzdwx avatar Sep 27 '22 07:09 fzdwx

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?

muesli avatar Sep 27 '22 07:09 muesli

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.

screen


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

fzdwx avatar Sep 27 '22 07:09 fzdwx

OK, it works, Thanks!

fzdwx avatar Oct 22 '22 01:10 fzdwx

OK, it works, Thanks!

Thanks for confirming!

muesli avatar Oct 22 '22 10:10 muesli