diff options
Diffstat (limited to 'contrib/less/screen.c')
-rw-r--r-- | contrib/less/screen.c | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/contrib/less/screen.c b/contrib/less/screen.c index 03960c7..399ffc3 100644 --- a/contrib/less/screen.c +++ b/contrib/less/screen.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * 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. @@ -164,6 +164,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 */ @@ -228,13 +229,14 @@ extern int no_back_scroll; extern int swindow; extern int no_init; extern int quit_at_eof; -extern int more_mode; +extern int less_is_more; extern int no_keypad; extern int sigs; 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 @@ -1130,7 +1132,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; @@ -1196,7 +1198,7 @@ get_term() * that switch to/from an alternate screen, and we're in quit_at_eof * (eg, more(1)). */ - if (!quit_at_eof && !more_mode) { + if (!quit_at_eof && !less_is_more) { sc_init = ltgetstr("ti", &sp); sc_deinit = ltgetstr("te", &sp); } @@ -1294,6 +1296,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. */ @@ -1812,6 +1821,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). */ @@ -2119,7 +2155,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 @@ -2196,7 +2236,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); |