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

Function term_columns

pager.c:203–232  ·  view source on GitHub ↗

* Return cached value (if set) or $COLUMNS environment variable (if * set and positive) or ioctl(1, TIOCGWINSZ).ws_col (if positive), * and default to 80 if all else fails. */

Source from the content-addressed store, hash-verified

201 * and default to 80 if all else fails.
202 */
203int term_columns(void)
204{
205 static int term_columns_at_startup;
206
207 char *col_string;
208 int n_cols;
209
210 if (term_columns_at_startup)
211 return term_columns_at_startup;
212
213 term_columns_at_startup = 80;
214 term_columns_guessed = 1;
215
216 col_string = getenv("COLUMNS");
217 if (col_string && (n_cols = atoi(col_string)) > 0) {
218 term_columns_at_startup = n_cols;
219 term_columns_guessed = 0;
220 }
221#ifdef TIOCGWINSZ
222 else {
223 struct winsize ws;
224 if (!ioctl(1, TIOCGWINSZ, &ws) && ws.ws_col) {
225 term_columns_at_startup = ws.ws_col;
226 term_columns_guessed = 0;
227 }
228 }
229#endif
230
231 return term_columns_at_startup;
232}
233
234/*
235 * Clear the entire line, leave cursor in first column.

Callers 7

print_columnsFunction · 0.85
setup_pagerFunction · 0.85
term_clear_lineFunction · 0.85
show_statsFunction · 0.85
displayFunction · 0.85
refcol_widthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected