Skip to content

Commit

Permalink
Allow double-tapping tab to fully disclose pager, per #291
Browse files Browse the repository at this point in the history
  • Loading branch information
ridiculousfish committed Feb 20, 2014
1 parent adf5b03 commit 8eaabac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 9 additions & 1 deletion pager.cpp
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions pager.h
Expand Up @@ -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;

Expand Down
12 changes: 10 additions & 2 deletions reader.cpp
Expand Up @@ -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
{
Expand Down

0 comments on commit 8eaabac

Please sign in to comment.