mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #249] Change textview's text on key press. #195
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#195
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @emmggi on GitHub (Mar 14, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/249
Sorry to be asking a question like this but i'm running in circles on how to do this.
I need to trigger the redraw of a textview on a keypress and have the "mode" change from one to another on each F1 keypress and have the text in textview update accordingly but i don't know what's the issue i'm facing.
Also I'm wondering can I set a minimum width for a table cell?
Here's my code
@rivo commented on GitHub (Mar 16, 2019):
Your key capture function doesn't fire because your
appobject is not used to run the application. At the end of your program, you instantiate a newApplicationobject. It should look like this, however:You also don't need to call
QueueUpdateDraw()from within theSetInputCapture()function. It is called implicitly. (See the Wiki for more information.)So it could like something like this:
Let me know if this answers your question.
@emmggi commented on GitHub (Mar 16, 2019):
I still don't understand how i can refresh the screen, sorry. This is from another app, the table is being overwritten by another table without the previous one clearing.
Also is there a way to set a minimum width for a table cell?
I tried to do something like
app.Draw()on each enter keypress because that's when i want it to happen. Ortable.Clear()but nothing happens.@rivo commented on GitHub (Mar 16, 2019):
I can't help you with the table without seeing the code for this. Please paste some code that will reproduce this issue.
Again, you don't need to call
app.Draw()on each key event as it's called automatically by the main application loop. Unless you're making use of goroutines, you probably don't need to callapp.Draw()anywhere at all. You can see in my code above that I'm not callingapp.Draw().There's no minimum width for a table cell. The column width of a table is chosen based on the widest cell in that column. You could pad your cell's text with spaces if you want it to be wider than its contained text.
To answer your other questions, I need more specific information, preferably code.
@emmggi commented on GitHub (Mar 16, 2019):
@rivo I'd say this is the most important part. The
startsearch()function returns a[]string. Each two values need to be one next to another in two columns, which they are at the moment. But as mentioned, it's not clearing the screen from the previous table when new one comes.@emmggi commented on GitHub (Mar 20, 2019):
Can this one be reopened? I'm still having issues with this.
@rivo commented on GitHub (Aug 29, 2019):
This issue kind of got lost. Apologies for that.
It seems that there's a misunderstanding regarding how
Grid.AddItem()works. Here's the documentation for it. And you might also want to check out the documentation forGrid.SetColumns().Grid rows and columns don't refer to the individual cells in a terminal window. A column can be multiple cells wide and a row can be multiple cells tall. In your example, let's assume that
maxW = 120. Now you're tellingtviewthat your table spansmaxW - 2 = 118columns. Does yourGridlayout really have that many columns? (Because you include borders, you must have a huge screen for that.)I wouldn't be surprised that given these numbers, you are getting some weird artefacts.
First of all, I think you don't need
maxWormaxHat all in your application. The idea oftviewis to let you create layouts independently of the actual screen resolution. Without having tested it, this is probably what you want:I'll reopen this again for a while in case you still have questions.
@emmggi commented on GitHub (Aug 29, 2019):
I've given up on using tview for this project. Thanks still for letting me know on the fix.