fixed flickering on all platforms

This commit is contained in:
2024-10-04 22:55:30 +02:00
parent 0f052d7652
commit d4f6c4104d
4 changed files with 10 additions and 29 deletions
-24
View File
@@ -11,7 +11,6 @@ import (
"github.com/nathan-fiscaletti/consolesize-go"
"github.com/orus-dev/osui/colors"
"golang.org/x/term"
)
var re = regexp.MustCompile(`(\x1b\[([0-9;]*)[a-zA-Z])+`)
@@ -71,11 +70,6 @@ func RenderOnFrame(c Component, frame *[]string) {
}
func ReadKey() (string, error) {
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
if err != nil {
return "", err
}
defer term.Restore(int(os.Stdin.Fd()), oldState)
var b [3]byte
n, err := os.Stdin.Read(b[:])
if err != nil {
@@ -84,24 +78,6 @@ func ReadKey() (string, error) {
return string(b[:n]), nil
}
func DisableEcho() {
switch runtime.GOOS {
case "windows":
// Need to implement this later
default:
exec.Command("stty", "-F", "/dev/tty", "-echo").Run()
}
}
func EnableEcho() {
switch runtime.GOOS {
case "windows":
// Need to implement this later
default:
exec.Command("stty", "-F", "/dev/tty", "echo").Run()
}
}
func NewFrame(width, height int) []string {
frame := make([]string, height)
for i := 0; i < height; i++ {