aboutsummaryrefslogtreecommitdiffhomepage
path: root/pager.cpp
diff options
context:
space:
mode:
authorGravatar Martin Hamrle <martin.hamrle@monetas.net>2015-03-02 22:08:29 +0100
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2015-03-20 14:41:38 +0800
commit94e9d6a5ef97884de84debf06680806661272523 (patch)
tree4a5765bf6d96e9edad5be9780a02a759a43ce167 /pager.cpp
parent733108e33bc651e1292a50d7e5a88b46d460836e (diff)
Add paging into navigating pager
Diffstat (limited to 'pager.cpp')
-rw-r--r--pager.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/pager.cpp b/pager.cpp
index 002479bc..b2a4e4da 100644
--- a/pager.cpp
+++ b/pager.cpp
@@ -684,6 +684,7 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio
{
/* These directions do something sane */
case direction_south:
+ case direction_page_south:
case direction_next:
case direction_prev:
if (direction == direction_prev)
@@ -698,6 +699,7 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio
/* These do nothing */
case direction_north:
+ case direction_page_north:
case direction_east:
case direction_west:
case direction_deselect:
@@ -744,9 +746,18 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio
/* Cardinal directions. We have a completion index; we wish to compute its row and column. */
size_t current_row = this->get_selected_row(rendering);
size_t current_col = this->get_selected_column(rendering);
+ size_t page_height = maxi(rendering.term_height - 1, 1);
switch (direction)
{
+ case direction_page_north:
+ {
+ if (current_row > page_height)
+ current_row = current_row - page_height;
+ else
+ current_row = 0;
+ break;
+ }
case direction_north:
{
/* Go up a whole row. If we cycle, go to the previous column. */
@@ -763,6 +774,21 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio
break;
}
+ case direction_page_south:
+ {
+ if (current_row + page_height < rendering.rows)
+ {
+ current_row += page_height;
+ }
+ else
+ {
+ current_row = rendering.rows - 1;
+ if (current_col * rendering.rows + current_row >= completion_infos.size()) {
+ current_row = (completion_infos.size() - 1) % rendering.rows;
+ }
+ }
+ break;
+ }
case direction_south:
{
/* Go down, unless we are in the last row. Note that this means that we may set selected_completion_idx to an out-of-bounds value if the last row is incomplete; this is a feature (it allows "last column memory"). */