-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Area Update after return
/ or when typing in the terminal
#422
Comments
Why aren't you using the PTerm interactive printers, if I may ask?
I think the only way to avoid letting users mess up the output, would be to disable user input while the area is running. Do you use user input, while the Area is running? If you want to disable user input, while the area is running, you could use this snippet: func main() {
area, _ := pterm.DefaultArea.Start()
running := true // We will maybe expose area.IsActive so this wouldn't be needed
go func() {
keyboard.Listen(func(key keys.Key) (stop bool, err error) {
return !running, nil
})
}()
for i := 0; i < 10; i++ {
str, _ := pterm.DefaultBigText.WithLetters(putils.LettersFromString(time.Now().Format("15:04:05"))).Srender()
str = pterm.DefaultCenter.Sprint(str)
area.Update(str)
time.Sleep(time.Second)
}
area.Stop()
running = false
} This snippet uses https://atomicgo.dev/keyboard (PTerm also uses this internally for the interactive printers) I hope this helps, let me know if you need more help :) |
@MarvinJWendt thanks for the ideas! So, just to be a bit more clear on the ask, the Table Area which updates dynamically, is a sort of monitoring table, not something which shall end after 10 iterations or 2 minutes or when a download is finished. The user may enter commands, while still monitoring this table - in an ideal scenario 1- Interactive Printer: I'm using an auto complete feature which I don't think is supported here. This being said and regardless of the autocomplete, I don't think that the interactive printer could be combined with an Area component which updates itself in parallel? 2- I like the idea of disabling the user input, then maybe it could be tweaked with some special key, such as when pressing escape, or tab, it would stop the Area update and gives back control to the user. Not ideal, but ... |
Ah, yeah I think we should be able to fix that. I'll take a look soon! |
I'm not sure whether it's a feature request or a bug report. I'm using the Area component (which renders a dynamic table) along with some interactive inputs which require a user input on the command line (not part of this library). Whenever the area renders, the cursor will move back to the beginning of the line. Also, if the user creates a new line in the terminal (by clicking on return), it will break the table (see below).
Simple example is just to use the clock of the example, then click a few times on return
The text was updated successfully, but these errors were encountered: