Fix curses bug: garbled output in nl mode.

Use nonl mode in sl, as more efficient.
This commit is contained in:
Serge Vakulenko
2015-09-13 23:47:32 -07:00
parent 7a8eff3fa3
commit 218466583d
3 changed files with 9 additions and 8 deletions

View File

@@ -90,6 +90,7 @@ int main(int argc, char *argv[])
initscr(); initscr();
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
noecho(); noecho();
nonl();
leaveok(stdscr, TRUE); leaveok(stdscr, TRUE);
scrollok(stdscr, FALSE); scrollok(stdscr, FALSE);

View File

@@ -160,7 +160,7 @@ plod(cnt)
* If we will later need a \n which will turn into a \r\n by * If we will later need a \n which will turn into a \r\n by
* the system or the terminal, then don't bother to try to \r. * the system or the terminal, then don't bother to try to \r.
*/ */
if ((NONL || !_pfast) && outline < destline) if (!_pfast && outline < destline)
goto dontcr; goto dontcr;
/* /*
* If the terminal will do a \r\n and there isn't room for it, * If the terminal will do a \r\n and there isn't room for it,
@@ -195,12 +195,13 @@ dontcr:
outline++; outline++;
if (NL) if (NL)
tputs(NL, 0, plodput); tputs(NL, 0, plodput);
else else {
plodput('\n'); plodput('\n');
if (!_pfast)
outcol = 0;
}
if (plodcnt < 0) if (plodcnt < 0)
goto out; goto out;
if (NONL || _pfast == 0)
outcol = 0;
} }
if (BT) if (BT)
k = strlen(BT); k = strlen(BT);
@@ -271,7 +272,7 @@ dontcr:
} }
else else
nondes: nondes:
if (ND) if (ND)
tputs(ND, 0, plodput); tputs(ND, 0, plodput);
else else
plodput(' '); plodput(' ');

View File

@@ -52,6 +52,7 @@ gettmode()
_res_flg = _tty.sg_flags; _res_flg = _tty.sg_flags;
GT = ((_tty.sg_flags & XTABS) == 0); GT = ((_tty.sg_flags & XTABS) == 0);
NONL = ((_tty.sg_flags & CRMOD) == 0); NONL = ((_tty.sg_flags & CRMOD) == 0);
_pfast = NONL;
_tty.sg_flags &= ~XTABS; _tty.sg_flags &= ~XTABS;
ioctl(_tty_ch, TIOCSETP, &_tty); ioctl(_tty_ch, TIOCSETP, &_tty);
# ifdef DEBUG # ifdef DEBUG
@@ -59,8 +60,6 @@ gettmode()
fprintf(outf, "GETTMODE: NONL = %s\n", NONL ? "TRUE" : "FALSE"); fprintf(outf, "GETTMODE: NONL = %s\n", NONL ? "TRUE" : "FALSE");
fprintf(outf, "GETTMODE: ospeed = %d\n", ospeed); fprintf(outf, "GETTMODE: ospeed = %d\n", ospeed);
# endif # endif
/* Use nonl mode by default. */
nonl();
} }
/* /*