charmbracelet / charmbracelet/bubbles
Custom width for internal viewport for table component of bubbles
- Dominant language
- Go
- Stars
- 8.9k
- Forks
- 457
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 5
Description
I am currently using the table component of the bubbles package to display various contents of a particular directory. My current solution uses a bubbletea model that embeds a table component along with other strings. Here is the example of how i am using it to render contents of the project directory-
When the length of the names(string) of the contents(fs.FileInfo) of a particular directory are within the width of the table component's default viewport width this is a non issue. But with string lengths greater than the default viewport width the render cuts off midway. Though this approach ensures that the viewport correctly renders the contents provided correctly and fits properly. But this also means when an application doesn't make use of any sort of vertical scroll feature the contents can be incomplete and it becomes hard to distinguish. As an example when there are two files in a folder starting with the same character sequence. In that scenario it's very easy to not be able to tell them apart.
From reading the source code for the initialization function for the model in the table component i can observe the width of the viewport is hard coded to be 20.-
An alternative approach could be to make a public function with the same prototype as Option to make the viewport width adjustable. Doing this will give users for this table component control how much of the horizontal content is rendered.
So far looking into the source code for the table component in the bubbles package i couldn't find any obvious method to set the viewport width afterward initialization.
Contributor guide
Assessment
This issue has not been assessed yet.