| 65 | // text with newlines inserted just before the end of screen is reached. |
| 66 | |
| 67 | void FieldWord(CONST char *sz) |
| 68 | { |
| 69 | static char line[cchSzMax]; |
| 70 | static int cursor = 0; |
| 71 | int ich = 0, i, j; |
| 72 | char ch; |
| 73 | |
| 74 | // Display buffer if function called with a null string. |
| 75 | |
| 76 | if (sz == NULL) |
| 77 | sz = "\n"; |
| 78 | else if (cursor > 0) |
| 79 | line[cursor++] = ' '; |
| 80 | loop { |
| 81 | ch = sz[ich]; |
| 82 | if (ch == chNull) |
| 83 | break; |
| 84 | if (ch == '\n') { |
| 85 | line[cursor] = 0; |
| 86 | PrintSz(line); PrintL(); |
| 87 | cursor = 0; |
| 88 | ich++; |
| 89 | continue; |
| 90 | } |
| 91 | line[cursor] = ch; |
| 92 | |
| 93 | // When buffer overflows 'n' columns, display one line and start over. |
| 94 | |
| 95 | if (cursor >= us.nScreenWidth-1) { |
| 96 | for (i = us.nScreenWidth-1; i > 2 && line[i] != ' '; i--) |
| 97 | ; |
| 98 | if (i <= 2) |
| 99 | i = us.nScreenWidth-1; |
| 100 | line[i] = 0; |
| 101 | PrintSz(line); PrintL(); |
| 102 | line[0] = line[1] = ' '; |
| 103 | for (j = 2; (line[j] = line[j+i-1]) != 0; j++) |
| 104 | ; |
| 105 | cursor -= (i-1); |
| 106 | } |
| 107 | ich++, cursor++; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 |
no test coverage detected