-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Columns seem to ignore lipgloss padding #130
Comments
Interesting result: I can get closer to the format I want with package main
import (
"fmt"
"github.com/charmbracelet/lipgloss"
"github.com/evertras/bubble-table/table"
)
func main() {
cols := []table.Column{
table.NewColumn("a", "A", 10),
}
paddedCell := lipgloss.NewStyle().Padding(0, 1) // for our own safety
rows := []table.Row{
table.NewRow(table.RowData{"a": table.NewStyledCell("hello", paddedCell)}),
table.NewRow(table.RowData{"a": table.NewStyledCell("very long text", paddedCell)}),
}
t := table.New(cols).WithRows(rows)
fmt.Println(t.View())
} Output
|
Apologies for the late reply on this, it slipped through my email and I haven't checked here for a little bit. I think the |
What I found so far is this line.
In its implementation in the lipgloss package, we can see that margins and padding properties are skipped
With that knowledge, I created a column with left padding
and change the renderRowColumnData a little bit
Which results in the desired state: What we can do is:
I have some free time now, I can go with the second solution. cc. @Evertras |
Okay, it may be tricky because Without access lipgloss.Style.rules it may be hard to implement simply. We can cover the override margins/paddings with a next column flag but I do not if it is a best approach here |
PR: #160 |
I want to pad my cell data with a space on both the left and the right. This is because in many terminals, double-clicking on the text of a cell will select the contents plus the column separator. The common behavior is to delimit only on whitespace. What I want is to quickly copy a cell's contents into my OS clipboard for pasting into other tools.
I tried this by adding a column style that uses
.Padding(0, 1)
as well as manually adding spaces to the row data, but either way the table seems to trim space before rendering. Any hints on how I should be doing this?I skimmed through the code and did not find any explicit logic to remove leading or trailing space.
Note: For overflow, I don't care if the ellipsis touches the column separator, because a truncated value is not worth copying into a clipboard.
I am using Version: v0.15.0
Sample Program:
Expected Output:
Actual Output:
The text was updated successfully, but these errors were encountered: