MCPcopy
hub / github.com/sammcj/gollama / calculateColumnWidths

Function calculateColumnWidths

helpers.go:44–83  ·  view source on GitHub ↗
(totalWidth int)

Source from the content-addressed store, hash-verified

42const minParamSizeWidth = 10
43
44func calculateColumnWidths(totalWidth int) (nameWidth, sizeWidth, quantWidth, modifiedWidth, idWidth, familyWidth, paramSizeWidth int) {
45 // Calculate column widths
46 nameWidth = int(0.40 * float64(totalWidth))
47 sizeWidth = int(0.05 * float64(totalWidth))
48 quantWidth = int(0.05 * float64(totalWidth))
49 familyWidth = int(0.05 * float64(totalWidth))
50 modifiedWidth = int(0.05 * float64(totalWidth))
51 idWidth = int(0.02 * float64(totalWidth))
52 paramSizeWidth = int(0.05 * float64(totalWidth))
53
54 // Set the absolute minimum width for each column
55 if nameWidth < minNameWidth {
56 nameWidth = minNameWidth
57 }
58 if sizeWidth < minSizeWidth {
59 sizeWidth = minSizeWidth
60 }
61 if quantWidth < minQuantWidth {
62 quantWidth = minQuantWidth
63 }
64 if modifiedWidth < minModifiedWidth {
65 modifiedWidth = minModifiedWidth
66 }
67 if idWidth < minIDWidth {
68 idWidth = minIDWidth
69 }
70 if familyWidth < minFamilyWidth {
71 familyWidth = minFamilyWidth
72 }
73 if paramSizeWidth < minParamSizeWidth {
74 paramSizeWidth = minParamSizeWidth
75 }
76
77 // If the total width is less than the sum of the minimum column widths, adjust the name column width and make sure all columns are aligned
78 if totalWidth < nameWidth+sizeWidth+quantWidth+familyWidth+modifiedWidth+idWidth+paramSizeWidth {
79 nameWidth = totalWidth - sizeWidth - quantWidth - familyWidth - modifiedWidth - idWidth - paramSizeWidth
80 }
81
82 return
83}
84
85func removeModels(models []Model, selectedModels []Model) []Model {
86 result := make([]Model, 0)

Callers 2

RenderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected