aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-12-01 17:09:13 +0100
committerMichael Muré <batolettre@gmail.com>2018-12-01 17:09:13 +0100
commit9c89cf5b96308b5319d2c2310ea9af80b369dc94 (patch)
tree325b938c6c739ee6c155660399f19e779cfa059a /termui
parentab970da4d5ac223e501f55d71a5af574a1345050 (diff)
downloadgit-bug-9c89cf5b96308b5319d2c2310ea9af80b369dc94.tar.gz
termui: tighter column in the bug table
Diffstat (limited to 'termui')
-rw-r--r--termui/bug_table.go47
1 files changed, 26 insertions, 21 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go
index 14d9aa31..1545dbc9 100644
--- a/termui/bug_table.go
+++ b/termui/bug_table.go
@@ -269,12 +269,12 @@ func (bt *bugTable) getTableLength() int {
func (bt *bugTable) getColumnWidths(maxX int) map[string]int {
m := make(map[string]int)
- m["id"] = 10
- m["status"] = 8
+ m["id"] = 9
+ m["status"] = 7
left := maxX - 5 - m["id"] - m["status"]
- m["summary"] = 14
+ m["summary"] = 10
left -= m["summary"]
m["lastEdit"] = 19
left -= m["lastEdit"]
@@ -296,14 +296,19 @@ func (bt *bugTable) render(v *gocui.View, maxX int) {
person = create.Author
}
- id := text.LeftPadMaxLine(snap.HumanId(), columnWidths["id"], 2)
- status := text.LeftPadMaxLine(snap.Status.String(), columnWidths["status"], 2)
- title := text.LeftPadMaxLine(snap.Title, columnWidths["title"], 2)
- author := text.LeftPadMaxLine(person.DisplayName(), columnWidths["author"], 2)
- summary := text.LeftPadMaxLine(snap.Summary(), columnWidths["summary"], 2)
- lastEdit := text.LeftPadMaxLine(humanize.Time(snap.LastEditTime()), columnWidths["lastEdit"], 2)
+ summaryTxt := fmt.Sprintf("C:%-2d L:%-2d",
+ len(snap.Comments)-1,
+ len(snap.Labels),
+ )
+
+ id := text.LeftPadMaxLine(snap.HumanId(), columnWidths["id"], 1)
+ status := text.LeftPadMaxLine(snap.Status.String(), columnWidths["status"], 1)
+ title := text.LeftPadMaxLine(snap.Title, columnWidths["title"], 1)
+ author := text.LeftPadMaxLine(person.DisplayName(), columnWidths["author"], 1)
+ summary := text.LeftPadMaxLine(summaryTxt, columnWidths["summary"], 1)
+ lastEdit := text.LeftPadMaxLine(humanize.Time(snap.LastEditTime()), columnWidths["lastEdit"], 1)
- fmt.Fprintf(v, "%s %s %s %s %s %s\n",
+ _, _ = fmt.Fprintf(v, "%s %s %s %s %s %s\n",
colors.Cyan(id),
colors.Yellow(status),
title,
@@ -317,20 +322,20 @@ func (bt *bugTable) render(v *gocui.View, maxX int) {
func (bt *bugTable) renderHeader(v *gocui.View, maxX int) {
columnWidths := bt.getColumnWidths(maxX)
- id := text.LeftPadMaxLine("ID", columnWidths["id"], 2)
- status := text.LeftPadMaxLine("STATUS", columnWidths["status"], 2)
- title := text.LeftPadMaxLine("TITLE", columnWidths["title"], 2)
- author := text.LeftPadMaxLine("AUTHOR", columnWidths["author"], 2)
- summary := text.LeftPadMaxLine("SUMMARY", columnWidths["summary"], 2)
- lastEdit := text.LeftPadMaxLine("LAST EDIT", columnWidths["lastEdit"], 2)
+ id := text.LeftPadMaxLine("ID", columnWidths["id"], 1)
+ status := text.LeftPadMaxLine("STATUS", columnWidths["status"], 1)
+ title := text.LeftPadMaxLine("TITLE", columnWidths["title"], 1)
+ author := text.LeftPadMaxLine("AUTHOR", columnWidths["author"], 1)
+ summary := text.LeftPadMaxLine("SUMMARY", columnWidths["summary"], 1)
+ lastEdit := text.LeftPadMaxLine("LAST EDIT", columnWidths["lastEdit"], 1)
- fmt.Fprintf(v, "\n")
- fmt.Fprintf(v, "%s %s %s %s %s %s\n", id, status, title, author, summary, lastEdit)
+ _, _ = fmt.Fprintf(v, "\n")
+ _, _ = fmt.Fprintf(v, "%s %s %s %s %s %s\n", id, status, title, author, summary, lastEdit)
}
func (bt *bugTable) renderFooter(v *gocui.View, maxX int) {
- fmt.Fprintf(v, " \nShowing %d of %d bugs", len(bt.bugs), len(bt.allIds))
+ _, _ = fmt.Fprintf(v, " \nShowing %d of %d bugs", len(bt.bugs), len(bt.allIds))
}
func (bt *bugTable) cursorDown(g *gocui.Gui, v *gocui.View) error {
@@ -432,7 +437,7 @@ func (bt *bugTable) pull(g *gocui.Gui, v *gocui.View) error {
return nil
})
} else {
- fmt.Fprintf(&buffer, "%s%s: %s",
+ _, _ = fmt.Fprintf(&buffer, "%s%s: %s",
beginLine, colors.Cyan(merge.Bug.HumanId()), merge,
)
@@ -445,7 +450,7 @@ func (bt *bugTable) pull(g *gocui.Gui, v *gocui.View) error {
}
}
- fmt.Fprintf(&buffer, "%sdone", beginLine)
+ _, _ = fmt.Fprintf(&buffer, "%sdone", beginLine)
g.Update(func(gui *gocui.Gui) error {
ui.msgPopup.UpdateMessage(buffer.String())