Allow double-tapping tab to fully disclose pager, per #291

This commit is contained in:
ridiculousfish 2014-02-20 13:30:26 -08:00
parent adf5b036d6
commit 8eaabacf44
3 changed files with 22 additions and 3 deletions

View file

@ -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;

View file

@ -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;

View file

@ -3337,9 +3337,17 @@ 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. */
/* 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
{
/* Either the user hit tab only once, or we had no visible completion list. */