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

Method render

termui/bug_table.go:301–347  ·  view source on GitHub ↗
(v *gocui.View, maxX int)

Source from the content-addressed store, hash-verified

299}
300
301func (bt *bugTable) render(v *gocui.View, maxX int) {
302 columnWidths := bt.getColumnWidths(maxX)
303
304 for _, excerpt := range bt.excerpts {
305 summaryTxt := fmt.Sprintf("%3d", excerpt.LenComments-1)
306 if excerpt.LenComments-1 <= 0 {
307 summaryTxt = ""
308 }
309 if excerpt.LenComments-1 > 999 {
310 summaryTxt = " ∞"
311 }
312
313 var labelsTxt strings.Builder
314 for _, l := range excerpt.Labels {
315 labelsTxt.WriteString(" ")
316 lc256 := l.Color().Term256()
317 labelsTxt.WriteString(lc256.Escape())
318 labelsTxt.WriteString("◼")
319 labelsTxt.WriteString(lc256.Unescape())
320 }
321
322 author, err := bt.repo.Identities().ResolveExcerpt(excerpt.AuthorId)
323 if err != nil {
324 panic(err)
325 }
326
327 id := text.LeftPadMaxLine(excerpt.Id().Human(), columnWidths["id"], 0)
328 status := text.LeftPadMaxLine(excerpt.Status.String(), columnWidths["status"], 0)
329 labels := text.TruncateMax(labelsTxt.String(), minInt(columnWidths["title"]-2, 10))
330 title := text.LeftPadMaxLine(strings.TrimSpace(excerpt.Title), columnWidths["title"]-text.Len(labels), 0)
331 authorTxt := text.LeftPadMaxLine(author.DisplayName(), columnWidths["author"], 0)
332 comments := text.LeftPadMaxLine(summaryTxt, columnWidths["comments"], 0)
333 lastEdit := text.LeftPadMaxLine(humanize.Time(excerpt.EditTime()), columnWidths["lastEdit"], 1)
334
335 _, _ = fmt.Fprintf(v, "%s %s %s%s %s %s %s\n",
336 colors.Cyan(id),
337 colors.Yellow(status),
338 title,
339 labels,
340 colors.Magenta(authorTxt),
341 comments,
342 lastEdit,
343 )
344 }
345
346 _ = v.SetHighlight(bt.selectCursor, true)
347}
348
349func (bt *bugTable) renderHeader(v *gocui.View, maxX int) {
350 columnWidths := bt.getColumnWidths(maxX)

Callers 2

layoutMethod · 0.95
index.tsxFile · 0.80

Calls 15

getColumnWidthsMethod · 0.95
minIntFunction · 0.85
Term256Method · 0.80
EscapeMethod · 0.80
UnescapeMethod · 0.80
ResolveExcerptMethod · 0.80
IdentitiesMethod · 0.80
ColorMethod · 0.65
IdMethod · 0.65
StringMethod · 0.65
DisplayNameMethod · 0.65
TimeMethod · 0.65

Tested by

no test coverage detected