static bool draw_text_overflow(struct view *view, const char *text, enum line_type type, int overflow_length, int offset) { bool on = overflow_length > 0; if (on) { int overflow = overflow_length + offset; int max = MIN(VIEW_MAX_LEN(view), overflow); const char *tmp = text; int text_width = 0; int trimmed = false; size_t len = utf8_length(&tmp, -1, 0, &text_width, max, &trimmed, false, 1); if (draw_text_expanded(view, type, text, -1, text_width, max < overflow)) return true; text += len; type = LINE_OVERFLOW; } if (*text && draw_text(view, type, text)) return true; return VIEW_MAX_LEN(view) <= 0; }
bool draw_text_overflow(struct view *view, const char *text, bool on, int overflow, enum line_type type) { if (on) { int max = MIN(VIEW_MAX_LEN(view), overflow); int len = strlen(text); if (draw_text_expanded(view, type, text, max, max < overflow)) return TRUE; text = len > overflow ? text + overflow : ""; type = LINE_OVERFLOW; } if (*text && draw_text(view, type, text)) return TRUE; return VIEW_MAX_LEN(view) <= 0; }
bool draw_text(struct view *view, enum line_type type, const char *string) { return draw_text_expanded(view, type, string, VIEW_MAX_LEN(view), TRUE); }
bool view_column_draw(struct view *view, struct line *line, unsigned int lineno) { struct view_column *column = view->columns; struct view_column_data column_data = {0}; if (!view->ops->get_column_data(view, line, &column_data)) return true; if (column_data.section) column = column_data.section; for (; column; column = column->next) { mode_t mode = column_data.mode ? *column_data.mode : 0; if (column->hidden) continue; switch (column->type) { case VIEW_COLUMN_DATE: if (draw_date(view, column, column_data.date)) return true; continue; case VIEW_COLUMN_AUTHOR: if (draw_author(view, column, column_data.author)) return true; continue; case VIEW_COLUMN_REF: if (draw_ref(view, column, column_data.ref)) return true; continue; case VIEW_COLUMN_ID: if (draw_id(view, column, column_data.reflog ? column_data.reflog : column_data.id)) return true; continue; case VIEW_COLUMN_LINE_NUMBER: if (draw_lineno(view, column, column_data.line_number ? *column_data.line_number : lineno)) return true; continue; case VIEW_COLUMN_MODE: if (draw_mode(view, column, mode)) return true; continue; case VIEW_COLUMN_FILE_SIZE: if (draw_file_size(view, column, column_data.file_size ? *column_data.file_size : 0, mode)) return true; continue; case VIEW_COLUMN_COMMIT_TITLE: if (draw_commit_title(view, column, column_data.graph, column_data.graph_canvas, column_data.refs, column_data.commit_title)) return true; continue; case VIEW_COLUMN_FILE_NAME: if (draw_filename(view, column, column_data.file_name, mode)) return true; continue; case VIEW_COLUMN_SECTION: if (draw_text(view, column->opt.section.type, column->opt.section.text)) return true; continue; case VIEW_COLUMN_STATUS: if (draw_status(view, column, line->type, column_data.status)) return true; continue; case VIEW_COLUMN_TEXT: { enum line_type type = line->type; const char *text = column_data.text; if (line->wrapped && draw_text(view, LINE_DELIMITER, "+")) return true; if (line->graph_indent) { size_t indent = get_graph_indent(text); if (draw_text_expanded(view, LINE_DEFAULT, text, -1, indent, false)) return true; text += indent; } if (line->commit_title) { if (draw_text_overflow(view, text, LINE_DEFAULT, column->opt.text.commit_title_overflow, 4)) return true; } else if (column_data.box) { const struct box *box = column_data.box; const char *text = box->text; size_t i; for (i = 0; i < box->cells; i++) { const struct box_cell *cell = &box->cell[i]; if (draw_textn(view, cell->type, text, cell->length)) return true; text += cell->length; } } else if (draw_text(view, type, text)) { return true; } } continue; } } return true; }
static inline bool draw_textn(struct view *view, enum line_type type, const char *string, int length) { return draw_text_expanded(view, type, string, length, VIEW_MAX_LEN(view), false); }