From 025c1dc9948fe99af4d7fe7bf12fe91caa793df8 Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Wed, 22 Aug 2001 17:41:10 +0000 Subject: [PATCH] See ChangeLog entry 2001-08-22 13:30 UTC-0400 David G. Holm --- harbour/source/rtl/console.c | 11 +++++++- harbour/tests/boxtst2.prg | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 harbour/tests/boxtst2.prg diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index 96f851f9c0..cfc502319a 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -82,6 +82,8 @@ static BOOL s_bInit = FALSE; static USHORT s_uiPRow; static USHORT s_uiPCol; +static SHORT s_originalMaxRow; +static SHORT s_originalMaxCol; static char s_szCrLf[ CRLF_BUFFER_LEN ]; static int s_iFilenoStdin; static int s_iFilenoStdout; @@ -129,7 +131,8 @@ void hb_conInit( void ) s_bInit = TRUE; hb_gtInit( s_iFilenoStdin, s_iFilenoStdout, s_iFilenoStderr ); - + s_originalMaxRow = hb_gtMaxRow(); /* Save the original */ + s_originalMaxCol = hb_gtMaxCol(); /* screen size */ hb_setkeyInit(); /* April White, May 6, 2000 */ } @@ -137,6 +140,12 @@ void hb_conRelease( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_conRelease()")); + if( s_originalMaxRow != hb_gtMaxRow() || s_originalMaxCol != hb_gtMaxCol() ) + { + /* If the program changed the screen size, restore the original */ + hb_gtSetMode( s_originalMaxRow + 1, s_originalMaxCol + 1 ); + } + hb_fsSetDevMode( s_iFilenoStdout, FD_TEXT ); hb_fsSetDevMode( s_iFilenoStderr, FD_TEXT ); diff --git a/harbour/tests/boxtst2.prg b/harbour/tests/boxtst2.prg new file mode 100644 index 0000000000..eadeb81aab --- /dev/null +++ b/harbour/tests/boxtst2.prg @@ -0,0 +1,53 @@ +/* + * $Id$ + */ + +// Test program for box and line drawing functions. +/* Harbour Project source code + http://www.Harbour-Project.org/ + Donated to the public domain on 2001-08-22 by David G. Holm +*/ + +#include "box.ch" + +function Main() +local max_row, max_col, boxColor := "W+/B,N/BG", lineColor := "W+/R, N/BG" + + SetMode(50, 80) + clear screen + max_row := maxrow() + max_col := maxcol() + + // Draw filled boxes centered around the four screen corners. + DispBox(-10, -10, 10, 10, B_SINGLE + "X", boxColor) + DispBox(-10, max_col - 10, 10, max_col + 10, B_SINGLE + "X", boxColor) + DispBox(max_row - 10, -10, max_row + 10, 10, B_SINGLE + "X", boxColor) + DispBox(max_row - 10, max_col - 10, max_row + 10, max_col + 10, B_SINGLE + "X", boxColor) + + // Draw non-filled boxes around the filled boxes. + DispBox(-15, -15, 15, 15, 1, boxColor) + DispBox(-15, max_col - 15, 15, max_col + 15, 1, boxColor) + DispBox(max_row - 15, -15, max_row + 15, 15, 1, boxColor) + DispBox(max_row - 15, max_col - 15, max_row + 15, max_col + 15, 1, boxColor) + + // Draw a box in the center, then two boxes off screen. + + DispBox( 20, 20, 25, 60, 2, boxColor) + DispBox( -10, -10, -1, -1, 2, boxColor) + DispBox( max_row + 1, max_col + 1, max_row + 10, max_col + 10, 2, boxColor) + + // Draw horizontal lines from off-screen to on-screen, + // off-screen to off-screen, and on-screen to off-screen. + DispBox(1, -10, 1, 10, B_SINGLE, lineColor) + DispBox(2, -10, 2, max_col + 10, B_DOUBLE, lineColor) + DispBox(3, max_col - 10, 3, max_col + 10, B_SINGLE, lineColor) + + // Draw vertical lines from off-screen to on-screen, + // off-screen to off-screen, and on-screen to off-screen. + DispBox(-10, 1, 10, 1, B_SINGLE, lineColor) + DispBox(-10, 2, max_row + 10, 2, B_DOUBLE, lineColor) + DispBox(max_row - 10, 3, max_row + 10, 3, B_SINGLE, lineColor) + + inkey(5) + +return nil \ No newline at end of file