示例#1
0
void pager_t::set_term_size(int w, int h) {
    assert(w > 0);
    assert(h > 0);
    available_term_width = w;
    available_term_height = h;
    recalc_min_widths(&completion_infos);
}
示例#2
0
void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &prefix) const
{
    size_t prefix_len = my_wcswidth(prefix.c_str());
    for (size_t i=0; i < infos->size(); i++)
    {
        comp_t *comp = &infos->at(i);

        // Compute comp_width
        const wcstring_list_t &comp_strings = comp->comp;
        for (size_t j=0; j < comp_strings.size(); j++)
        {
            // If there's more than one, append the length of ', '
            if (j >= 1)
                comp->comp_width += 2;

            comp->comp_width += prefix_len + my_wcswidth(comp_strings.at(j).c_str());
        }

        // Compute desc_width
        comp->desc_width = my_wcswidth(comp->desc.c_str());

        // Compute preferred width
        comp->pref_width = comp->comp_width + comp->desc_width + (comp->desc_width?4:0);
    }

    recalc_min_widths(infos);
}