aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
Diffstat (limited to 'termui')
-rw-r--r--termui/msg_popup.go2
-rw-r--r--termui/show_bug.go54
-rw-r--r--termui/termui.go2
3 files changed, 22 insertions, 36 deletions
diff --git a/termui/msg_popup.go b/termui/msg_popup.go
index 236c16a2..d0e31634 100644
--- a/termui/msg_popup.go
+++ b/termui/msg_popup.go
@@ -63,7 +63,7 @@ func (ep *msgPopup) layout(g *gocui.Gui) error {
v.Title = ep.title
v.Clear()
- fmt.Fprintf(v, wrapped)
+ _, _ = fmt.Fprint(v, wrapped)
if _, err := g.SetCurrentView(msgPopupView); err != nil {
return err
diff --git a/termui/show_bug.go b/termui/show_bug.go
index 6c7163ac..e483117a 100644
--- a/termui/show_bug.go
+++ b/termui/show_bug.go
@@ -238,18 +238,16 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
// TODO: me might skip the rendering of blocks that are outside of the view
// but to do that we need to rework how sb.mainSelectableView is maintained
- switch op.(type) {
+ switch op := op.(type) {
case *bug.CreateTimelineItem:
- create := op.(*bug.CreateTimelineItem)
-
var content string
var lines int
- if create.MessageIsEmpty() {
+ if op.MessageIsEmpty() {
content, lines = text.WrapLeftPadded(emptyMessagePlaceholder(), maxX-1, 4)
} else {
- content, lines = text.WrapLeftPadded(create.Message, maxX-1, 4)
+ content, lines = text.WrapLeftPadded(op.Message, maxX-1, 4)
}
v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true)
@@ -260,23 +258,21 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
y0 += lines + 2
case *bug.AddCommentTimelineItem:
- comment := op.(*bug.AddCommentTimelineItem)
-
edited := ""
- if comment.Edited() {
+ if op.Edited() {
edited = " (edited)"
}
var message string
- if comment.MessageIsEmpty() {
+ if op.MessageIsEmpty() {
message, _ = text.WrapLeftPadded(emptyMessagePlaceholder(), maxX-1, 4)
} else {
- message, _ = text.WrapLeftPadded(comment.Message, maxX-1, 4)
+ message, _ = text.WrapLeftPadded(op.Message, maxX-1, 4)
}
content := fmt.Sprintf("%s commented on %s%s\n\n%s",
- colors.Magenta(comment.Author.DisplayName()),
- comment.CreatedAt.Time().Format(timeLayout),
+ colors.Magenta(op.Author.DisplayName()),
+ op.CreatedAt.Time().Format(timeLayout),
edited,
message,
)
@@ -290,12 +286,10 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
y0 += lines + 2
case *bug.SetTitleTimelineItem:
- setTitle := op.(*bug.SetTitleTimelineItem)
-
content := fmt.Sprintf("%s changed the title to %s on %s",
- colors.Magenta(setTitle.Author.DisplayName()),
- colors.Bold(setTitle.Title),
- setTitle.UnixTime.Time().Format(timeLayout),
+ colors.Magenta(op.Author.DisplayName()),
+ colors.Bold(op.Title),
+ op.UnixTime.Time().Format(timeLayout),
)
content, lines := text.Wrap(content, maxX)
@@ -307,12 +301,10 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
y0 += lines + 2
case *bug.SetStatusTimelineItem:
- setStatus := op.(*bug.SetStatusTimelineItem)
-
content := fmt.Sprintf("%s %s the bug on %s",
- colors.Magenta(setStatus.Author.DisplayName()),
- colors.Bold(setStatus.Status.Action()),
- setStatus.UnixTime.Time().Format(timeLayout),
+ colors.Magenta(op.Author.DisplayName()),
+ colors.Bold(op.Status.Action()),
+ op.UnixTime.Time().Format(timeLayout),
)
content, lines := text.Wrap(content, maxX)
@@ -324,15 +316,13 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
y0 += lines + 2
case *bug.LabelChangeTimelineItem:
- labelChange := op.(*bug.LabelChangeTimelineItem)
-
var added []string
- for _, label := range labelChange.Added {
+ for _, label := range op.Added {
added = append(added, colors.Bold("\""+label+"\""))
}
var removed []string
- for _, label := range labelChange.Removed {
+ for _, label := range op.Removed {
removed = append(removed, colors.Bold("\""+label+"\""))
}
@@ -359,9 +349,9 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
}
content := fmt.Sprintf("%s %s on %s",
- colors.Magenta(labelChange.Author.DisplayName()),
+ colors.Magenta(op.Author.DisplayName()),
action.String(),
- labelChange.UnixTime.Time().Format(timeLayout),
+ op.UnixTime.Time().Format(timeLayout),
)
content, lines := text.Wrap(content, maxX)
@@ -651,13 +641,11 @@ func (sb *showBug) edit(g *gocui.Gui, v *gocui.View) error {
return err
}
- switch op.(type) {
+ switch op := op.(type) {
case *bug.AddCommentTimelineItem:
- message := op.(*bug.AddCommentTimelineItem).Message
- return editCommentWithEditor(sb.bug, op.Id(), message)
+ return editCommentWithEditor(sb.bug, op.Id(), op.Message)
case *bug.CreateTimelineItem:
- preMessage := op.(*bug.CreateTimelineItem).Message
- return editCommentWithEditor(sb.bug, op.Id(), preMessage)
+ return editCommentWithEditor(sb.bug, op.Id(), op.Message)
case *bug.LabelChangeTimelineItem:
return sb.editLabels(g, snap)
}
diff --git a/termui/termui.go b/termui/termui.go
index 9b92b536..1ef960de 100644
--- a/termui/termui.go
+++ b/termui/termui.go
@@ -117,8 +117,6 @@ func initGui(action func(ui *termUI) error) {
}
ui.gError <- err
}
-
- return
}
func layout(g *gocui.Gui) error {