New creates a new model for the table widget.
(opts ...Option)
| 174 | |
| 175 | // New creates a new model for the table widget. |
| 176 | func New(opts ...Option) Model { |
| 177 | m := Model{ |
| 178 | cursor: 0, |
| 179 | viewport: viewport.New(0, 20), |
| 180 | |
| 181 | KeyMap: DefaultKeyMap(), |
| 182 | styles: DefaultStyles(), |
| 183 | |
| 184 | hcol: -1, |
| 185 | hstep: 10, |
| 186 | hcursor: 0, |
| 187 | } |
| 188 | |
| 189 | for _, opt := range opts { |
| 190 | opt(&m) |
| 191 | } |
| 192 | |
| 193 | m.UpdateViewport() |
| 194 | |
| 195 | return m |
| 196 | } |
| 197 | |
| 198 | // WithColumns sets the table columns (headers). |
| 199 | func WithColumns(cols []Column) Option { |