diff options
author | Michael Muré <batolettre@gmail.com> | 2018-08-09 14:36:23 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-08-09 14:36:23 +0200 |
commit | b6087d7e35dd0f687264ef3a743ccc3871bd3b64 (patch) | |
tree | 1187069341bd5cdff08c5820cf473d03db0ee854 /termui/show_bug.go | |
parent | 0da2bea132ee57820572c2636ae52ccd39171345 (diff) | |
download | git-bug-b6087d7e35dd0f687264ef3a743ccc3871bd3b64.tar.gz |
termui: colors show bug
Diffstat (limited to 'termui/show_bug.go')
-rw-r--r-- | termui/show_bug.go | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/termui/show_bug.go b/termui/show_bug.go index 92845b47..0189b2b3 100644 --- a/termui/show_bug.go +++ b/termui/show_bug.go @@ -155,26 +155,22 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error { sb.childViews = nil sb.selectableView = nil - v, err := g.SetView(showBugHeaderView, x0, y0, maxX+1, y0+4) - + header := 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) + + v, err := sb.createOpView(g, showBugHeaderView, x0, y0, maxX+1, lines, false) if err != nil { - if err != gocui.ErrUnknownView { - return err - } - - v.Frame = false + return err } - sb.childViews = append(sb.childViews, showBugHeaderView) - - y0 += 4 - v.Clear() - header1 := fmt.Sprintf("[%s] %s", snap.HumanId(), snap.Title) - fmt.Fprintf(v, util.LeftPaddedString(header1, maxX-1, 0)+"\n\n") - - header2 := fmt.Sprintf("[%s] %s opened this bug on %s", - snap.Status, snap.Author.Name, snap.CreatedAt.Format(timeLayout)) - fmt.Fprintf(v, util.LeftPaddedString(header2, maxX-1, 0)) + fmt.Fprint(v, content) + y0 += lines + 1 for i, op := range snap.Operations { viewName := fmt.Sprintf("op%d", i) @@ -198,17 +194,36 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error { case operations.AddCommentOperation: comment := op.(operations.AddCommentOperation) - header := fmt.Sprintf("%s commented on %s", - comment.Author.Name, comment.Time().Format(timeLayout)) - header = util.LeftPaddedString(header, maxX, 6) - message, lines := util.TextWrap(comment.Message, maxX) + content := fmt.Sprintf("%s commented on %s\n\n%s", + util.Magenta(comment.Author.Name), + comment.Time().Format(timeLayout), + comment.Message, + ) + content, lines := util.TextWrapPadded(content, maxX, 6) + + v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true) + if err != nil { + return err + } + fmt.Fprint(v, content) + y0 += lines + 2 - v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines+2, true) + case operations.SetTitleOperation: + setTitle := op.(operations.SetTitleOperation) + + content := fmt.Sprintf("%s changed the title to %s on %s", + util.Magenta(setTitle.Author.Name), + util.Bold(setTitle.Title), + setTitle.Time().Format(timeLayout), + ) + content, lines := util.TextWrap(content, maxX) + + v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true) if err != nil { return err } - fmt.Fprint(v, header, "\n\n", message) - y0 += lines + 3 + fmt.Fprint(v, content) + y0 += lines + 2 } } |