static bool draw_chars(struct view *view, enum line_type type, const char *string, int max_len, bool use_tilde) { int len = 0; int col = 0; int trimmed = FALSE; size_t skip = view->pos.col > view->col ? view->pos.col - view->col : 0; if (max_len <= 0) return VIEW_MAX_LEN(view) <= 0; if (opt_iconv_out != ICONV_NONE) { string = encoding_iconv(opt_iconv_out, string); if (!string) return VIEW_MAX_LEN(view) <= 0; } len = utf8_length(&string, skip, &col, max_len, &trimmed, use_tilde, opt_tab_size); set_view_attr(view, type); if (len > 0) { waddnstr(view->win, string, len); if (trimmed && use_tilde) { set_view_attr(view, LINE_DELIMITER); waddch(view->win, '~'); col++; } } view->col += col; return VIEW_MAX_LEN(view) <= 0; }
static bool draw_chars(struct view *view, enum line_type type, const char *string, int length, int max_width, bool use_tilde) { int len = 0; int col = 0; int trimmed = false; size_t skip = view->pos.col > view->col ? view->pos.col - view->col : 0; if (max_width <= 0) return VIEW_MAX_LEN(view) <= 0; len = utf8_length(&string, length, skip, &col, max_width, &trimmed, use_tilde, opt_tab_size); if (opt_iconv_out != ICONV_NONE) { string = encoding_iconv(opt_iconv_out, string, len); if (!string) return VIEW_MAX_LEN(view) <= 0; } set_view_attr(view, type); if (len > 0) waddnstr(view->win, string, len); if (trimmed && use_tilde) { set_view_attr(view, LINE_DELIMITER); waddstr(view->win, opt_truncation_delimiter ? opt_truncation_delimiter : "~"); col++; } view->col += col; return VIEW_MAX_LEN(view) <= 0; }
bool draw_view_line(struct view *view, unsigned int lineno) { struct line *line; bool selected = (view->pos.offset + lineno == view->pos.lineno); /* FIXME: Disabled during code split. assert(view_is_displayed(view)); */ if (view->pos.offset + lineno >= view->lines) return FALSE; line = &view->line[view->pos.offset + lineno]; wmove(view->win, lineno, 0); if (line->cleareol) wclrtoeol(view->win); view->col = 0; view->curline = line; view->curtype = LINE_NONE; line->selected = FALSE; line->dirty = line->cleareol = 0; if (selected) { set_view_attr(view, LINE_CURSOR); line->selected = TRUE; view->ops->select(view, line); } return view->ops->draw(view, line, lineno); }
bool draw_graphic(struct view *view, enum line_type type, const chtype graphic[], size_t size, bool separator) { size_t skip = view->pos.col > view->col ? view->pos.col - view->col : 0; int max = VIEW_MAX_LEN(view); int i; if (max < size) size = max; set_view_attr(view, type); /* Using waddch() instead of waddnstr() ensures that * they'll be rendered correctly for the cursor line. */ for (i = skip; i < size; i++) waddch(view->win, graphic[i]); view->col += size; if (separator) { if (size < max && skip <= size) waddch(view->win, ' '); view->col++; } return VIEW_MAX_LEN(view) <= 0; }
bool draw_view_line(struct view *view, unsigned int lineno) { struct line *line; bool selected = (view->pos.offset + lineno == view->pos.lineno); bool ok; /* FIXME: Disabled during code split. assert(view_is_displayed(view)); */ if (view->pos.offset + lineno >= view->lines) return false; line = &view->line[view->pos.offset + lineno]; wmove(view->win, lineno, 0); if (line->cleareol) wclrtoeol(view->win); view->col = 0; view->curline = line; view->curtype = LINE_NONE; line->selected = false; line->dirty = line->cleareol = 0; if (selected) { set_view_attr(view, LINE_CURSOR); line->selected = true; view->ops->select(view, line); } ok = view->ops->draw(view, line, lineno); if (ok && line->search_result && view->regex) draw_view_line_search_result(view, lineno); return ok; }