aboutsummaryrefslogtreecommitdiffstats
path: root/termui/show_bug.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-09 14:51:19 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-09 14:55:18 +0200
commitde76b6fa1528d476b5be91785f75f8c6d224c92e (patch)
tree8d69f02cb77c18d8095086c1ddb2fd2c66085579 /termui/show_bug.go
parent5675299c8dd9488c3b60142d8da8b112473a0cd4 (diff)
downloadgit-bug-de76b6fa1528d476b5be91785f75f8c6d224c92e.tar.gz
termui: better padding for show bug
Diffstat (limited to 'termui/show_bug.go')
-rw-r--r--termui/show_bug.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/termui/show_bug.go b/termui/show_bug.go
index aecdce4b..d6644b1d 100644
--- a/termui/show_bug.go
+++ b/termui/show_bug.go
@@ -31,6 +31,11 @@ func newShowBug(cache cache.RepoCacher) *showBug {
}
}
+func (sb *showBug) SetBug(bug cache.BugCacher) {
+ sb.bug = bug
+ sb.scroll = 0
+}
+
func (sb *showBug) layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
@@ -155,21 +160,21 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
sb.childViews = nil
sb.selectableView = nil
- header := fmt.Sprintf("[ %s ] %s\n\n[ %s ] %s opened this bug on %s",
+ bugHeader := fmt.Sprintf("[ %s ] %s\n\n[ %s ] %s opened this bug on %s",
util.Cyan(snap.HumanId()),
util.Bold(snap.Title),
util.Yellow(snap.Status),
util.Magenta(snap.Author.Name),
snap.CreatedAt.Format(timeLayout),
)
- content, lines := util.TextWrap(header, maxX)
+ bugHeader, lines := util.TextWrap(bugHeader, maxX)
v, err := sb.createOpView(g, showBugHeaderView, x0, y0, maxX+1, lines, false)
if err != nil {
return err
}
- fmt.Fprint(v, content)
+ fmt.Fprint(v, bugHeader)
y0 += lines + 1
for i, op := range snap.Operations {
@@ -182,7 +187,7 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
case operations.CreateOperation:
create := op.(operations.CreateOperation)
- content, lines := util.TextWrap(create.Message, maxX)
+ content, lines := util.TextWrapPadded(create.Message, maxX, 4)
v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true)
if err != nil {
@@ -194,12 +199,13 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
case operations.AddCommentOperation:
comment := op.(operations.AddCommentOperation)
+ message, _ := util.TextWrapPadded(comment.Message, maxX, 4)
content := fmt.Sprintf("%s commented on %s\n\n%s",
util.Magenta(comment.Author.Name),
comment.Time().Format(timeLayout),
- comment.Message,
+ message,
)
- content, lines := util.TextWrapPadded(content, maxX, 6)
+ content, lines = util.TextWrap(content, maxX)
v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true)
if err != nil {