*** empty log message ***

This commit is contained in:
Paul Tucker
1999-08-11 19:31:52 +00:00
parent 4f6c83bb64
commit 7ec045931a
7 changed files with 238 additions and 190 deletions

View File

@@ -1,3 +1,37 @@
19990811-14:30 EDT Paul Tucker <ptucker@sympatico.ca>
* source/rtl/console.c
* set binary mode on stanard files before intializing gt system.
* HB_SCROLL - changed to only call hb_max_row and col once each.
* source/rtl/gtapi.c
* hb_gtInit()
+ add call to hb_gtMaxRow and Col to initialize statics properly
- remove calls to setmode, setpos and setcursor
* some reformatting
* source/rtl/gt/gtwin.c
* simplified hb_gtDone
* modified code that returns maxrow and col to take into account
a window that is larger than the display region. Now the system
will use a screen size of 25x40 or the visible window, whichever
is greater. Comments?
NOTE: if you resize the window after initialization, Dispbegin/end
may cause the screen to jump around a bit - this will be corrected.
Also, if you resize the window while a savescreen is in effect,
the resulting restore screen will be unpleasant -this is being
reviewed.
* simplified hb_gt_DrawShadow
+ static hb_gt_SetScreenBuffer()
* dispbegin/end support routine
! changed hb_gt_SetMode to return BOOL
* include/gtapi.h source/rtl/gtdos.c
! changed hb_gt_SetMode to return BOOL
* source/rtl/gtos2.c (Chen Kedem <niki@actcom.co.il>)
! changed hb_gt_SetMode to return BOOL
+ hb_gt_IsColor()
+ hb_gt_SetAttribute()
+ hb_gt_DrawShadow()
* source/rt/gt/gt_tpl.c
* changed a comment
19990811-11:35 EDT David G. Holm <dholm@jsd-llc.com>
* doc/gmake.txt
+ Added a new section under 'NOTES' discussing how to build only

View File

@@ -101,7 +101,7 @@ extern void hb_gt_SetAttribute( char cTop, char cLeft, char cBottom, char cRig
extern void hb_gt_DrawShadow( char cTop, char cLeft, char cBottom, char cRight, char attribute );
extern void hb_gt_DispBegin( void );
extern void hb_gt_DispEnd( void );
extern void hb_gt_SetMode( USHORT uiRows, USHORT uiCols );
extern BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols );
extern BOOL hb_gt_GetBlink(void);
extern void hb_gt_SetBlink(BOOL bBlink);

View File

@@ -161,13 +161,6 @@ void hb_consoleInitialize( void )
CrLf [1] = 0;
#endif
#ifdef HARBOUR_USE_GTAPI
hb_gtInit();
hb_gtGetPos( &dev_row, & dev_col);
#else
dev_row = 0;
dev_col = 0;
#endif
p_row = p_col = 0;
/* Some compilers open stdout and stderr in text mode, but
@@ -179,6 +172,14 @@ void hb_consoleInitialize( void )
_setmode( _fileno( stdout ), _O_BINARY );
_setmode( _fileno( stderr ), _O_BINARY );
#endif
#ifdef HARBOUR_USE_GTAPI
hb_gtInit();
hb_gtGetPos( &dev_row, & dev_col);
#else
dev_row = 0;
dev_col = 0;
#endif
}
WORD hb_max_row( void )
@@ -706,7 +707,7 @@ HARBOUR HB_SETPRC( void ) /* Sets the current printer row and column positions *
HARBOUR HB_SCROLL( void ) /* Scrolls a screen region (requires the GT API) */
{
int i_top = 0, i_left = 0, i_bottom = hb_max_row(), i_right = hb_max_col(),
int i_top = 0, i_left = 0,iMR, iMC, i_bottom = iMR=hb_max_row(), i_right = iMC = hb_max_col(),
v_scroll = 0, h_scroll = 0;
WORD top, left, bottom, right;
@@ -725,27 +726,27 @@ HARBOUR HB_SCROLL( void ) /* Scrolls a screen region (requires the GT API) */
/* Enforce limits of (0,0) to (MAXROW(),MAXCOL()) */
if( i_top < 0 ) top = 0;
else if( i_top > hb_max_row() ) top = hb_max_row ();
else if( i_top > iMR ) top = iMR;
else top = i_top;
if( i_left < 0 ) left = 0;
else if( i_left > hb_max_col() ) left = hb_max_col ();
else if( i_left > iMC ) left = iMC;
else left = i_left;
if( i_bottom < 0 ) bottom = 0;
else if( i_bottom > hb_max_row() ) bottom = hb_max_row ();
else if( i_bottom > iMR ) bottom = iMR;
else bottom = i_bottom;
if( i_right < 0 ) right = 0;
else if( i_right > hb_max_col() ) right = hb_max_col ();
else if( i_right > iMC ) right = iMC;
else right = i_right;
#ifdef HARBOUR_USE_GTAPI
hb_gtScroll( top, left, bottom, right, v_scroll, h_scroll );
#else
if( top == 0 && bottom == hb_max_row()
&& left == 0 && right == hb_max_col()
if( top == 0 && bottom == iMR
&& left == 0 && right == iMC
&& v_scroll == 0 && h_scroll == 0 )
{
WORD count;
dev_row = hb_max_row();
dev_row = iMR;
for( count = 0; count < dev_row ; count++ ) printf( "\n" );
dev_row = dev_col = 0;
}

View File

@@ -28,10 +28,10 @@
#include <conio.h>
#include <sys/farptr.h>
#else
#ifndef MK_FP
#define MK_FP(seg,off) \
((void FAR *)(((unsigned long)(seg) << 16)|(unsigned)(off)))
#endif
#ifndef MK_FP
#define MK_FP(seg,off) \
((void FAR *)(((unsigned long)(seg) << 16)|(unsigned)(off)))
#endif
#endif
static void hb_gt_xGetXY(char cRow, char cCol, char *attr, char *ch);
@@ -460,7 +460,6 @@ void hb_gt_DispBegin(void)
#ifndef __DJGPP__
if( hb_gtDispCount() == 1 )
{
long offset;
char FAR *ptr;
ULONG nSize;
@@ -493,9 +492,10 @@ void hb_gt_DispEnd(void)
#endif
}
void hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
{
uiRows=uiCols=0;
return 0;
}
void hb_gt_Replicate(char c, DWORD nLength)
@@ -534,6 +534,5 @@ void hb_gt_SetBlink( BOOL bBlink )
#else
int86(0x10, &regs, &regs);
#endif
return;
#endif
}

View File

@@ -35,8 +35,12 @@ void hb_gt_Done(void)
int hb_gt_IsColor(void)
{
/* TODO: How to detect this? */
return TRUE;
/* Chen Kedem <niki@actcom.co.il> */
VIOMODEINFO vi;
vi.cb = sizeof(VIOMODEINFO);
VioGetMode(&vi, 0);
return (vi.fbType); /* 0 = monochrom-compatible mode */
}
char hb_gt_GetScreenWidth(void)
@@ -231,17 +235,32 @@ void hb_gt_PutText(char cTop, char cLeft, char cBottom, char cRight, char *srce)
void hb_gt_SetAttribute( char cTop, char cLeft, char cBottom, char cRight, char attribute )
{
/* TODO: we want to take a screen that is say bright white on blue,
and change the attributes only for a section of the screen
to white on black.
/* Chen Kedem <niki@actcom.co.il> */
/*
TODO: work with DispBegin DispEnd
NOTE: type of attribute should be change from char to unsigned char to
allow the >127 attributes (sames goes for hb_gt_DrawShadow)
*/
USHORT width;
char y;
/*
assume top level check that coordinate are all valid and fall
within visible screen, else if width cannot be fit on current line
it is going to warp to the next line
*/
width = (USHORT) (cRight - cLeft + 1);
for (y = cTop; y <= cBottom; y++)
VioWrtNAttr( &attribute, width, y, (USHORT) cLeft, 0);
}
void hb_gt_DrawShadow( char cTop, char cLeft, char cBottom, char cRight, char attribute )
{
/* TODO: similar to above - either use gtwin.c as a template, or
leave it and I will extrapolate from above function.
*/
/* Chen Kedem <niki@actcom.co.il> */
hb_gt_SetAttribute( cBottom+1, cLeft+1, cBottom+1, cRight+1, attribute );
hb_gt_SetAttribute( cTop+1, cRight+1, cBottom+1, cRight+1, attribute );
}
void hb_gt_DispBegin(void)
@@ -258,18 +277,17 @@ void hb_gt_DispEnd(void)
/* TODO: here we flush the buffer, and restore normal screen writes */
}
void hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
{
int rc;
VIOMODEINFO vi;
VioGetMode(&vi, 0); /* fill structure with current settings */
vi.row = uiRows;
vi.col = uiCols;
rc = VioSetMode(&vi, 0); /* 0 = Ok, other = Fail */
/* return rc */ /* TODO: set a return value for this function */
return (BOOL)VioSetMode(&vi, 0); /* 0 = Ok, other = Fail */
}
void hb_gt_Replicate(char c, ULONG nLength)
void hb_gt_Replicate(char c, DWORD nLength)
{
/* TODO: this will write character c nlength times to the screen.
Note that it is not used yet

View File

@@ -29,14 +29,18 @@ typedef WORD far *LPWORD;
#endif
#endif /* __GNUC__ */
static BOOL hb_gt_SetScreenBuffer( HANDLE HNew, HANDLE HOld );
static HANDLE HInput = INVALID_HANDLE_VALUE;
static HANDLE HOutput = INVALID_HANDLE_VALUE;
static HANDLE HStealth = INVALID_HANDLE_VALUE; /* DispBegin buffer */
static HANDLE HOriginal;
static HANDLE HStealth = INVALID_HANDLE_VALUE; /* DispBegin buffer */
static HANDLE HOriginal; /* used to restore before quit */
static HANDLE HCursor; /* When DispBegin is in effect, all cursor related
functions must refer to the original handle!
functions must refer to the active handle!
Otherwise turds are left on the screen when
running in a window
running in a window. This handle will always
refer to the currently _active_ buffer which could
be different than the one being written to.
*/
#define HB_LOG 0
@@ -63,59 +67,28 @@ void hb_gt_Init(void)
void hb_gt_Done(void)
{
/* because the current screen may not be the one that was active
when the app started, we need to restore that screen and update
it with the current image before quiting.
*/
if( HOutput != HOriginal )
{
COORD coDest = {0, 0};
COORD coBuf; /* the size of the buffer to read into */
CHAR_INFO *pCharInfo; /* buffer to store info from ReadConsoleOutput */
SMALL_RECT srWin; /* source rectangle to read from */
CONSOLE_SCREEN_BUFFER_INFO csbi;
CONSOLE_CURSOR_INFO cci;
srWin.Top = srWin.Left = 0;
srWin.Bottom = (coBuf.Y = hb_gt_GetScreenHeight()) -1;
srWin.Right = (coBuf.X = hb_gt_GetScreenWidth()) -1;
/* allocate a buffer for the screen rectangle */
pCharInfo = (CHAR_INFO *)hb_xgrab(coBuf.Y * coBuf.X * sizeof(CHAR_INFO));
/* read the screen rectangle into the buffer */
ReadConsoleOutput(HOutput, /* current screen handle */
pCharInfo, /* transfer area */
coBuf, /* size of destination buffer */
coDest, /* upper-left cell to write data to */
&srWin); /* screen buffer rectangle to read from */
GetConsoleCursorInfo(HCursor, &cci);
GetConsoleScreenBufferInfo(HOutput, &csbi);
HOutput = HOriginal;
SetConsoleScreenBufferSize(HOutput, coBuf);
SetConsoleCursorPosition(HOutput, csbi.dwCursorPosition);
WriteConsoleOutput(HOutput, /* output handle */
pCharInfo, /* data to write */
coBuf, /* col/row size of source buffer */
coDest, /* upper-left cell to write data from in src */
&srWin); /* screen buffer rect to write data to */
hb_xfree(pCharInfo);
/* ptucker */
/* because the current screen may not be the one that was active
when the app started, we need to restore that screen and update
it with the current image before quitting.
*/
/* easy fix ;-) */
hb_gtDispBegin(); /* must use these versions ! */
hb_gtDispEnd();
SetConsoleActiveScreenBuffer(HOutput);
SetConsoleCursorInfo(HOutput, &cci);
}
CloseHandle(HInput);
HInput = INVALID_HANDLE_VALUE;
CloseHandle(HOutput);
HOutput = INVALID_HANDLE_VALUE;
CloseHandle(HStealth);
HStealth = INVALID_HANDLE_VALUE;
CloseHandle(HOriginal);
HOriginal = INVALID_HANDLE_VALUE;
if( HStealth != INVALID_HANDLE_VALUE )
{
CloseHandle(HStealth);
HStealth = INVALID_HANDLE_VALUE;
}
LOG("Ending");
}
@@ -131,7 +104,8 @@ char hb_gt_GetScreenWidth(void)
LOG("GetScreenWidth");
GetConsoleScreenBufferInfo(HOutput, &csbi);
return (char)csbi.dwMaximumWindowSize.X;
/* return (char)csbi.dwMaximumWindowSize.X; */
return (char)max(csbi.srWindow.Right - csbi.srWindow.Left +1,40);
}
char hb_gt_GetScreenHeight(void)
@@ -140,7 +114,8 @@ char hb_gt_GetScreenHeight(void)
LOG("GetScreenHeight");
GetConsoleScreenBufferInfo(HOutput, &csbi);
return (char)csbi.dwMaximumWindowSize.Y;
/* return (char)csbi.dwMaximumWindowSize.Y; */
return (char)max(csbi.srWindow.Bottom - csbi.srWindow.Top +1,25);
}
void hb_gt_SetPos(char cRow, char cCol)
@@ -341,7 +316,7 @@ void hb_gt_DrawShadow( char cTop, char cLeft, char cBottom, char cRight, char at
{
/* ptucker */
DWORD len, y, width;
DWORD len, width;
COORD coord;
width = (cRight - cLeft + 1);
@@ -349,13 +324,7 @@ void hb_gt_DrawShadow( char cTop, char cLeft, char cBottom, char cRight, char at
coord.Y = (DWORD) (cBottom);
FillConsoleOutputAttribute(HOutput, (WORD)((unsigned char)attribute)&0xff, width, coord, &len);
coord.X = (DWORD) (cRight);
for( y=cTop;y<=cBottom;y++)
{
coord.Y = y;
FillConsoleOutputAttribute(HOutput, (WORD)((unsigned char)attribute)&0xff, 1, coord, &len);
}
hb_gt_SetAttribute( cTop, cRight, cBottom, cRight, attribute );
}
@@ -392,7 +361,7 @@ void hb_gt_Scroll( char cTop, char cLeft, char cBottom, char cRight, char attrib
memcpy( &Clip, &Source, sizeof(Clip) );
if( (horiz | vert) == 0 )
if( (horiz | vert) == 0 ) /* both zero? */
{
Target.Y = cBottom+1; /* set outside the clipping region */
Target.X = cRight+1;
@@ -442,10 +411,11 @@ void hb_gt_DispBegin(void)
CONSOLE_TEXTMODE_BUFFER, /* Type of buffer */
NULL); /* reserved */
SetConsoleScreenBufferSize(HStealth, coBuf);
hb_gt_SetScreenBuffer( HStealth, HOriginal );
}
HOutput = HStealth;
hb_gt_SetScreenBuffer( HStealth, HOutput );
HOutput = HStealth;
WriteConsoleOutput(HOutput, /* output handle */
pCharInfo, /* data to write */
coBuf, /* col/row size of source buffer */
@@ -472,7 +442,28 @@ void hb_gt_DispEnd(void)
}
}
void hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
static BOOL hb_gt_SetScreenBuffer( HANDLE HNew, HANDLE HOld )
{
/* ptucker */
/* set a new buffer to have the same characteristics as an existing buffer */
CONSOLE_SCREEN_BUFFER_INFO csbi;
SMALL_RECT srWin;
GetConsoleScreenBufferInfo(HOld, &csbi);
/* new console window size and scroll position */
srWin.Top = srWin.Left = 0;
srWin.Bottom = csbi.dwSize.Y - 1;
srWin.Right = csbi.dwSize.X - 1;
SetConsoleScreenBufferSize(HNew, csbi.dwSize);
SetConsoleWindowInfo(HNew, TRUE, &srWin);
return 0;
}
BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
{
/* ptucker */
CONSOLE_SCREEN_BUFFER_INFO csbi;
@@ -503,6 +494,7 @@ void hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
SetConsoleScreenBufferSize(HOutput, coBuf);
SetConsoleWindowInfo(HOutput, TRUE, &srWin);
}
return 0;
}
void hb_gt_Replicate(char c, DWORD nLength)
@@ -512,7 +504,7 @@ void hb_gt_Replicate(char c, DWORD nLength)
COORD coBuf = {0,0};
DWORD nWritten;
/* later... */
/* TODO: later... */
FillConsoleOutputCharacter(
HOutput, /* handle to screen buffer */
c, /* character to write */
@@ -530,5 +522,5 @@ BOOL hb_gt_GetBlink()
void hb_gt_SetBlink( BOOL bBlink )
{
bBlink = FALSE;
}

View File

@@ -6,6 +6,7 @@
* GTAPI.C: Generic Terminal for Harbour
*
* Latest mods:
* 1.56 19990811 ptucker Corrected initial MaxRow/col
* 1.53 19990807 ptucker Modified Dispbegin/end support
* 1.47 19990802 ptucker DispBegin/End and SetMode for gtWin
* 1.46 19990801 ptucker simplified hb_gtScroll if gtWin
@@ -67,8 +68,8 @@ static USHORT s_uiCurrentRow = 0;
static USHORT s_uiCurrentCol = 0;
static USHORT s_uiDispCount = 0;
static USHORT s_uiColorIndex = 0;
static USHORT s_uiMaxCol=80;
static USHORT s_uiMaxRow=24;
static USHORT s_uiMaxCol;
static USHORT s_uiMaxRow;
int *_Color; /* masks: 0x0007 Foreground
0x0070 Background
@@ -88,9 +89,8 @@ void hb_gtInit(void)
_ColorCount = 5;
hb_gt_Init();
hb_gtSetColorStr( hb_set.HB_SET_COLOR );
hb_gtSetMode( hb_gtMaxRow()+1, hb_gtMaxCol()+1 );
hb_gtSetPos( hb_gt_Row(), hb_gt_Col() );
hb_gtSetCursor(1);
hb_gtMaxRow();
hb_gtMaxCol();
}
void hb_gtExit(void)
@@ -247,6 +247,68 @@ int hb_gtDispEnd(void)
return(0);
}
int hb_gtGetColorStr(char * fpColorString)
{
/* ptucker */
char *sColors;
int i,j=0,k = 0, nColor;
sColors = (char *)hb_xgrab( _ColorCount * 8 + 1 ); /* max possible */
for( i=0; i<_ColorCount; i++ )
{
j = 0;
nColor = _Color[i] & 7;
do
{
if( ( _Color[i] & (j ? 0x8000 : 0x800)) != 0 )
sColors[k++] = 'U';
else
{
if( nColor == 7 )
sColors[k++] = 'W';
else
{
if( nColor == 0 )
sColors[k++] = 'N';
else
{
if( ( nColor & 1 ) != 0 )
sColors[k++] = 'B';
if( ( nColor & 2 ) != 0 )
sColors[k++] = 'G';
if( ( nColor & 4 ) != 0 )
sColors[k++] = 'R';
}
}
}
if( j == 0 )
{
if( ( _Color[i] & 8 ) != 0 )
sColors[k++] = '+';
sColors[k++] = '/';
}
else
if( ( _Color[i] & 128 ) != 0 )
sColors[k++] = '*';
nColor = (_Color[i] >> 4) & 7;
}
while( ++j < 2 );
if( i+1 < _ColorCount )
sColors[k++] = ',';
}
sColors[k++] = '\0';
strcpy( fpColorString, sColors );
hb_xfree( sColors );
return(0);
}
int hb_gtSetColorStr(char * fpColorString)
{
/* ptucker */
@@ -394,68 +456,6 @@ int hb_gtSetColorStr(char * fpColorString)
return(0);
}
int hb_gtGetColorStr(char * fpColorString)
{
/* ptucker */
char *sColors;
int i,j=0,k = 0, nColor;
sColors = (char *)hb_xgrab( _ColorCount * 8 + 1 ); /* max possible */
for( i=0; i<_ColorCount; i++ )
{
j = 0;
nColor = _Color[i] & 7;
do
{
if( ( _Color[i] & (j ? 0x8000 : 0x800)) != 0 )
sColors[k++] = 'U';
else
{
if( nColor == 7 )
sColors[k++] = 'W';
else
{
if( nColor == 0 )
sColors[k++] = 'N';
else
{
if( ( nColor & 1 ) != 0 )
sColors[k++] = 'B';
if( ( nColor & 2 ) != 0 )
sColors[k++] = 'G';
if( ( nColor & 4 ) != 0 )
sColors[k++] = 'R';
}
}
}
if( j == 0 )
{
if( ( _Color[i] & 8 ) != 0 )
sColors[k++] = '+';
sColors[k++] = '/';
}
else
if( ( _Color[i] & 128 ) != 0 )
sColors[k++] = '*';
nColor = (_Color[i] >> 4) & 7;
}
while( ++j < 2 );
if( i+1 < _ColorCount )
sColors[k++] = ',';
}
sColors[k++] = '\0';
strcpy( fpColorString, sColors );
hb_xfree( sColors );
return(0);
}
int hb_gtGetCursor(USHORT * uipCursorShape)
{
int i=hb_gt_GetCursorStyle();
@@ -473,10 +473,31 @@ int hb_gtGetCursor(USHORT * uipCursorShape)
return(rc);
}
int hb_gtSetCursor(USHORT uiCursorShape)
{
hb_gt_SetCursorStyle(uiCursorShape);
return(0);
}
int hb_gtGetPos(USHORT * uipRow, USHORT * uipCol)
{
*uipRow = s_uiCurrentRow;
*uipCol = s_uiCurrentCol;
*uipRow = s_uiCurrentRow = hb_gt_Row();
*uipCol = s_uiCurrentCol = hb_gt_Col();
return(0);
}
int hb_gtSetPos(USHORT uiRow, USHORT uiCol)
{
/* TODO: in this situation Clipper just turns off the cursor */
/* any further writes would be accounted for by clipping */
if(uiRow > s_uiMaxRow || uiCol > s_uiMaxCol)
return(1);
s_uiCurrentRow = uiRow;
s_uiCurrentCol = uiCol;
hb_gt_SetPos( uiRow, uiCol );
return(0);
}
@@ -576,12 +597,6 @@ int hb_gtSetBlink(BOOL bBlink)
return(0);
}
int hb_gtSetCursor(USHORT uiCursorShape)
{
hb_gt_SetCursorStyle(uiCursorShape);
return(0);
}
int hb_gtSetMode(USHORT uiRows, USHORT uiCols)
{
/* ptucker */
@@ -591,23 +606,12 @@ int hb_gtSetMode(USHORT uiRows, USHORT uiCols)
return(0);
}
int hb_gtSetPos(USHORT uiRow, USHORT uiCol)
{
/* TODO: in this situation Clipper just turns off the cursor */
/* any further writes would be accounted for by clipping */
if(uiRow > s_uiMaxRow || uiCol > s_uiMaxCol)
return(1);
s_uiCurrentRow = uiRow;
s_uiCurrentCol = uiCol;
hb_gt_SetPos( uiRow, uiCol );
return(0);
}
int hb_gtSetSnowFlag(BOOL bNoSnow)
{
/* COMMENT: This is a compatibility function.
If you're running on a CGA and snow is a problem
speak up!
*/
HB_SYMBOL_UNUSED( bNoSnow );
return(0);
}