aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
authorYuri D'Elia <wavexx@thregr.org>2020-07-15 14:27:23 +0200
committerMichael Muré <batolettre@gmail.com>2020-08-29 22:21:11 +0200
commit5a4dc7aade221a15e590e1491d988d9030e4a4d9 (patch)
tree6bc8d222cc6dd44f1f68c3145bed0a0f5cfefd21 /termui
parent6824ecf0fb0e9253dafa69a8ccd2e4885e97c62d (diff)
downloadgit-bug-5a4dc7aade221a15e590e1491d988d9030e4a4d9.tar.gz
TermUI: pack the bug table view
Diffstat (limited to 'termui')
-rw-r--r--termui/bug_table.go43
1 files changed, 23 insertions, 20 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go
index 4b583dca..3567da09 100644
--- a/termui/bug_table.go
+++ b/termui/bug_table.go
@@ -277,14 +277,14 @@ func (bt *bugTable) getTableLength() int {
func (bt *bugTable) getColumnWidths(maxX int) map[string]int {
m := make(map[string]int)
- m["id"] = 9
- m["status"] = 7
+ m["id"] = 7
+ m["status"] = 6
left := maxX - 5 - m["id"] - m["status"]
- m["comments"] = 10
+ m["comments"] = 3
left -= m["comments"]
- m["lastEdit"] = 19
+ m["lastEdit"] = 14
left -= m["lastEdit"]
m["author"] = minInt(maxInt(left/3, 15), 10+left/8)
@@ -297,20 +297,23 @@ func (bt *bugTable) render(v *gocui.View, maxX int) {
columnWidths := bt.getColumnWidths(maxX)
for _, excerpt := range bt.excerpts {
- summaryTxt := fmt.Sprintf("%4d 💬", excerpt.LenComments)
+ summaryTxt := fmt.Sprintf("%3d", excerpt.LenComments)
if excerpt.LenComments <= 0 {
summaryTxt = ""
}
- if excerpt.LenComments > 9999 {
- summaryTxt = " ∞ 💬"
+ if excerpt.LenComments > 999 {
+ summaryTxt = " ∞"
}
var labelsTxt strings.Builder
- for _, l := range excerpt.Labels {
- lc256 := l.Color().Term256()
- labelsTxt.WriteString(lc256.Escape())
- labelsTxt.WriteString(" ◼")
- labelsTxt.WriteString(lc256.Unescape())
+ if len(excerpt.Labels) > 0 {
+ labelsTxt.WriteString(" ")
+ for _, l := range excerpt.Labels {
+ lc256 := l.Color().Term256()
+ labelsTxt.WriteString(lc256.Escape())
+ labelsTxt.WriteString("◼")
+ labelsTxt.WriteString(lc256.Unescape())
+ }
}
var authorDisplayName string
@@ -327,11 +330,11 @@ func (bt *bugTable) render(v *gocui.View, maxX int) {
lastEditTime := excerpt.EditTime()
id := text.LeftPadMaxLine(excerpt.Id.Human(), columnWidths["id"], 0)
- status := text.LeftPadMaxLine(excerpt.Status.String(), columnWidths["status"], 1)
+ status := text.LeftPadMaxLine(excerpt.Status.String(), columnWidths["status"], 0)
labels := text.TruncateMax(labelsTxt.String(), minInt(columnWidths["title"]-2, 10))
- title := text.LeftPadMaxLine(strings.TrimSpace(excerpt.Title), columnWidths["title"]-text.Len(labels), 1)
- author := text.LeftPadMaxLine(authorDisplayName, columnWidths["author"], 1)
- comments := text.LeftPadMaxLine(summaryTxt, columnWidths["comments"], 1)
+ title := text.LeftPadMaxLine(strings.TrimSpace(excerpt.Title), columnWidths["title"]-text.Len(labels), 0)
+ author := text.LeftPadMaxLine(authorDisplayName, columnWidths["author"], 0)
+ comments := text.LeftPadMaxLine(summaryTxt, columnWidths["comments"], 0)
lastEdit := text.LeftPadMaxLine(humanize.Time(lastEditTime), columnWidths["lastEdit"], 1)
_, _ = fmt.Fprintf(v, "%s %s %s%s %s %s %s\n",
@@ -352,10 +355,10 @@ func (bt *bugTable) renderHeader(v *gocui.View, maxX int) {
columnWidths := bt.getColumnWidths(maxX)
id := text.LeftPadMaxLine("ID", columnWidths["id"], 0)
- status := text.LeftPadMaxLine("STATUS", columnWidths["status"], 1)
- title := text.LeftPadMaxLine("TITLE", columnWidths["title"], 1)
- author := text.LeftPadMaxLine("AUTHOR", columnWidths["author"], 1)
- comments := text.LeftPadMaxLine("COMMENTS", columnWidths["comments"], 1)
+ status := text.LeftPadMaxLine("STATUS", columnWidths["status"], 0)
+ title := text.LeftPadMaxLine("TITLE", columnWidths["title"], 0)
+ author := text.LeftPadMaxLine("AUTHOR", columnWidths["author"], 0)
+ comments := text.LeftPadMaxLine("CMT", columnWidths["comments"], 0)
lastEdit := text.LeftPadMaxLine("LAST EDIT", columnWidths["lastEdit"], 1)
_, _ = fmt.Fprintf(v, "%s %s %s %s %s %s\n", id, status, title, author, comments, lastEdit)