MCPcopy Index your code
hub / github.com/git-bug/git-bug / renderMain

Method renderMain

termui/show_bug.go:211–379  ·  view source on GitHub ↗
(g *gocui.Gui, mainView *gocui.View)

Source from the content-addressed store, hash-verified

209}
210
211func (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)

Callers 1

layoutMethod · 0.95

Calls 15

createOpViewMethod · 0.95
emptyMessagePlaceholderFunction · 0.85
SnapshotMethod · 0.80
EditedMethod · 0.80
MessageIsEmptyMethod · 0.80
ActionMethod · 0.80
NameMethod · 0.65
IdMethod · 0.65
DisplayNameMethod · 0.65
StringMethod · 0.65
CombinedIdMethod · 0.65
TimeMethod · 0.65

Tested by

no test coverage detected