MCPcopy Index your code
hub / github.com/pterm/pterm / renderHeader

Method renderHeader

heatmap_printer.go:359–408  ·  view source on GitHub ↗
(buffer *bytes.Buffer, colWidth int, xAmount int)

Source from the content-addressed store, hash-verified

357}
358
359func (p HeatmapPrinter) renderHeader(buffer *bytes.Buffer, colWidth int, xAmount int) {
360 buffer.WriteString("\n")
361 if p.Boxed {
362 buffer.WriteString(p.SeparatorStyle.Sprint(p.LSeparator))
363 }
364 if p.Grid {
365 for i := 0; i < xAmount+1; i++ {
366 buffer.WriteString(strings.Repeat(p.SeparatorStyle.Sprint(p.HorizontalSeparator), colWidth))
367 if i < xAmount {
368 buffer.WriteString(p.SeparatorStyle.Sprint(p.TCrossSeparator))
369 }
370 }
371 }
372 if p.Boxed {
373 buffer.WriteString(p.SeparatorStyle.Sprint(p.LReverseSeparator))
374 }
375 if p.Grid {
376 buffer.WriteString("\n")
377 }
378 for j, f := range p.Axis.XAxis {
379 if j == 0 {
380 if p.Boxed {
381 buffer.WriteString(p.SeparatorStyle.Sprint(p.VerticalSeparator))
382 }
383 ct := internal.CenterText(" ", colWidth)
384 if len(ct) < colWidth {
385 ct += strings.Repeat(" ", colWidth-len(ct))
386 }
387 buffer.WriteString(p.AxisStyle.Sprint(ct))
388 if p.Grid {
389 buffer.WriteString(p.SeparatorStyle.Sprint(p.VerticalSeparator))
390 }
391 }
392 var ct string
393 ct = internal.CenterText(Sprintf("%v", f), colWidth)
394 if len(ct) < colWidth {
395 ct += strings.Repeat(" ", colWidth-len(ct))
396 }
397 buffer.WriteString(p.AxisStyle.Sprint(ct))
398
399 if j < xAmount {
400 if !p.Boxed && j == xAmount-1 {
401 continue
402 }
403 if p.Grid {
404 buffer.WriteString(p.SeparatorStyle.Sprint(p.VerticalSeparator))
405 }
406 }
407 }
408}
409
410func (p HeatmapPrinter) renderData(buffer *bytes.Buffer, colWidth int, xAmount int, yAmount int) {
411 for i, datum := range p.Data {

Callers 1

SrenderMethod · 0.95

Calls 3

CenterTextFunction · 0.92
SprintfFunction · 0.85
SprintMethod · 0.65

Tested by

no test coverage detected