Restyle pager.cpp via make style

This commit is contained in:
ridiculousfish 2016-12-03 13:38:50 -08:00
parent ffd4754cb2
commit ed85393611

View file

@ -55,8 +55,8 @@ static size_t divide_round_up(size_t numer, size_t denom) {
/// \param max the maximum space that may be used for printing
/// \param has_more if this flag is true, this is not the entire string, and the string should be
/// ellipsized even if the string fits but takes up the whole space.
static size_t print_max(const wcstring &str, highlight_spec_t color, size_t max,
bool has_more, line_t *line) {
static size_t print_max(const wcstring &str, highlight_spec_t color, size_t max, bool has_more,
line_t *line) {
size_t remaining = max;
for (size_t i = 0; i < str.size(); i++) {
wchar_t c = str.at(i);
@ -132,17 +132,22 @@ line_t pager_t::completion_print_item(const wcstring &prefix, const comp_t *c, s
true /* has_more */, &line_data);
}
highlight_spec_t packed_color = highlight_spec_pager_prefix | highlight_make_background(bg_color);
comp_remaining -= print_max(prefix, packed_color, comp_remaining, !comp.empty(), &line_data);
highlight_spec_t packed_color =
highlight_spec_pager_prefix | highlight_make_background(bg_color);
comp_remaining -=
print_max(prefix, packed_color, comp_remaining, !comp.empty(), &line_data);
packed_color = highlight_spec_pager_completion | highlight_make_background(bg_color);
comp_remaining -= print_max(comp, packed_color, comp_remaining, i + 1 < c->comp.size(), &line_data);
comp_remaining -=
print_max(comp, packed_color, comp_remaining, i + 1 < c->comp.size(), &line_data);
}
size_t desc_remaining = width - comp_width + comp_remaining;
if (c->desc_width > 0 && desc_remaining > 4) {
highlight_spec_t desc_color = highlight_spec_pager_description | highlight_make_background(bg_color);
highlight_spec_t punct_color = highlight_spec_pager_completion | highlight_make_background(bg_color);
highlight_spec_t desc_color =
highlight_spec_pager_description | highlight_make_background(bg_color);
highlight_spec_t punct_color =
highlight_spec_pager_completion | highlight_make_background(bg_color);
// always have at least two spaces to separate completion and description
desc_remaining -= print_max(L" ", punct_color, 2, false, &line_data);
@ -196,9 +201,7 @@ void pager_t::completion_print(size_t cols, const size_t *width_by_column, size_
bool is_selected = (idx == effective_selected_idx);
// Print this completion on its own "line".
line_t line = completion_print_item(
prefix, el, row, col,
width_by_column[col], row % 2,
line_t line = completion_print_item(prefix, el, row, col, width_by_column[col], row % 2,
is_selected, rendering);
// If there's more to come, append two spaces.
@ -383,11 +386,15 @@ bool pager_t::completion_try_print(size_t cols, const wcstring &prefix, const co
size_t width_by_column[PAGER_MAX_COLS] = {0};
// Skip completions on tiny terminals.
if (this->available_term_width < PAGER_MIN_WIDTH || this->available_term_height < PAGER_MIN_HEIGHT) return true;
if (this->available_term_width < PAGER_MIN_WIDTH ||
this->available_term_height < PAGER_MIN_HEIGHT)
return true;
// Compute the effective term width and term height, accounting for disclosure.
size_t term_width = this->available_term_width;
size_t term_height = this->available_term_height - 1 - (search_field_shown ? 1 : 0); // we always subtract 1 to make room for a comment row
size_t 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, (size_t)PAGER_UNDISCLOSED_MAX_ROWS);
}
@ -481,11 +488,9 @@ bool pager_t::completion_try_print(size_t cols, const wcstring &prefix, const co
if (!progress_text.empty()) {
line_t &line = rendering->screen_data.add_line();
highlight_spec_t spec =
highlight_spec_pager_progress |
highlight_spec_t spec = highlight_spec_pager_progress |
highlight_make_background(highlight_spec_pager_progress);
print_max(progress_text, spec, term_width,
true /* has_more */, &line);
print_max(progress_text, spec, term_width, true /* has_more */, &line);
}
if (search_field_shown) {