aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
Diffstat (limited to 'termui')
-rw-r--r--termui/bug_table.go46
-rw-r--r--termui/label_select.go10
-rw-r--r--termui/msg_popup.go2
-rw-r--r--termui/show_bug.go11
-rw-r--r--termui/termui.go3
5 files changed, 48 insertions, 24 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go
index 8d69d665..c432c94a 100644
--- a/termui/bug_table.go
+++ b/termui/bug_table.go
@@ -3,14 +3,16 @@ package termui
import (
"bytes"
"fmt"
+ "strings"
"time"
+ "github.com/MichaelMure/go-term-text"
+ "github.com/MichaelMure/gocui"
+ "github.com/dustin/go-humanize"
+
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/util/colors"
- "github.com/MichaelMure/git-bug/util/text"
- "github.com/MichaelMure/gocui"
- "github.com/dustin/go-humanize"
)
const bugTableView = "bugTableView"
@@ -275,8 +277,8 @@ func (bt *bugTable) getColumnWidths(maxX int) map[string]int {
left := maxX - 5 - m["id"] - m["status"]
- m["summary"] = 10
- left -= m["summary"]
+ m["comments"] = 10
+ left -= m["comments"]
m["lastEdit"] = 19
left -= m["lastEdit"]
@@ -290,10 +292,21 @@ func (bt *bugTable) render(v *gocui.View, maxX int) {
columnWidths := bt.getColumnWidths(maxX)
for _, excerpt := range bt.excerpts {
- summaryTxt := fmt.Sprintf("C:%-2d L:%-2d",
- excerpt.LenComments,
- len(excerpt.Labels),
- )
+ summaryTxt := fmt.Sprintf("%4d 💬", excerpt.LenComments)
+ if excerpt.LenComments <= 0 {
+ summaryTxt = ""
+ }
+ if excerpt.LenComments > 9999 {
+ summaryTxt = " ∞ 💬"
+ }
+
+ var labelsTxt strings.Builder
+ for _, l := range excerpt.Labels {
+ lc256 := l.Color().Term256()
+ labelsTxt.WriteString(lc256.Escape())
+ labelsTxt.WriteString(" ◼")
+ labelsTxt.WriteString(lc256.Unescape())
+ }
var authorDisplayName string
if excerpt.AuthorId != "" {
@@ -310,17 +323,19 @@ func (bt *bugTable) render(v *gocui.View, maxX int) {
id := text.LeftPadMaxLine(excerpt.Id.Human(), columnWidths["id"], 1)
status := text.LeftPadMaxLine(excerpt.Status.String(), columnWidths["status"], 1)
- title := text.LeftPadMaxLine(excerpt.Title, columnWidths["title"], 1)
+ labels := text.TruncateMax(labelsTxt.String(), minInt(columnWidths["title"]-2, 10))
+ title := text.LeftPadMaxLine(excerpt.Title, columnWidths["title"]-text.Len(labels), 1)
author := text.LeftPadMaxLine(authorDisplayName, columnWidths["author"], 1)
- summary := text.LeftPadMaxLine(summaryTxt, columnWidths["summary"], 1)
+ comments := text.LeftPadMaxLine(summaryTxt, columnWidths["comments"], 1)
lastEdit := text.LeftPadMaxLine(humanize.Time(lastEditTime), columnWidths["lastEdit"], 1)
- _, _ = fmt.Fprintf(v, "%s %s %s %s %s %s\n",
+ _, _ = fmt.Fprintf(v, "%s %s %s%s %s %s %s\n",
colors.Cyan(id),
colors.Yellow(status),
title,
+ labels,
colors.Magenta(author),
- summary,
+ comments,
lastEdit,
)
}
@@ -333,12 +348,11 @@ func (bt *bugTable) renderHeader(v *gocui.View, maxX int) {
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)
+ comments := text.LeftPadMaxLine("COMMENTS", columnWidths["comments"], 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, "%s %s %s %s %s %s\n", id, status, title, author, comments, lastEdit)
}
func (bt *bugTable) renderFooter(v *gocui.View, maxX int) {
diff --git a/termui/label_select.go b/termui/label_select.go
index 131703f9..39edbdb1 100644
--- a/termui/label_select.go
+++ b/termui/label_select.go
@@ -4,9 +4,10 @@ import (
"fmt"
"strings"
+ "github.com/MichaelMure/gocui"
+
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/gocui"
)
const labelSelectView = "labelSelectView"
@@ -127,7 +128,12 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
if ls.labelSelect[i] {
selectBox = " [x] "
}
- fmt.Fprint(v, selectBox, label)
+
+ lc := label.Color()
+ lc256 := lc.Term256()
+ labelStr := lc256.Escape() + "◼ " + lc256.Unescape() + label.String()
+ fmt.Fprint(v, selectBox, labelStr)
+
y0 += 2
}
diff --git a/termui/msg_popup.go b/termui/msg_popup.go
index 4452427e..99180c99 100644
--- a/termui/msg_popup.go
+++ b/termui/msg_popup.go
@@ -3,7 +3,7 @@ package termui
import (
"fmt"
- "github.com/MichaelMure/git-bug/util/text"
+ "github.com/MichaelMure/go-term-text"
"github.com/MichaelMure/gocui"
)
diff --git a/termui/show_bug.go b/termui/show_bug.go
index 228b85b0..50478b8f 100644
--- a/termui/show_bug.go
+++ b/termui/show_bug.go
@@ -5,12 +5,13 @@ import (
"fmt"
"strings"
+ "github.com/MichaelMure/go-term-text"
+ "github.com/MichaelMure/gocui"
+
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/util/colors"
- "github.com/MichaelMure/git-bug/util/text"
- "github.com/MichaelMure/gocui"
)
const showBugView = "showBugView"
@@ -429,13 +430,15 @@ func (sb *showBug) renderSidebar(g *gocui.Gui, sideView *gocui.View) error {
labelStr := make([]string, len(snap.Labels))
for i, l := range snap.Labels {
- labelStr[i] = string(l)
+ lc := l.Color()
+ lc256 := lc.Term256()
+ labelStr[i] = lc256.Escape() + "◼ " + lc256.Unescape() + l.String()
}
labels := strings.Join(labelStr, "\n")
labels, lines := text.WrapLeftPadded(labels, maxX, 2)
- content := fmt.Sprintf("%s\n\n%s", colors.Bold("Labels"), labels)
+ content := fmt.Sprintf("%s\n\n%s", colors.Bold(" Labels"), labels)
v, err := sb.createSideView(g, "sideLabels", x0, y0, maxX, lines+2)
if err != nil {
diff --git a/termui/termui.go b/termui/termui.go
index 5d3bb0c1..8aece020 100644
--- a/termui/termui.go
+++ b/termui/termui.go
@@ -66,11 +66,12 @@ func Run(cache *cache.RepoCache) error {
return err
}
+
return nil
}
func initGui(action func(ui *termUI) error) {
- g, err := gocui.NewGui(gocui.OutputNormal)
+ g, err := gocui.NewGui(gocui.Output256)
if err != nil {
ui.gError <- err