| 272 | } |
| 273 | |
| 274 | func (m selectModel) viewableOptions() ([]string, int) { |
| 275 | options := m.filteredOptions() |
| 276 | halfHeight := m.height / 2 |
| 277 | bottom := 0 |
| 278 | top := len(options) |
| 279 | |
| 280 | switch { |
| 281 | case m.cursor <= halfHeight: |
| 282 | top = min(top, m.height) |
| 283 | case m.cursor < top-halfHeight: |
| 284 | bottom = max(0, m.cursor-halfHeight) |
| 285 | top = min(top, m.cursor+halfHeight+1) |
| 286 | default: |
| 287 | bottom = max(0, top-m.height) |
| 288 | } |
| 289 | |
| 290 | return options[bottom:top], bottom |
| 291 | } |
| 292 | |
| 293 | func (m selectModel) filteredOptions() []string { |
| 294 | options := []string{} |