bubbles
bubbles copied to clipboard
feat(table): expose `start` and `end` fields via getter methods
This PR exposes the start
and the end
fields from the table model struct.
Not having setters is fine because that would break the inner logic, but handling
mouse clicks on rows is a bit inconvenient because the mouse events contain the
relative position but to select the actual row under the (mouse)cursor, the absolute
row index is needed. With exporting these - mainly the start - it should be as easy
as table.Start() + mouseMsg.Y
.
Can someone review this? I don't want to bother maintainers by tagging. :)
Hi, there. Just curious, what your use case for this?
I'm working on a TUI app which has to support mouse clicks. Currently - when the content is scrolled - there is no way to get the offset of the first rendered row. Only the selected row is available (under the cursor), but that's not what I'd like to get. I've made a small hack which works, but it's definitely not ideal :)
rowOffset := int(reflect.ValueOf(&m.tableData.table).Elem().FieldByName("start").Int())
Hey @pyrooka, thank you for the PR. We're working on swapping out the implementation of the Bubble Table with using Lip Gloss tables:
https://github.com/charmbracelet/lipgloss/releases/tag/v0.9.0
That being said, we'll want to make sure the API is as small as possible so we limit breaking changes as much as possible. I will close this PR for now but we can revisit after we introduce Lip Gloss tables as the rendering for the bubble.
I see, thanks for the update! I'll keep my on the transition as we might need to change our code, since we use unexported fields via reflection. :)