- // set max_cols if length exceeded
- max_cols = (line->length > max_cols) ? line->length : max_cols;
+ if(line->length > COLS) {
+ i = line->length;
+ offset = 0;
+ while(i > COLS) {
+
+ i = prev_blank(line->text, offset + COLS) - offset;
+
+ // single word is > COLS
+ if(!i) {
+ // calculate min_width
+ i = next_blank(line->text, offset + COLS) - offset;
+
+ // disable ncurses
+ endwin();
+
+ // print error
+ fprintf(stderr, "Error: Terminal width (%i columns) too small. Need at least %i columns.\n", COLS, i);
+ fprintf(stderr, "You may need to shorten some lines by inserting line breaks.\n");
+
+ return(1);
+ }
+
+ // set max_cols
+ max_cols = (i > max_cols) ? i : max_cols;
+
+ // iterate to next line
+ offset = prev_blank(line->text, offset + COLS);
+ i = line->length - offset;
+ lc++;
+ }
+ // set max_cols one last time
+ max_cols = (i > max_cols) ? i : max_cols;
+ } else {
+ // set max_cols
+ max_cols = (line->length > max_cols) ? line->length : max_cols;
+ }
+ lc++;