From 8eaabacf44698f7cde0c4d10cecb76c06b51b1b7 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Thu, 20 Feb 2014 13:30:26 -0800 Subject: [PATCH] Allow double-tapping tab to fully disclose pager, per #291 --- pager.cpp | 10 +++++++++- pager.h | 3 +++ reader.cpp | 12 ++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pager.cpp b/pager.cpp index 16456bc9d..b137bca2f 100644 --- a/pager.cpp +++ b/pager.cpp @@ -449,7 +449,9 @@ bool pager_t::completion_try_print(size_t cols, const wcstring &prefix, const co int term_width = this->available_term_width; int term_height = this->available_term_height - 1 - (search_field_shown ? 1 : 0); // we always subtract 1 to make room for a comment row if (! this->fully_disclosed) + { term_height = mini(term_height, PAGER_UNDISCLOSED_MAX_ROWS); + } size_t row_count = divide_round_up(lst.size(), cols); @@ -691,7 +693,8 @@ void pager_t::update_rendering(page_rendering_t *rendering) const rendering->selected_completion_idx != this->visual_selected_completion_index(rendering->rows, rendering->cols) || rendering->search_field_shown != this->search_field_shown || rendering->search_field_line.text != this->search_field_line.text || - rendering->search_field_line.position != this->search_field_line.position) + rendering->search_field_line.position != this->search_field_line.position || + (rendering->remaining_to_disclose > 0 && this->fully_disclosed)) { *rendering = this->render(); } @@ -934,6 +937,11 @@ bool pager_t::is_navigating_contents() const return selected_completion_idx != PAGER_SELECTION_NONE; } +void pager_t::set_fully_disclosed(bool flag) +{ + fully_disclosed = flag; +} + const completion_t *pager_t::selected_completion(const page_rendering_t &rendering) const { const completion_t * result = NULL; diff --git a/pager.h b/pager.h index 8253dc113..a1c024a6e 100644 --- a/pager.h +++ b/pager.h @@ -159,6 +159,9 @@ class pager_t /* Indicates if we are navigating our contents */ bool is_navigating_contents() const; + /* Become fully disclosed */ + void set_fully_disclosed(bool flag); + /* Position of the cursor */ size_t cursor_position() const; diff --git a/reader.cpp b/reader.cpp index db83e4b9d..250884ffb 100644 --- a/reader.cpp +++ b/reader.cpp @@ -3337,8 +3337,16 @@ const wchar_t *reader_readline(void) editable_line_t *el = &data->command_line; if (data->is_navigating_pager_contents() || (! comp_empty && last_char == R_COMPLETE)) { - /* The user typed R_COMPLETE more than once in a row. Cycle through our available completions. */ - select_completion_in_direction(c == R_COMPLETE ? direction_next : direction_prev); + /* The user typed R_COMPLETE more than once in a row. If we are not yet fully disclosed, then become so; otherwise cycle through our available completions. */ + if (data->current_page_rendering.remaining_to_disclose > 0) + { + data->pager.set_fully_disclosed(true); + reader_repaint_needed(); + } + else + { + select_completion_in_direction(c == R_COMPLETE ? direction_next : direction_prev); + } } else {