()
| 189 | } |
| 190 | |
| 191 | func (tb *Table) UpdateMaxWidths() { |
| 192 | if tb.SliceSize == 0 { |
| 193 | return |
| 194 | } |
| 195 | for fli := 0; fli < tb.numVisibleFields; fli++ { |
| 196 | field := tb.visibleFields[fli] |
| 197 | tb.colMaxWidths[fli] = 0 |
| 198 | val := tb.sliceElementValue(0) |
| 199 | fval := val.FieldByIndex(field.Index) |
| 200 | _, isicon := fval.Interface().(icons.Icon) |
| 201 | isString := fval.Type().Kind() == reflect.String |
| 202 | if !isString || isicon { |
| 203 | continue |
| 204 | } |
| 205 | mxw := 0 |
| 206 | for rw := 0; rw < tb.SliceSize; rw++ { |
| 207 | val := tb.sliceElementValue(rw) |
| 208 | str := reflectx.ToString(val.FieldByIndex(field.Index).Interface()) |
| 209 | mxw = max(mxw, len(str)) |
| 210 | } |
| 211 | tb.colMaxWidths[fli] = mxw |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | func (tb *Table) makeHeader(p *tree.Plan) { |
| 216 | tree.AddAt(p, "header", func(w *Frame) { |
nothing calls this directly
no test coverage detected