aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-01-29 17:56:59 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2017-01-29 17:56:59 +0100
commit87a738161a5f48e71d323a4c3c899f1aa3712af3 (patch)
tree90fca60e822a5442c7245f5850386ba5fcb20fb1
parentd95eb500f7ae55f046114eac1814531e2dcd2c42 (diff)
downloadnncmpp-87a738161a5f48e71d323a4c3c899f1aa3712af3.tar.gz
nncmpp-87a738161a5f48e71d323a4c3c899f1aa3712af3.tar.xz
nncmpp-87a738161a5f48e71d323a4c3c899f1aa3712af3.zip
Factor out app_fitting_items()
-rw-r--r--nncmpp.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/nncmpp.c b/nncmpp.c
index e26df06..0b651ac 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -1136,10 +1136,16 @@ app_draw_header (void)
}
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
app_visible_items (void)
{
- // This may eventually include a header bar and/or a status bar
- return MAX (0, LINES - g.header_height);
+ return MAX (0, app_fitting_items ());
}
static void
@@ -1220,8 +1226,8 @@ app_draw_view (void)
bool want_scrollbar = (int) tab->item_count > app_visible_items ();
int view_width = COLS - want_scrollbar;
- int to_show = MIN (LINES - g.header_height,
- (int) tab->item_count - tab->item_top);
+ int to_show =
+ MIN (app_fitting_items (), (int) tab->item_count - tab->item_top);
for (int row = 0; row < to_show; row++)
{
int item_index = tab->item_top + row;
@@ -1560,12 +1566,12 @@ app_process_action (enum action action)
break;
case ACTION_GOTO_PAGE_PREVIOUS:
- app_scroll ((int) g.header_height - LINES);
- app_move_selection ((int) g.header_height - LINES);
+ app_scroll (-app_fitting_items ());
+ app_move_selection (-app_fitting_items ());
break;
case ACTION_GOTO_PAGE_NEXT:
- app_scroll (LINES - (int) g.header_height);
- app_move_selection (LINES - (int) g.header_height);
+ app_scroll (app_fitting_items ());
+ app_move_selection (app_fitting_items ());
break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -