Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows use window.getConsoleMode results is not expected #408

Closed
fzdwx opened this issue Aug 19, 2022 · 9 comments · Fixed by #565
Closed

Windows use window.getConsoleMode results is not expected #408

fzdwx opened this issue Aug 19, 2022 · 9 comments · Fixed by #565
Assignees
Labels
bug Something isn't working

Comments

@fzdwx
Copy link

fzdwx commented Aug 19, 2022

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 在 #393 (comment) 发布

@meowgorithm meowgorithm changed the title Yes, it fixed! @meowgorithm windows.GetConsoleMode and arrow keys Aug 19, 2022
@fzdwx fzdwx changed the title windows.GetConsoleMode and arrow keys Windows use window.getConsoleMode results not expected Aug 19, 2022
@fzdwx fzdwx changed the title Windows use window.getConsoleMode results not expected Windows use window.getConsoleMode results is not expected Aug 19, 2022
@meowgorithm
Copy link
Member

meowgorithm commented Aug 19, 2022

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?

@fzdwx
Copy link
Author

fzdwx commented Aug 19, 2022

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

@muesli muesli self-assigned this Aug 19, 2022
@muesli
Copy link
Contributor

muesli commented Aug 19, 2022

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!

@meowgorithm meowgorithm added the bug Something isn't working label Aug 19, 2022
@muesli
Copy link
Contributor

muesli commented Sep 27, 2022

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 muesli closed this as completed Sep 27, 2022
@fzdwx
Copy link
Author

fzdwx commented Sep 27, 2022

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?

@muesli
Copy link
Contributor

muesli commented Sep 27, 2022

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 muesli reopened this Sep 27, 2022
@fzdwx
Copy link
Author

fzdwx commented Sep 27, 2022

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.

fzdwx/infinite#29 (comment)

@fzdwx
Copy link
Author

fzdwx commented Oct 22, 2022

OK, it works, Thanks!

@muesli
Copy link
Contributor

muesli commented Oct 22, 2022

OK, it works, Thanks!

Thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants