mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #405] Why inner rectangle of a box is forced moved to screen? #297
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#297
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 @gnojus on GitHub (Feb 15, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/405
Hi.
As I understand from this snippet
github.com/rivo/tview@ae3d8cac5e/box.go (L318-L323)inside
Boxdrawing function the inner rectangle is moved inside the screen. Because of this, displayed content might be different than expected (e. g. when you want to cut part of the text, it will still be visible, just in different position relative to the surrounding box).This makes scrolling of lets say
flexorgridby a single row impossible. Or at least I couldn't figure out a way how to do it.Would it be possible to add an option to allow out of screen
inner rectangles?Or is it a feature by design and I'm not getting something?
@tslocum commented on GitHub (Feb 15, 2020):
I can't speak to why this is clamping occurs. However, if you could further explain what you are trying to achieve I may offer a solution. What do you mean by scrolling a Flex or Grid? Would creating an internal scrolling mechanism by updating a Grid to contain different rows achieve what you are looking for?
@gnojus commented on GitHub (Feb 15, 2020):
Smart, I didn't think about. It's actually doable, but a bit hacky. It would probably require displaying only specific subset of elements instead of everything.
What I want to achieve is basically a multi-line list (scrollable, not necessary selectable), containing multi-line
textViews. Similar to a webpage.And yet changing
grid's orflex's position would be much more elegant.@rivo commented on GitHub (Feb 19, 2020):
Early on, I was thinking of a class
Scrollablewhich may contain another primitive which would only be displayed partially and could be scrolled using keyboard shortcuts. WithGridyou do get a similar behaviour but scrolling is then per item, now per row in the terminal.Such a
Scrollablemay still be something I'll add in the future but given the backlog I have on here, you may not want to bet on it becoming available very soon.@gnojus commented on GitHub (Feb 19, 2020):
I see. That
Scrollableclass would be really useful.Scrolling per item gives quite different behavior on bigger items, and also cuts box borders: last line sometimes looks like this
instead of
and therefore gives impression that there isn't anything more to scroll while there are still more items.
And I suppose just allowing opt out clamping isn't a good idea? The problem is that there is no way to achieve that in a custom primitive level, without rewriting the base
box.@rivo commented on GitHub (Feb 19, 2020):
Ok. So the clamping in
Boxwas initially just a way to simply optimize the drawing of primitives. There was no aesthetic reason for it and I agree it actually makes some cases look worse.I removed it with the latest commit.
This meant that I needed to add screen boundary checking to all primitives. (Theoretically, it's not necessary because
tcellignores writes outside of the screen.) I wanted to have some basic optimization.Please note that, say, a large
TextViewmay still be slow to scroll because all the reindexing happens independently of the screen dimensions.tviewis not yet ready for huge primitives.@gnojus commented on GitHub (Feb 19, 2020):
Wow that was quick, thanks. Noted about the big buffers.