| 24 | #define OPT_SHOW_LEN 80 |
| 25 | |
| 26 | static unsigned int get_columns(void) |
| 27 | { |
| 28 | int ws_col = 0; |
| 29 | const char *env = getenv("COLUMNS"); |
| 30 | |
| 31 | if (env) |
| 32 | ws_col = atoi(env); |
| 33 | |
| 34 | #ifdef TIOCGWINSZ |
| 35 | if (!ws_col) |
| 36 | { |
| 37 | struct winsize w; |
| 38 | if (ioctl(0, TIOCGWINSZ, &w) != -1) |
| 39 | ws_col = w.ws_col; |
| 40 | } |
| 41 | #endif |
| 42 | if (!ws_col) |
| 43 | ws_col = 80; |
| 44 | |
| 45 | return ws_col; |
| 46 | } |
| 47 | |
| 48 | /* Return number of chars of words to put on this line. |
| 49 | * Prefix is set to number to skip at start, maxlen is max width, returns |