Switch s_write to accepting const vector & instead of raw pointers

This commit is contained in:
ridiculousfish 2019-03-03 18:49:57 -08:00
parent ccbc9d57f2
commit 89a7cc5da3
3 changed files with 11 additions and 12 deletions

View File

@ -638,8 +638,8 @@ void reader_data_t::repaint() {
bool focused_on_pager = active_edit_line() == &pager.search_field_line;
size_t cursor_position = focused_on_pager ? pager.cursor_position() : cmd_line->position;
s_write(&screen, left_prompt_buff, right_prompt_buff, full_line, cmd_line->size(), &colors[0],
&indents[0], cursor_position, current_page_rendering, focused_on_pager);
s_write(&screen, left_prompt_buff, right_prompt_buff, full_line, cmd_line->size(), colors,
indents, cursor_position, current_page_rendering, focused_on_pager);
repaint_needed = false;
}

View File

@ -802,7 +802,8 @@ static size_t truncation_offset_for_width(const std::vector<size_t> &width_by_of
static screen_layout_t compute_layout(screen_t *s, size_t screen_width,
const wcstring &left_prompt_str,
const wcstring &right_prompt_str, const wcstring &commandline,
const wcstring &autosuggestion_str, const int *indent) {
const wcstring &autosuggestion_str,
const std::vector<int> &indent) {
UNUSED(s);
screen_layout_t result = {};
@ -847,7 +848,7 @@ static screen_layout_t compute_layout(screen_t *s, size_t screen_width,
if (c == L'\n') {
// Make a new line.
command_lines.push_back(wcstring());
line_widths.push_back(indent[i] * INDENT_STEP);
line_widths.push_back(indent.at(i) * INDENT_STEP);
} else {
command_lines.back() += c;
line_widths.back() += fish_wcwidth_min_0(c);
@ -951,12 +952,10 @@ static screen_layout_t compute_layout(screen_t *s, size_t screen_width,
}
void s_write(screen_t *s, const wcstring &left_prompt, const wcstring &right_prompt,
const wcstring &commandline, size_t explicit_len, const highlight_spec_t *colors,
const int *indent, size_t cursor_pos, const page_rendering_t &pager,
bool cursor_is_within_pager) {
const wcstring &commandline, size_t explicit_len,
const std::vector<highlight_spec_t> &colors, const std::vector<int> &indent,
size_t cursor_pos, const page_rendering_t &pager, bool cursor_is_within_pager) {
screen_data_t::cursor_t cursor_arr;
CHECK(s, );
CHECK(indent, );
// Turn the command line into the explicit portion and the autosuggestion.
const wcstring explicit_command_line = commandline.substr(0, explicit_len);

View File

@ -169,9 +169,9 @@ class screen_t {
/// \param pager_data any pager data, to append to the screen
/// \param cursor_is_within_pager whether the position is within the pager line (first line)
void s_write(screen_t *s, const wcstring &left_prompt, const wcstring &right_prompt,
const wcstring &commandline, size_t explicit_len, const highlight_spec_t *colors,
const int *indent, size_t cursor_pos, const page_rendering_t &pager_data,
bool cursor_is_within_pager);
const wcstring &commandline, size_t explicit_len,
const std::vector<highlight_spec_t> &colors, const std::vector<int> &indent,
size_t cursor_pos, const page_rendering_t &pager_data, bool cursor_is_within_pager);
/// This function resets the screen buffers internal knowledge about the contents of the screen. Use
/// this function when some other function than s_write has written to the screen.