diff options
Diffstat (limited to 'more.c')
-rw-r--r-- | more.c | 27 |
1 files changed, 22 insertions, 5 deletions
@@ -57,6 +57,7 @@ struct more_file { static int more_clear = 0; static int more_fastexit = 0; +static int more_backspace = 1; static WINDOW *more_win = NULL; static WINDOW *more_status = NULL; @@ -89,14 +90,14 @@ static ssize_t more_getline(struct more_file *mf, size_t lineno) return -1; } + printf("%s\r", mf->buf); + if (mf->nlines > 1) { mf->bytepos[mf->nlines - 1] = mf->bytepos[mf->nlines - 2] + strlen(mf->buf); } else { mf->bytepos[0] = 0; } - printf("%s\r", mf->buf); - if (mf->backing != mf->f) { fgetpos(mf->backing, &(mf->tlines[mf->nlines - 1])); fputs(mf->buf, mf->backing); @@ -162,10 +163,28 @@ static int more_printline(char *s) scrollok(more_win, FALSE); for (size_t i = 0; s[i] != '\0'; i++) { + int attr = 0; + if (more_backspace && s[i + 1] == '\b') { + if (s[i + 2] == '_') { + attr = A_UNDERLINE; + } else if (s[i + 2] == s[i]) { + attr = A_BOLD; + } else { + i++; + continue; + } + } + if (attr) { + wattron(more_win, attr); + } waddch(more_win, s[i]); if (i % COLS == 0) { ret++; } + if (attr) { + wattroff(more_win, attr); + i += 2; + } } scrollok(more_win, TRUE); @@ -698,7 +717,6 @@ int main(int argc, char *argv[]) int ignorecase = 0; int compressempty = 0; - int backspace = 1; adjust_args(&argc, &argv); @@ -722,7 +740,7 @@ int main(int argc, char *argv[]) break; case 'u': - backspace = 0; + more_backspace = 0; break; case 'n': @@ -797,7 +815,6 @@ int main(int argc, char *argv[]) } while (argv[optind++]); (void)ignorecase; - (void)backspace; return more(head); } |