Update pagination according to the amount of markdowns for the current state.
()
| 253 | // Update pagination according to the amount of markdowns for the current |
| 254 | // state. |
| 255 | func (m *stashModel) updatePagination() { |
| 256 | _, helpHeight := m.helpView() |
| 257 | |
| 258 | availableHeight := m.common.height - |
| 259 | stashViewTopPadding - |
| 260 | helpHeight - |
| 261 | stashViewBottomPadding |
| 262 | |
| 263 | m.paginator().PerPage = max(1, availableHeight/stashViewItemHeight) |
| 264 | |
| 265 | if pages := len(m.getVisibleMarkdowns()); pages < 1 { |
| 266 | m.paginator().SetTotalPages(1) |
| 267 | } else { |
| 268 | m.paginator().SetTotalPages(pages) |
| 269 | } |
| 270 | |
| 271 | // Make sure the page stays in bounds |
| 272 | if m.paginator().Page >= m.paginator().TotalPages-1 { |
| 273 | m.paginator().Page = max(0, m.paginator().TotalPages-1) |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | // MarkdownIndex returns the index of the currently selected markdown item. |
| 278 | func (m stashModel) markdownIndex() int { |
no test coverage detected