diff options
Diffstat (limited to 'contrib/less/screen.c')
-rw-r--r-- | contrib/less/screen.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/contrib/less/screen.c b/contrib/less/screen.c index 48afdbf..6c4fc84 100644 --- a/contrib/less/screen.c +++ b/contrib/less/screen.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2005 Mark Nudelman + * Copyright (C) 1984-2007 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -163,6 +163,7 @@ static char *sc_home, /* Cursor home */ *sc_addline, /* Add line, scroll down following lines */ *sc_lower_left, /* Cursor to last line, first column */ + *sc_return, /* Cursor to beginning of current line */ *sc_move, /* General cursor positioning */ *sc_clear, /* Clear screen */ *sc_eol_clear, /* Clear to end of line */ @@ -232,6 +233,7 @@ extern int wscroll; extern int screen_trashed; extern int tty; extern int top_scroll; +extern int oldbot; #if HILITE_SEARCH extern int hilite_search; #endif @@ -1127,7 +1129,7 @@ get_term() if ((term = lgetenv("TERM")) == NULL) term = DEFAULT_TERM; hardcopy = 0; - if (tgetent(termbuf, term) <= 0) + if (tgetent(termbuf, term) != TGETENT_OK) hardcopy = 1; if (ltgetflag("hc")) hardcopy = 1; @@ -1283,6 +1285,13 @@ get_term() sc_lower_left = cheaper(t1, t2, "\r"); /* + * Get carriage return string. + */ + sc_return = ltgetstr("cr", &sp); + if (sc_return == NULL) + sc_return = "\r"; + + /* * Choose between using "al" or "sr" ("add line" or "scroll reverse") * to add a line at the top of the screen. */ @@ -1801,6 +1810,33 @@ lower_left() } /* + * Move cursor to left position of current line. + */ + public void +line_left() +{ +#if !MSDOS_COMPILER + tputs(sc_return, 1, putchr); +#else + int row; + flush(); +#if MSDOS_COMPILER==WIN32C + { + CONSOLE_SCREEN_BUFFER_INFO scr; + GetConsoleScreenBufferInfo(con_out, &scr); + row = scr.dwCursorPosition.Y - scr.srWindow.Top + 1; + } +#else + { + struct rccoord tpos = _gettextposition(); + row = tpos.row; + } +#endif + _settextposition(row, 1); +#endif +} + +/* * Check if the console size has changed and reset internals * (in lieu of SIGWINCH for WIN32). */ @@ -2108,7 +2144,11 @@ clear_bot() * the mode while we do the clear. Some terminals fill the * cleared area with the current attribute. */ - lower_left(); + if (oldbot) + lower_left(); + else + line_left(); + if (attrmode == AT_NORMAL) clear_eol_bot(); else @@ -2185,7 +2225,10 @@ at_exit() at_switch(attr) int attr; { - if (apply_at_specials(attr) != attrmode) + int new_attrmode = apply_at_specials(attr); + int ignore_modes = AT_ANSI; + + if ((new_attrmode & ~ignore_modes) != (attrmode & ~ignore_modes)) { at_exit(); at_enter(attr); |