mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #65] Project is missing examples/demos #48
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#48
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 @KingRikkie on GitHub (Mar 5, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/65
First I'd like to tell you that your project certainly is awesome and the most complete TUI package. I looked into gocui first but as development has been on hold since over half a year now I went with tview.
Unfortunately your repo is lacking examples and demo applications, for example how do I colorize Text per line inside a
TextViewwithout enabling dynamic color? What about #52 ? How do I useSetAfterDrawFunc()and alike in a real world project? How to alterSetBorder()to only show a single border line instead of the default double-line on focus? I have a hard time getting through the needed setup/adjustments for my solution (but maybe it's just me).gocui has a nice list of projects using it where I can look at different implementions for a broad spectrum of various elements and methods. tview is young but if we don't have anything to link yet then please provide more (pseudo) real world examples, Postgres is not enough.
Do you have any complex (WIP) demos?
@rivo commented on GitHub (Mar 5, 2018):
Hi, I'm glad you like
tview. Let me address your questions:There are a bunch of demos in the repo and in the Wiki. They're meant to get you started with the different primitives so I kept them fairly simple. If you want to go more in-depth, you will have to refer to the documentation.
This is not possible. If you want to colorize text partially, you will need to use dynamic colors.
Not sure what your question is here.
This really depends on what you need to do. If you want to know the background to this function, take a look at #58.
If you want to change the default look of the
Boxborders, you'll need to useSetDrawFunc(). Basically, you'll have to draw your own borders. In #57, there was a longer discussion about this.If you have an interesting public project that uses
tview, I'm happy to link to it. So far, I haven't had any requests to add links. Probably because, you're right,tviewis still young.The most complex demo I'm providing is the one in the
demos/presentationdirectory. It shows a lot of functionality (but not all, of course).@KingRikkie commented on GitHub (Mar 5, 2018):
Thank you for your reply.
The documentation is great for reference but not so much for snippets or use cases.
One could create a custom "CrappyConsoleLikeTextView" element by adding a
Framearound aBoxand callAddText()onto it as it takes atcell.Coloras argument like you did in cover.go.I was thinking about (ab)using a
Tableto show a different color per line, row by row.My problem with
[color]is that the text I am going to show will can contain square brackets on its own and this could potentially lead to breaking the style. But I guess I'll fall back to inserting an opening square bracket in front of every closing bracket, ugly but works.Access to
Print()and the neededtcell.screenat least forBoxwould be really helpful making it more dynamic. I saw that you rejected a PR about this already, but maybe Box is just the right barebone for it (or a wiki entry about how to create a basic custom primitive).@rivo commented on GitHub (Mar 6, 2018):
Framecould be a solution but note that it also uses color tags. Pretty much everything does now. (People wanted to be able to individually color almost all text.)Depending on what else you need (e.g. scrolling, selections), I would probably still use
TextView:If your line content potentially contains strings that look like a color tag, I could offer you to add an
Escape()function totviewwhich makes them appear as original text again. Let me know if you need that.As mentioned, this exists.
@KingRikkie commented on GitHub (Mar 9, 2018):
Simple enough, can be defined globally:
Figured that out already, but is there a way to add a callback, executing it and then setting back the previously installed one (if any)? Modal unfortunately does not support a "pop-over" so I am creating my own
ShowModal(title string, text string, yesText string, noText string, yesFunc func(), noFunc func())that will install a callback onto app.SetAfterDrawFunc, draws a simple modal on top of screen, waits for user decision, then removes the handler and redraws screen. Doingapp.SetAfterDrawFunc(nil)will however remove any possible other callback so my solution can't be used as a simple blackbox.@rivo commented on GitHub (Mar 10, 2018):
Do you mean it would help you to have getters, too? I.e.
app.GetBeforeDrawFunc()andapp.GetAfterDrawFunc()? Or would that still cause problems in your example?@KingRikkie commented on GitHub (Mar 10, 2018):
If one could do:
@rivo commented on GitHub (Mar 10, 2018):
I added these getters. Let me know if this helps you.
If not, I can always reopen this issue.
@KingRikkie commented on GitHub (Apr 5, 2018):
@rivo
Yes these getters are fitting nicely.
In case anyone wants a basic modal pop-up:
modal.go
main.go
@lnxbil commented on GitHub (Nov 29, 2018):
The stated example is not working anymore, any hints on what has changed besides the styling stuff?
@rivo commented on GitHub (Dec 3, 2018):
You'll need to make two modifications:
app.Lock()andapp.Unlock()statements. The before/after draw handlers are already executed in a locked state. (I didn't realize they were there in the old example but they weren't needed back then, either.) If you leave them in, you'll get a deadlock, which is why the example gets stuck.BoxDrawings...constants were named wrong. #126 fixed this and also refactored it. It's better to usetview.Borders.Horizontaletc.Let me know if there's anything else.
@lnxbil commented on GitHub (Dec 10, 2018):
Okay, that seems to work.
So, just for completeness, the corrected example (only the named remarks) for anyone stumbling on this long closed issue as I did.