Factor out app_fitting_items()
This commit is contained in:
parent
d95eb500f7
commit
87a738161a
22
nncmpp.c
22
nncmpp.c
|
@ -1135,11 +1135,17 @@ app_draw_header (void)
|
||||||
app_flush_header (&buf, attrs[false]);
|
app_flush_header (&buf, attrs[false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
app_fitting_items (void)
|
||||||
|
{
|
||||||
|
// The raw number of items that would have fit on the terminal
|
||||||
|
return LINES - g.header_height;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
app_visible_items (void)
|
app_visible_items (void)
|
||||||
{
|
{
|
||||||
// This may eventually include a header bar and/or a status bar
|
return MAX (0, app_fitting_items ());
|
||||||
return MAX (0, LINES - g.header_height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1220,8 +1226,8 @@ app_draw_view (void)
|
||||||
bool want_scrollbar = (int) tab->item_count > app_visible_items ();
|
bool want_scrollbar = (int) tab->item_count > app_visible_items ();
|
||||||
int view_width = COLS - want_scrollbar;
|
int view_width = COLS - want_scrollbar;
|
||||||
|
|
||||||
int to_show = MIN (LINES - g.header_height,
|
int to_show =
|
||||||
(int) tab->item_count - tab->item_top);
|
MIN (app_fitting_items (), (int) tab->item_count - tab->item_top);
|
||||||
for (int row = 0; row < to_show; row++)
|
for (int row = 0; row < to_show; row++)
|
||||||
{
|
{
|
||||||
int item_index = tab->item_top + row;
|
int item_index = tab->item_top + row;
|
||||||
|
@ -1560,12 +1566,12 @@ app_process_action (enum action action)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_GOTO_PAGE_PREVIOUS:
|
case ACTION_GOTO_PAGE_PREVIOUS:
|
||||||
app_scroll ((int) g.header_height - LINES);
|
app_scroll (-app_fitting_items ());
|
||||||
app_move_selection ((int) g.header_height - LINES);
|
app_move_selection (-app_fitting_items ());
|
||||||
break;
|
break;
|
||||||
case ACTION_GOTO_PAGE_NEXT:
|
case ACTION_GOTO_PAGE_NEXT:
|
||||||
app_scroll (LINES - (int) g.header_height);
|
app_scroll (app_fitting_items ());
|
||||||
app_move_selection (LINES - (int) g.header_height);
|
app_move_selection (app_fitting_items ());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
Loading…
Reference in New Issue