Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
e20cbc16
Unverified
Commit
e20cbc16
authored
Dec 15, 2020
by
Cristian Maglie
Committed by
GitHub
Dec 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed odd width of tables in command outputs (#1080)
Fix #1040
parent
441f8ebf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
table/table.go
table/table.go
+13
-0
No files found.
table/table.go
View file @
e20cbc16
...
@@ -80,6 +80,7 @@ func (t *Table) Render() string {
...
@@ -80,6 +80,7 @@ func (t *Table) Render() string {
average
:=
make
([]
int
,
t
.
columnsCount
)
average
:=
make
([]
int
,
t
.
columnsCount
)
widths
:=
make
([]
int
,
t
.
columnsCount
)
widths
:=
make
([]
int
,
t
.
columnsCount
)
count
:=
make
([]
int
,
t
.
columnsCount
)
count
:=
make
([]
int
,
t
.
columnsCount
)
minimum
:=
make
([]
int
,
t
.
columnsCount
)
for
_
,
row
:=
range
t
.
rows
{
for
_
,
row
:=
range
t
.
rows
{
for
x
,
cell
:=
range
row
.
cells
{
for
x
,
cell
:=
range
row
.
cells
{
l
:=
cell
.
Len
()
l
:=
cell
.
Len
()
...
@@ -98,6 +99,15 @@ func (t *Table) Render() string {
...
@@ -98,6 +99,15 @@ func (t *Table) Render() string {
average
[
x
]
=
average
[
x
]
/
count
[
x
]
average
[
x
]
=
average
[
x
]
/
count
[
x
]
}
}
}
}
// table headers will dictate the absolute min width
for
x
:=
range
minimum
{
if
t
.
hasHeader
{
minimum
[
x
]
=
t
.
rows
[
0
]
.
cells
[
x
]
.
Len
()
}
else
{
minimum
[
x
]
=
1
}
}
variance
:=
make
([]
int
,
t
.
columnsCount
)
variance
:=
make
([]
int
,
t
.
columnsCount
)
for
_
,
row
:=
range
t
.
rows
{
for
_
,
row
:=
range
t
.
rows
{
for
x
,
cell
:=
range
row
.
cells
{
for
x
,
cell
:=
range
row
.
cells
{
...
@@ -128,6 +138,9 @@ func (t *Table) Render() string {
...
@@ -128,6 +138,9 @@ func (t *Table) Render() string {
selectedWidth
=
average
[
x
]
+
variance
[
x
]
*
3
selectedWidth
=
average
[
x
]
+
variance
[
x
]
*
3
}
}
}
}
if
selectedWidth
<
minimum
[
x
]
{
selectedWidth
=
minimum
[
x
]
}
res
+=
separator
res
+=
separator
res
+=
cell
.
Pad
(
selectedWidth
)
res
+=
cell
.
Pad
(
selectedWidth
)
separator
=
" "
separator
=
" "
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment