(g *gocui.Gui, mainView *gocui.View)
| 209 | } |
| 210 | |
| 211 | func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error { |
| 212 | maxX, _ := mainView.Size() |
| 213 | x0, y0, _, _, _ := g.ViewPosition(mainView.Name()) |
| 214 | |
| 215 | y0 -= sb.scroll |
| 216 | |
| 217 | snap := sb.bug.Snapshot() |
| 218 | |
| 219 | sb.mainSelectableView = nil |
| 220 | |
| 221 | createTimelineItem := snap.Timeline[0].(*bug.CreateTimelineItem) |
| 222 | |
| 223 | edited := "" |
| 224 | if createTimelineItem.Edited() { |
| 225 | edited = " (edited)" |
| 226 | } |
| 227 | |
| 228 | bugHeader := fmt.Sprintf("[%s] %s\n\n[%s] %s opened this bug on %s%s", |
| 229 | colors.Cyan(snap.Id().Human()), |
| 230 | colors.Bold(snap.Title), |
| 231 | colors.Yellow(snap.Status), |
| 232 | colors.Magenta(snap.Author.DisplayName()), |
| 233 | snap.CreateTime.Format(timeLayout), |
| 234 | edited, |
| 235 | ) |
| 236 | bugHeader, lines := text.Wrap(bugHeader, maxX, text.WrapIndent(" ")) |
| 237 | |
| 238 | v, err := sb.createOpView(g, showBugHeaderView, x0, y0, maxX+1, lines, false) |
| 239 | if err != nil { |
| 240 | return err |
| 241 | } |
| 242 | |
| 243 | _, _ = fmt.Fprint(v, bugHeader) |
| 244 | y0 += lines + 1 |
| 245 | |
| 246 | for _, op := range snap.Timeline { |
| 247 | viewName := op.CombinedId().String() |
| 248 | |
| 249 | // TODO: me might skip the rendering of blocks that are outside of the view |
| 250 | // but to do that we need to rework how sb.mainSelectableView is maintained |
| 251 | |
| 252 | switch op := op.(type) { |
| 253 | |
| 254 | case *bug.CreateTimelineItem: |
| 255 | var content string |
| 256 | var lines int |
| 257 | |
| 258 | if op.MessageIsEmpty() { |
| 259 | content, lines = text.WrapLeftPadded(emptyMessagePlaceholder(), maxX-1, 4) |
| 260 | } else { |
| 261 | content, lines = text.WrapLeftPadded(op.Message, maxX-1, 4) |
| 262 | } |
| 263 | |
| 264 | v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true) |
| 265 | if err != nil { |
| 266 | return err |
| 267 | } |
| 268 | _, _ = fmt.Fprint(v, content) |
no test coverage detected