From 563ab3efeb5af69e1cc8fae23471af70d1ed44a2 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Sat, 5 May 2018 13:34:13 +1000 Subject: [PATCH] Use current screen size rather than original terminal size in term_clear_screen() Also renames the function term_clrscr() to term_clear_screen() and remove the term_clear_screen() macro. --- include/ircterm.h | 3 +-- source/term.c | 13 +++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/ircterm.h b/include/ircterm.h index 08127d1..b93764f 100644 --- a/include/ircterm.h +++ b/include/ircterm.h @@ -698,7 +698,6 @@ int tputs_x(char *); #define term_cursor_left() term_left(1) #define term_cursor_right() term_right(1) #define term_clear_to_eol() term_clreol() -#define term_clear_screen() term_clrscr() #ifdef __EMX__ extern int vio_screen; @@ -720,7 +719,7 @@ SIGNAL_HANDLER(term_cont); void term_right (int); void term_left (int); void term_clreol (void); - void term_clrscr (void); + void term_clear_screen (void); void term_gotoxy (int, int); void term_reset (void); int term_eight_bit (void); diff --git a/source/term.c b/source/term.c index d11c683..0337cdb 100644 --- a/source/term.c +++ b/source/term.c @@ -1351,15 +1351,16 @@ void term_gotoxy (int col, int row) } /* A no-brainer. Clear the screen. */ -void term_clrscr (void) +void term_clear_screen(void) { #if defined(__EMX__) && !defined(__EMXX__) && !defined(GUI) VioScrollUp(0, 0, -1, -1, -1, &default_pair, vio_screen); #elif defined(GUI) gui_clrscr(); #else - int i; + /* This is called from scr-bx with output_screen == NULL */ + const long li = output_screen ? output_screen->li : current_term->li; /* We have a specific cap for clearing the screen */ if (current_term->TI_clear) @@ -1379,27 +1380,27 @@ void term_clrscr (void) /* We can also clear by deleteing lines ... */ else if (current_term->TI_dl) { - tputs_x(tparm1(current_term->TI_dl, current_term->TI_lines)); + tputs_x(tparm1(current_term->TI_dl, li)); return; } /* ... in this case one line at a time */ else if (current_term->TI_dl1) { - for (i = 0; i < current_term->TI_lines; i++) + for (i = 0; i < li; i++) tputs_x(current_term->TI_dl1); return; } /* As a last resort we can insert lines ... */ else if (current_term->TI_il) { - tputs_x(tparm1(current_term->TI_il, current_term->TI_lines)); + tputs_x(tparm1(current_term->TI_il, li)); term_gotoxy (0, 0); return; } /* ... one line at a time */ else if (current_term->TI_il1) { - for (i = 0; i < current_term->TI_lines; i++) + for (i = 0; i < li; i++) tputs_x(current_term->TI_il1); term_gotoxy (0, 0); }