MCPcopy Index your code
hub / github.com/git/git / display_cell

Function display_cell

column.c:114–144  ·  view source on GitHub ↗

Print a cell to stdout with all necessary leading/trailing space */

Source from the content-addressed store, hash-verified

112
113/* Print a cell to stdout with all necessary leading/trailing space */
114static int display_cell(struct column_data *data, int initial_width,
115 const char *empty_cell, int x, int y)
116{
117 int i, len, newline;
118
119 i = XY2LINEAR(data, x, y);
120 if (i >= data->list->nr)
121 return -1;
122
123 len = data->len[i];
124 if (data->width && data->len[data->width[x]] < initial_width) {
125 /*
126 * empty_cell has initial_width chars, if real column
127 * is narrower, increase len a bit so we fill less
128 * space.
129 */
130 len += initial_width - data->len[data->width[x]];
131 len -= data->opts.padding;
132 }
133
134 if (COL_LAYOUT(data->colopts) == COL_COLUMN)
135 newline = i + data->rows >= data->list->nr;
136 else
137 newline = x == data->cols - 1 || i == data->list->nr - 1;
138
139 printf("%s%s%s",
140 x == 0 ? data->opts.indent : "",
141 data->list->items[i].string,
142 newline ? data->opts.nl : empty_cell + len);
143 return 0;
144}
145
146/* Display COL_COLUMN or COL_ROW */
147static void display_table(const struct string_list *list,

Callers 1

display_tableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected