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

Liner does not print characters when shift is pressed #163

Open
elgopher opened this issue Aug 11, 2023 · 1 comment
Open

Liner does not print characters when shift is pressed #163

elgopher opened this issue Aug 11, 2023 · 1 comment

Comments

@elgopher
Copy link

elgopher commented Aug 11, 2023

Operating System

Windows 11

Terminal Emulator

  • Integrated terminal in VSCode
  • Integrated terminal in GoLand

Bug behaviour

Liner does not print characters when shift is pressed.

Write following characters in sequence: a (left arrow key) B

Liner prints: a

Expected behaviour

Liner should print Ba

Complete sample that reproduces the bug

package main

import (
	"fmt"

	"github.com/peterh/liner"
)

func main() {
	l := liner.NewLiner()
	line, err := l.Prompt("> ")
	if err != nil {
		panic(err)
	}

	fmt.Println(line)
}

Run the code from VScode or GoLand, then write in terminal a (left arrow key) B

elgopher added a commit to elgopher/pi that referenced this issue Aug 11, 2023
elgopher added a commit to elgopher/pi that referenced this issue Aug 12, 2023
This commit adds the ability to run Go code when the game is running. No need to compile, and restart the game. Just write the code in terminal, hit enter, and it will be immediately executed.

Go code is interpreted by traefik/yaegi interpreter. It is a Go interpreter compatible with standard Go compiler.

Lines are read from terminal by peterh/liner package. For now I'm using my fork of github.com/peterh/liner, because the original does not work well in Goland/VSCode on Win11 (see peterh/liner#163). This is temporary, until peterh/liner is fixed properly.

Limitations:
* MidInt, MaxInt, MinInt - those functions can be executed in terminal but only accepts int's (not int64, byte etc.)
* pi.Int cannot be used
* The size of compiled game with devtools is increased by 3.7MB (+35% increase), the compilation takes 21% more time. But it is worth it. I plan to add a possibility to disable scripting in the future though.
elgopher added a commit to elgopher/pi that referenced this issue Aug 12, 2023
This commit adds the ability to run Go code when the game is running. No need to compile, and restart the game. Just write the code in terminal, hit enter, and it will be immediately executed.

Go code is interpreted by traefik/yaegi interpreter. It is a Go interpreter compatible with standard Go compiler.

Lines are read from terminal by peterh/liner package. For now I'm using my fork of github.com/peterh/liner, because the original does not work well in Goland/VSCode on Win11 (see peterh/liner#163). This is temporary, until peterh/liner is fixed properly.

Limitations:
* MidInt, MaxInt, MinInt - those functions can be executed in terminal but only accepts int's (not int64, byte etc.)
* pi.Int cannot be used
* The size of compiled game with devtools is increased by 3.7MB (+35% increase), the compilation takes 21% more time. But it is worth it. I plan to add a possibility to disable scripting in the future though.
elgopher added a commit to elgopher/pi-template that referenced this issue Aug 12, 2023
@elgopher
Copy link
Author

elgopher commented Aug 14, 2023

I created a fork with a small change and it looks like the fix solved the problem, altough I am not sure I didn't broke something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant