gtwin.c | |||
Type | Function | Source | Line |
---|---|---|---|
STATIC VOID | hb_gt_win_xSetCursorPos( void )
static void hb_gt_win_xSetCursorPos( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_xSetCursorPos()")); s_csbi.dwCursorPosition.Y = s_sCurRow; s_csbi.dwCursorPosition.X = s_sCurCol; SetConsoleCursorPosition( s_HOutput, s_csbi.dwCursorPosition ); } | gtwin.c | 408 |
STATIC VOID | hb_gt_win_xSetCursorStyle( void )
static void hb_gt_win_xSetCursorStyle( void ) { CONSOLE_CURSOR_INFO cci; HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_xSetCursorStyle()")); switch( s_usCursorStyle ) { case SC_NONE: cci.bVisible = FALSE; cci.dwSize = 13; break; case SC_INSERT: cci.bVisible = TRUE; cci.dwSize = 50; break; case SC_SPECIAL1: cci.bVisible = TRUE; cci.dwSize = 99; break; case SC_SPECIAL2: cci.bVisible = TRUE; cci.dwSize = 66; /* In their infinite wisdom, MS doesn't support cursors that don't start at the bottom of the cell */ break; case SC_NORMAL: default: cci.bVisible = TRUE; cci.dwSize = 13; break; } s_usOldCurStyle = s_usCursorStyle; SetConsoleCursorInfo( s_HOutput, &cci ); } | gtwin.c | 419 |
STATIC VOID | hb_gt_win_xScreenUpdate( void )
static void hb_gt_win_xScreenUpdate( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_xScreenUpdate()")); if( s_pCharInfoScreen ) { if( s_uiDispCount == 0 && s_usUpdtTop <= s_usUpdtBottom ) { COORD coDest, coSize; SMALL_RECT srWin; coSize.Y = _GetScreenHeight(); coSize.X = _GetScreenWidth(); coDest.Y = s_usUpdtTop; coDest.X = s_usUpdtLeft; srWin.Top = ( SHORT ) s_usUpdtTop; srWin.Left = ( SHORT ) s_usUpdtLeft; srWin.Bottom = ( SHORT ) s_usUpdtBottom; srWin.Right = ( SHORT ) s_usUpdtRight; s_usUpdtTop = _GetScreenHeight(); s_usUpdtLeft = _GetScreenWidth(); s_usUpdtBottom = s_usUpdtRight = 0; WriteConsoleOutput( s_HOutput, /* output handle */ s_pCharInfoScreen, /* data to write */ coSize, /* col/row size of source buffer */ coDest, /* upper-left cell to write data from in src */ &srWin ); /* screen buffer rect to write data to */ } if( s_usOldCurStyle != s_usCursorStyle && ( s_uiDispCount == 0 || s_usCursorStyle == SC_NONE ) ) hb_gt_win_xSetCursorStyle(); if( s_usCursorStyle != SC_NONE && s_uiDispCount == 0 && ( s_csbi.dwCursorPosition.Y != s_sCurRow || s_csbi.dwCursorPosition.X != s_sCurCol ) ) hb_gt_win_xSetCursorPos(); } } | gtwin.c | 461 |
STATIC VOID | hb_gt_win_xUpdtSet( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight )
static void hb_gt_win_xUpdtSet( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_xUpdtSet(%hu, %hu, %hu, %hu)", usTop, usLeft, usBottom, usRight)); if( usTop < s_usUpdtTop ) s_usUpdtTop = usTop; if( usLeft < s_usUpdtLeft ) s_usUpdtLeft = usLeft; if( usBottom > s_usUpdtBottom ) s_usUpdtBottom = HB_MIN( usBottom, ( USHORT ) _GetScreenHeight() - 1 ); if( usRight > s_usUpdtRight ) s_usUpdtRight = HB_MIN( usRight, ( USHORT ) _GetScreenWidth() - 1 ); } | gtwin.c | 505 |
STATIC BOOL WINAPI | hb_gt_win_CtrlHandler( DWORD dwCtrlType )
static BOOL WINAPI hb_gt_win_CtrlHandler( DWORD dwCtrlType ) { BOOL bHandled; HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_CtrlHandler(%lu)", ( ULONG ) dwCtrlType)); switch( dwCtrlType ) { case CTRL_C_EVENT: bHandled = FALSE; break; case CTRL_CLOSE_EVENT: case CTRL_BREAK_EVENT: s_bBreak = TRUE; bHandled = TRUE; break; case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: default: #if 0 printf(" Event %ld ", dwCtrlType ); #endif bHandled = FALSE; } return bHandled; } | gtwin.c | 521 |
STATIC VOID | hb_gt_win_xGetScreenContents( PHB_GT pGT, SMALL_RECT * psrWin )
static void hb_gt_win_xGetScreenContents( PHB_GT pGT, SMALL_RECT * psrWin ) { int iRow, iCol, i; HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_xGetScreenContents(%p,%p)", pGT, psrWin)); for( iRow = psrWin->Top; iRow <= psrWin->Bottom; ++iRow ) { i = iRow * _GetScreenWidth() + psrWin->Left; for( iCol = psrWin->Left; iCol <= psrWin->Right; ++iCol ) { HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, ( BYTE ) s_pCharInfoScreen[i].Attributes, 0, s_charTransRev[ ( BYTE ) s_pCharInfoScreen[i].Char.AsciiChar ] ); ++i; } } HB_GTSELF_COLDAREA( pGT, psrWin->Top, psrWin->Left, psrWin->Bottom, psrWin->Right ); } | gtwin.c | 553 |
STATIC VOID | hb_gt_win_xInitScreenParam( PHB_GT pGT )
static void hb_gt_win_xInitScreenParam( PHB_GT pGT ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_xInitScreenParam(%p)", pGT)); if( GetConsoleScreenBufferInfo( s_HOutput, &s_csbi ) ) { COORD coDest; SMALL_RECT srWin; ULONG ulSize = ( ULONG ) _GetScreenWidth() * _GetScreenHeight() * sizeof( CHAR_INFO ); HB_GTSELF_RESIZE( pGT, _GetScreenHeight(), _GetScreenWidth() ); if( s_pCharInfoScreen == NULL || ulSize != s_ulScreenBuffSize ) { if( s_pCharInfoScreen ) hb_xfree( s_pCharInfoScreen ); s_ulScreenBuffSize = ulSize; s_pCharInfoScreen = ( CHAR_INFO * ) hb_xgrab( s_ulScreenBuffSize ); } s_sCurRow = s_csbi.dwCursorPosition.Y; s_sCurCol = s_csbi.dwCursorPosition.X; s_usUpdtTop = s_csbi.dwSize.Y; s_usUpdtLeft = s_csbi.dwSize.X; s_usUpdtBottom = s_usUpdtRight = 0; /* * Unfortunatelly Windows refuse to read to big area :-( * (I do not know why) so we cannot read the whole console * buffer { 0, 0, s_csbi.dwSize.Y - 1, s_csbi.dwSize.X - 1 } * because it reads nothing, [druzus] */ #if 0 srWin.Top = 0; srWin.Left = 0; srWin.Bottom = s_csbi.dwSize.Y - 1; srWin.Right = s_csbi.dwSize.X - 1; #else srWin.Top = s_csbi.srWindow.Top; srWin.Left = s_csbi.srWindow.Left; srWin.Bottom = s_csbi.srWindow.Bottom; srWin.Right = s_csbi.srWindow.Right; #endif coDest.Y = srWin.Top; coDest.X = srWin.Left; /* read the screen rectangle into the buffer */ if( ReadConsoleOutput( s_HOutput, /* screen handle */ s_pCharInfoScreen, /* transfer area */ s_csbi.dwSize, /* size of destination buffer */ coDest, /* upper-left cell to write data to */ &srWin ) ) /* screen buffer rectangle to read from */ { hb_gt_win_xGetScreenContents( pGT, &srWin ); } HB_GTSELF_SETPOS( pGT, s_sCurRow, s_sCurCol ); } else if( s_pCharInfoScreen ) { hb_xfree( s_pCharInfoScreen ); s_ulScreenBuffSize = 0; } } | gtwin.c | 575 |
STATIC VOID | hb_gt_win_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFilenoStdout, HB_FHANDLE hFilenoStderr )
static void hb_gt_win_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFilenoStdout, HB_FHANDLE hFilenoStderr ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_Init(%p,%p,%p,%p)", pGT, hFilenoStdin, hFilenoStdout, hFilenoStderr)); s_osv.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); GetVersionEx( &s_osv ); if( s_osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { s_dwAltGrBits = RIGHT_ALT_PRESSED; } else { s_dwAltGrBits = LEFT_CTRL_PRESSED | RIGHT_ALT_PRESSED; } /* stdin && stdout && stderr */ s_hStdIn = hFilenoStdin; s_hStdOut = hFilenoStdout; s_hStdErr = hFilenoStderr; s_bBreak = FALSE; s_cNumRead = 0; s_cNumIndex = 0; s_uiDispCount = 0; s_usOldCurStyle = s_usCursorStyle = SC_NORMAL; s_bSpecialKeyHandling = FALSE; s_bAltKeyHandling = TRUE; /* initialize code page translation */ HB_GTSELF_SETDISPCP( pGT, NULL, NULL, FALSE ); HB_GTSELF_SETKEYCP( pGT, NULL, NULL ); /* Add Ctrl+Break handler [vszakats] */ SetConsoleCtrlHandler( hb_gt_win_CtrlHandler, TRUE ); #ifndef HB_NO_ALLOC_CONSOLE /* * This is a hack for MSYS console. It does not support full screen output * so nothing can be seen on the screen and we have to close the MSYS * console to be able to allocate the MS-Windows one. * Unfortunatelly I do not know any method to detect the MSYS console * so I used this hack with checking OSTYPE environemnt variable. [druzus] */ { char * pszOsType; pszOsType = hb_getenv( "OSTYPE" ); if( pszOsType ) { if( strcmp( pszOsType, "msys" ) == 0 ) FreeConsole(); hb_xfree( pszOsType ); } } /* Try to allocate console if we haven't inherited any */ AllocConsole(); #endif if( ( s_HInput = GetStdHandle( STD_INPUT_HANDLE ) ) == INVALID_HANDLE_VALUE ) { #ifdef HB_NO_ALLOC_CONSOLE /* allocate console only when debugger is linked */ if( hb_dynsymFind( "__DBGENTRY" ) ) { AllocConsole(); /* It is a Windows app without a console, so we create one */ s_HInput = GetStdHandle( STD_INPUT_HANDLE ); } #endif if( s_HInput == INVALID_HANDLE_VALUE ) { hb_errInternal( 10001, "Can't allocate console", NULL, NULL ); } } HB_GTSUPER_INIT( pGT, hFilenoStdin, hFilenoStdout, hFilenoStderr ); s_HOutput = CreateFile( TEXT( "CONOUT$" ), /* filename */ GENERIC_READ | GENERIC_WRITE, /* Access flag */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share mode */ NULL, /* security attributes */ OPEN_EXISTING, /* create mode */ 0, 0 ); if( s_HOutput == INVALID_HANDLE_VALUE ) hb_errInternal( 10001, "Can't allocate console (output)", NULL, NULL ); s_HInput = CreateFile( TEXT( "CONIN$" ), /* filename */ GENERIC_READ | GENERIC_WRITE, /* Access flag */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share mode */ NULL, /* security attributes */ OPEN_EXISTING, /* create mode */ 0, 0 ); if( s_HInput == INVALID_HANDLE_VALUE ) hb_errInternal( 10001, "Can't allocate console (input)", NULL, NULL ); GetConsoleScreenBufferInfo( s_HOutput, &s_csbi ); /* save screen info to restore on exit */ memcpy( &s_origCsbi, &s_csbi, sizeof( s_csbi ) ); s_csbi.srWindow.Top = s_csbi.srWindow.Left = 0; s_csbi.srWindow.Right = HB_MIN( s_csbi.srWindow.Right, _GetScreenWidth()-1 ); s_csbi.srWindow.Bottom = HB_MIN( s_csbi.srWindow.Bottom, _GetScreenHeight()-1 ); SetConsoleWindowInfo( s_HOutput, TRUE, &s_csbi.srWindow ); SetConsoleScreenBufferSize( s_HOutput, s_csbi.dwSize ); hb_gt_win_xInitScreenParam( pGT ); GetConsoleMode( s_HOutput, &s_dwomode ); GetConsoleMode( s_HInput, &s_dwimode ); SetConsoleMode( s_HInput, b_MouseEnable ? ENABLE_MOUSE_INPUT : 0x0000 ); } | gtwin.c | 643 |
STATIC VOID | hb_gt_win_Exit( PHB_GT pGT )
static void hb_gt_win_Exit( PHB_GT pGT ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_Exit(%p)", pGT)); HB_GTSELF_REFRESH( pGT ); if( s_pCharInfoScreen ) { hb_xfree( s_pCharInfoScreen ); s_pCharInfoScreen = NULL; } if( s_HOutput != INVALID_HANDLE_VALUE ) { SetConsoleScreenBufferSize( s_HOutput, s_origCsbi.dwSize ); s_origCsbi.srWindow.Right -= s_origCsbi.srWindow.Left; s_origCsbi.srWindow.Bottom -= s_origCsbi.srWindow.Top; s_origCsbi.srWindow.Top = s_origCsbi.srWindow.Left = 0; SetConsoleWindowInfo( s_HOutput, TRUE, &s_origCsbi.srWindow ); CloseHandle( s_HOutput ); } /* Remove Ctrl+Break handler */ SetConsoleCtrlHandler( hb_gt_win_CtrlHandler, FALSE ); HB_GTSUPER_EXIT( pGT ); } | gtwin.c | 762 |
STATIC BOOL | hb_gt_win_SetMode( PHB_GT pGT, int iRows, int iCols )
static BOOL hb_gt_win_SetMode( PHB_GT pGT, int iRows, int iCols ) { BOOL fRet = FALSE; HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_SetMode(%p,%d,%d)", pGT, iRows, iCols)); if( s_HOutput != INVALID_HANDLE_VALUE && iRows > 0 && iCols > 0 ) { SMALL_RECT srWin; COORD coBuf; coBuf = GetLargestConsoleWindowSize( s_HOutput ); if( iRows > coBuf.Y ) iRows = coBuf.Y; else coBuf.Y = ( SHORT ) iRows; if( iCols > coBuf.X ) iCols = coBuf.X; else coBuf.X = ( SHORT ) iCols; /* new console window size and scroll position */ srWin.Top = srWin.Left = 0; srWin.Bottom = ( SHORT ) ( iRows - 1 ); srWin.Right = ( SHORT ) ( iCols - 1 ); /* if the current buffer is larger than what we want, resize the */ /* console window first, then the buffer */ if( ( DWORD ) _GetScreenWidth() * _GetScreenHeight() > ( DWORD ) iCols * iRows ) { if( SetConsoleWindowInfo( s_HOutput, TRUE, &srWin ) ) { SetConsoleScreenBufferSize( s_HOutput, coBuf ); fRet = TRUE; } } else { if( SetConsoleScreenBufferSize( s_HOutput, coBuf ) ) { SetConsoleWindowInfo( s_HOutput, TRUE, &srWin ); fRet = TRUE; } } if( fRet ) hb_gt_win_xInitScreenParam( pGT ); } return fRet; } | gtwin.c | 794 |
STATIC CONST CHAR * | hb_gt_win_Version( PHB_GT pGT, int iType )
static const char * hb_gt_win_Version( PHB_GT pGT, int iType ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_win_Version(%p,%d)", pGT, iType ) ); HB_SYMBOL_UNUSED( pGT ); if( iType == 0 ) return HB_GT_DRVNAME( HB_GT_NAME ); return "Harbour Terminal: Windows native console"; } | gtwin.c | 850 |
STATIC BOOL | hb_gt_win_PostExt( PHB_GT pGT )
static BOOL hb_gt_win_PostExt( PHB_GT pGT ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_PostExt(%p)", pGT)); HB_GTSUPER_POSTEXT( pGT ); if( s_pCharInfoScreen ) hb_gt_win_xInitScreenParam( pGT ); return TRUE; } | gtwin.c | 864 |
STATIC BOOL | hb_gt_win_Suspend( PHB_GT pGT )
static BOOL hb_gt_win_Suspend( PHB_GT pGT ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_Suspend(%p)", pGT)); HB_SYMBOL_UNUSED( pGT ); if( s_pCharInfoScreen ) { SetConsoleCtrlHandler( hb_gt_win_CtrlHandler, FALSE ); SetConsoleCtrlHandler( NULL, TRUE ); SetConsoleMode( s_HOutput, s_dwomode ); SetConsoleMode( s_HInput, s_dwimode ); } return TRUE; } | gtwin.c | 876 |
STATIC BOOL | hb_gt_win_Resume( PHB_GT pGT )
static BOOL hb_gt_win_Resume( PHB_GT pGT ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_Resume(%p)", pGT)); if( s_pCharInfoScreen ) { SetConsoleCtrlHandler( NULL, FALSE ); SetConsoleCtrlHandler( hb_gt_win_CtrlHandler, TRUE ); SetConsoleMode( s_HOutput, s_dwomode ); SetConsoleMode( s_HInput, b_MouseEnable ? ENABLE_MOUSE_INPUT : 0x0000 ); hb_gt_win_xInitScreenParam( pGT ); hb_gt_win_xSetCursorStyle(); } return TRUE; } | gtwin.c | 892 |
STATIC INT | Handle_Alt_Key( int * paltisdown, int * paltnum, unsigned short wKey, int ch )
static int Handle_Alt_Key( int * paltisdown, int * paltnum, unsigned short wKey, int ch ) { if( s_irInBuf[ s_cNumIndex ].Event.KeyEvent.bKeyDown ) { /* on Keydown, it better be the alt or a numpad key, or bail out. */ switch(wKey) { case 0x38: case 0x47: case 0x48: case 0x49: case 0x4b: case 0x4c: case 0x4d: case 0x4f: case 0x50: case 0x51: case 0x52: break; default: *paltisdown=0; break; } } else { /* Keypad handling is done during Key up */ unsigned short nm = 10; switch(wKey) { case 0x38: /* Alt key ... */ #if 0 printf( " the state %ld ",s_irInBuf[ s_cNumIndex ].Event.KeyEvent.dwControlKeyState ); #endif if( s_irInBuf[ s_cNumIndex ].Event.KeyEvent.dwControlKeyState & 0x04000000 ) /* ... has been released after a numpad entry */ { ch = *paltnum & 0xff; ++s_cNumIndex; } else /* ... has been released after no numpad entry */ { s_irInBuf[ s_cNumIndex ].Event.KeyEvent.bKeyDown = 1; } *paltisdown = *paltnum = 0; break; case 0x52: --nm; case 0x4f: --nm; case 0x50: --nm; case 0x51: --nm; case 0x4b: --nm; case 0x4c: --nm; case 0x4d: --nm; case 0x47: --nm; case 0x48: --nm; case 0x49: --nm; *paltnum = ((*paltnum * 10) & 0xff) + nm; break; default: *paltisdown = 0; break; } } return ch; } | gtwin.c | 910 |
STATIC INT | SpecialHandling( WORD * wChar, unsigned short wKey, int ch, BOOL lReverse )
static int SpecialHandling( WORD * wChar, unsigned short wKey, int ch, BOOL lReverse ) { if( lReverse ) { switch( wKey ) { case 2: /* 1 to 9 */ case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: ch = wKey + 31; break; case 11: /* 0 */ ch = 41; break; case 12: /* - */ ch = 95; break; case 13: /* = */ ch = 43; break; case 26: /* [ */ ch = 123; break; case 27: /* ] */ ch = 125; break; case 39: /* ; */ ch = 58; break; case 40: /* ' */ ch = 34; break; case 41: /* ` */ ch = 126; break; case 43: /* \ */ ch = 124; break; case 51: /* , */ ch = 60; break; case 52: /* . */ ch = 62; break; case 53: /* / */ ch = 63; break; default: break; } } else { switch( wKey ) { case 2: /* 1 to 9 */ case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: ch = *wChar = wKey + 47; break; case 11: /* 0 */ ch = *wChar = 48; break; case 12: /* - */ ch = 45; break; case 13: /* = */ ch = *wChar = 61; break; case 26: /* [ */ ch = *wChar = 91; break; case 27: /* ] */ ch = *wChar = 93; break; case 39: /* ; */ ch = *wChar = 59; break; case 40: /* ' */ ch = 39; break; case 41: /* ` */ ch = *wChar = 96; break; case 43: /* \ */ ch = *wChar = 92; break; case 51: /* , */ ch = *wChar = 44; break; case 52: /* . */ ch = *wChar = 46; break; case 53: /* / */ ch = 47; break; default: break; } } return ch; } | gtwin.c | 988 |
STATIC INT | hb_gt_win_ReadKey( PHB_GT pGT, int iEventMask )
static int hb_gt_win_ReadKey( PHB_GT pGT, int iEventMask ) { int ch = 0, extKey = -1; const ClipKeyCode *clipKey = NULL; HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_ReadKey(%p,%d)", pGT, iEventMask)); HB_SYMBOL_UNUSED( pGT ); /* First check for Ctrl+Break, which is handled by gt/gtwin.c */ if( s_bBreak ) { /* Reset the global Ctrl+Break flag */ s_bBreak = FALSE; ch = HB_BREAK_FLAG; /* Indicate that Ctrl+Break was pressed */ } /* Check for events only when the event buffer is exhausted. */ else if( s_wRepeated == 0 && s_cNumRead <= s_cNumIndex ) { /* Check for keyboard input */ s_cNumRead = 0; GetNumberOfConsoleInputEvents( s_HInput, &s_cNumRead ); if( s_cNumRead ) { /* Read keyboard input */ ReadConsoleInput( s_HInput, /* input buffer handle */ s_irInBuf, /* buffer to read into */ INPUT_BUFFER_LEN, /* size of read buffer */ &s_cNumRead); /* number of records read */ /* Set up to process the first input event */ s_cNumIndex = 0; if( s_irInBuf[ s_cNumIndex ].EventType == KEY_EVENT ) { unsigned short wKey = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.wVirtualScanCode; #if 0 if( s_irInBuf[ s_cNumIndex ].Event.KeyEvent.bKeyDown ) { printf("\n scan %ld key %ld char %ld state %ld alt %d %d %d %d %d", wKey, /* scan code */ s_irInBuf[ s_cNumIndex ].Event.KeyEvent.wVirtualKeyCode, /* key code */ s_irInBuf[ s_cNumIndex ].Event.KeyEvent.uChar.AsciiChar, /* char */ s_irInBuf[ s_cNumIndex ].Event.KeyEvent.dwControlKeyState, /* state */ s_altisdown, s_wRepeated, s_cNumRead, s_cNumIndex, (int) s_bAltKeyHandling); } #endif if( s_bAltKeyHandling ) { if( s_altisdown ) { ch = Handle_Alt_Key( &s_altisdown, &s_altnum, wKey, ch ); } else { if( wKey == 0x38 && s_irInBuf[ s_cNumIndex ].Event.KeyEvent.bKeyDown && ( s_irInBuf[ s_cNumIndex ].Event.KeyEvent.dwControlKeyState & NUMLOCK_ON ) ) { s_altisdown = 1; } } } } } } /* Only process one keyboard event at a time. */ if( s_wRepeated > 0 || s_cNumRead > s_cNumIndex ) { #if 0 printf( " event %ld ",s_irInBuf[ s_cNumIndex ].EventType ); #endif if( s_irInBuf[ s_cNumIndex ].EventType == KEY_EVENT ) { /* Only process key down events */ if( s_irInBuf[ s_cNumIndex ].Event.KeyEvent.bKeyDown ) { /* Save the keyboard state and ASCII,scan, key code */ WORD wKey = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.wVirtualScanCode; WORD wChar = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.wVirtualKeyCode; DWORD dwState= s_irInBuf[ s_cNumIndex ].Event.KeyEvent.dwControlKeyState; ch = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.uChar.AsciiChar; /* * Under Win9x, Upper row keys are affected by caps-lock * and should not be. There are 2 solutions - the first * is to enable the calling of SpecialHandling below - which * will only be activated under Win9x (Preferrably under user * control, since they know if their keyboard isn't working), or * just enable KeyB handling in config.sys, and do not enable the * following call. * 2004-11-26 Vicente Guerra * (With some clarification by Paul Tucker) * If making this fix the default under Win98, then it doesn't * work for non-US keyboards. (The default has now been changed) * I tried to replicate the problem under Win98SE (spanish), * but it works fine. I hope someone could tell me how the * problem appears, for try to fix it. * "Microsoft has confirmed this to be a bug in the Microsoft * products " Windows 95 & Windows 98 (According to MSDN) * */ if( s_bSpecialKeyHandling && ( dwState & CAPSLOCK_ON ) && s_osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { ch = SpecialHandling( &wChar, wKey, ch, (dwState & SHIFT_PRESSED) ); } if( s_wRepeated == 0 ) { s_wRepeated = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.wRepeatCount; } if( s_wRepeated > 0 ) /* Might not be redundant */ { s_wRepeated--; } #if 0 printf( "\n\nhb_gt_ReadKey(): dwState is %ld, wChar is %d, wKey is %d, ch is %d", dwState, wChar, wKey, ch ); #endif if( wChar == 8 ) /* VK_BACK */ { extKey = EXKEY_BS; } else if( wChar == 9 ) /* VK_TAB */ { extKey = EXKEY_TAB; } else if( wChar == 13 ) /* VK_RETURN */ { extKey = EXKEY_ENTER; } else if( wChar == 27 ) /* VK_ESCAPE */ { extKey = EXKEY_ESC; } else if( wChar == 33 ) /* VK_PRIOR */ { extKey = EXKEY_PGUP; } else if( wChar == 34 ) /* VK_NEXT */ { extKey = EXKEY_PGDN; } else if( wChar == 35 ) /* VK_END */ { extKey = EXKEY_END; } else if( wChar == 36 ) /* VK_HOME */ { extKey = EXKEY_HOME; } else if( wChar == 37 ) /* VK_LEFT */ { extKey = EXKEY_LEFT; } else if( wChar == 38 ) /* VK_UP */ { extKey = EXKEY_UP; } else if( wChar == 39 ) /* VK_RIGHT */ { extKey = EXKEY_RIGHT; } else if( wChar == 40 ) /* VK_DOWN */ { extKey = EXKEY_DOWN; } else if( wChar == 45 ) /* VK_INSERT */ { extKey = EXKEY_INS; } else if( wChar == 46 && (!(ch==46)) ) /* VK_DELETE */ { /* International keyboard under Win98 - when VirtualKey and Ascii char are both 46, then it's keypad del key, but numlock is on, so treat as '.' else DEL */ extKey = EXKEY_DEL; } else if( wChar == 191 && ch == 63 && ( dwState & ENHANCED_KEY )) { /* numpad '/' always */ /* This is the Win98 test */ ch = 47; } else if( wChar == 106 ) /* VK_MULTIPLY */ { extKey = EXKEY_KPASTERISK; } else if( wChar == 107 ) /* VK_ADD */ { extKey = EXKEY_KPPLUS; } else if( wChar == 109 ) /* VK_SUBTRACT */ { extKey = EXKEY_KPMINUS; } else if( wChar == 111 || /* VK_DIVIDE */ ( wChar == 191 && ( dwState & ENHANCED_KEY ))) { /* This should be for other than Win98 */ extKey = EXKEY_KPDIVIDE; } else if( wChar >= 112 && wChar <= 123 ) /* F1-F12 VK_F1-VK_F12 */ { extKey = wChar - 112; } else if( ch >= K_SPACE && ch <= K_CTRL_BS ) { clipKey = &stdKeyTab[ ch - K_SPACE ]; } else if( ch > 0 && ch < K_SPACE && ( dwState & ( LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED ) ) ) { clipKey = &stdKeyTab[ ch + '@' ]; } else if( ch < 0 ) /* international keys */ { ch += 256; } if( extKey > -1 ) { clipKey = &extKeyTab[ extKey ]; } if( clipKey ) { if( ( dwState & SHIFT_PRESSED ) && ( dwState & ( LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED ) ) ) { if( clipKey->key == K_TAB ) { ch = K_CTRL_SH_TAB; } } else if( dwState & LEFT_ALT_PRESSED ) { ch = clipKey->alt_key; } else if( dwState & RIGHT_ALT_PRESSED ) { ch = clipKey->altgr_key; } else if( dwState & ( LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED ) ) { ch = clipKey->ctrl_key; } else if( dwState & SHIFT_PRESSED ) { ch = clipKey->shift_key; } else { ch = clipKey->key; } if( ch == 0 ) /* for keys that are only on shift or AltGr */ { ch = clipKey->key; } } /* national codepage translation */ if( ch > 0 && ch <= 255 ) { ch = s_keyTrans[ ch ]; } } } else if( b_MouseEnable && s_irInBuf[ s_cNumIndex ].EventType == MOUSE_EVENT && iEventMask & ~( INKEY_KEYBOARD | INKEY_RAW ) ) { hb_mouse_iCol = s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwMousePosition.X; hb_mouse_iRow = s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwMousePosition.Y; if( iEventMask & INKEY_MOVE && s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwEventFlags == MOUSE_MOVED ) { ch = K_MOUSEMOVE; } else if( iEventMask & INKEY_MWHEEL && s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwEventFlags == MOUSE_WHEELED ) { ch = s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwButtonState & 0xFF000000 ? K_MWBACKWARD : K_MWFORWARD; } else if( iEventMask & INKEY_LDOWN && s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED ) { ch = s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwEventFlags == DOUBLE_CLICK ? K_LDBLCLK : K_LBUTTONDOWN; s_mouseLast = K_LBUTTONDOWN; } else if( iEventMask & INKEY_RDOWN && s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED ) { ch = s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwEventFlags == DOUBLE_CLICK ? K_RDBLCLK : K_RBUTTONDOWN; s_mouseLast = K_RBUTTONDOWN; } else if( s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwEventFlags == 0 && s_irInBuf[ s_cNumIndex ].Event.MouseEvent.dwButtonState == 0 ) { if( iEventMask & INKEY_LUP && s_mouseLast == K_LBUTTONDOWN ) { ch = K_LBUTTONUP; s_mouseLast = 0; } else if( iEventMask & INKEY_RUP && s_mouseLast == K_RBUTTONDOWN ) { ch = K_RBUTTONUP; s_mouseLast = 0; } } } /* Set up to process the next input event (if any) */ if( s_wRepeated == 0 ) { s_cNumIndex++; } } #if 0 if( ch ) { printf(" %ld:%ld",ch,extKey); } #endif return ch; } | gtwin.c | 1129 |
STATIC VOID | hb_gt_win_Tone( PHB_GT pGT, double dFrequency, double dDuration )
static void hb_gt_win_Tone( PHB_GT pGT, double dFrequency, double dDuration ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_Tone(%p,%lf,%lf)", pGT, dFrequency, dDuration)); HB_SYMBOL_UNUSED( pGT ); hb_gt_w32_tone( dFrequency, dDuration ); } | gtwin.c | 1479 |
STATIC BOOL | hb_gt_win_SetDispCP( PHB_GT pGT, char *pszTermCDP, char *pszHostCDP, BOOL fBox )
static BOOL hb_gt_win_SetDispCP( PHB_GT pGT, char *pszTermCDP, char *pszHostCDP, BOOL fBox ) { int i; HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_SetDispCP(%p,%s,%s,%d)", pGT, pszTermCDP, pszHostCDP, (int) fBox)); HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ); for( i = 0; i < 256; i++ ) s_charTrans[ i ] = ( BYTE ) i; #ifndef HB_CDP_SUPPORT_OFF if( !pszHostCDP ) pszHostCDP = hb_cdpID(); if( pszTermCDP && pszHostCDP ) { PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP ), cdpHost = hb_cdpFind( pszHostCDP ); if( cdpTerm && cdpHost && cdpTerm != cdpHost && cdpTerm->nChars && cdpTerm->nChars == cdpHost->nChars ) { for( i = 0; i < cdpHost->nChars; ++i ) { s_charTrans[ ( BYTE ) cdpHost->CharsUpper[ i ] ] = ( BYTE ) cdpTerm->CharsUpper[ i ]; s_charTrans[ ( BYTE ) cdpHost->CharsLower[ i ] ] = ( BYTE ) cdpTerm->CharsLower[ i ]; } } } #endif for( i = 0; i < 256; i++ ) s_charTransRev[ s_charTrans[ i ] ] = ( BYTE ) i; return TRUE; } | gtwin.c | 1492 |
STATIC BOOL | hb_gt_win_SetKeyCP( PHB_GT pGT, char *pszTermCDP, char *pszHostCDP )
static BOOL hb_gt_win_SetKeyCP( PHB_GT pGT, char *pszTermCDP, char *pszHostCDP ) { int i; HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_SetKeyCP(%p,%s,%s)", pGT, pszTermCDP, pszHostCDP)); HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP ); for( i = 0; i < 256; i++ ) s_keyTrans[ i ] = ( BYTE ) i; #ifndef HB_CDP_SUPPORT_OFF if( !pszHostCDP ) { pszHostCDP = hb_cdpID(); } if( pszTermCDP && pszHostCDP ) { PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP ), cdpHost = hb_cdpFind( pszHostCDP ); if( cdpTerm && cdpHost && cdpTerm != cdpHost && cdpTerm->nChars && cdpTerm->nChars == cdpHost->nChars ) { for( i = 0; i < cdpHost->nChars; ++i ) { s_keyTrans[ ( BYTE ) cdpHost->CharsUpper[ i ] ] = ( BYTE ) cdpTerm->CharsUpper[ i ]; s_keyTrans[ ( BYTE ) cdpHost->CharsLower[ i ] ] = ( BYTE ) cdpTerm->CharsLower[ i ]; } } } #endif return TRUE; } | gtwin.c | 1533 |
STATIC BOOL | hb_gt_win_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
static BOOL hb_gt_win_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_win_Info(%p,%d,%p)", pGT, iType, pInfo ) ); switch( iType ) { case HB_GTI_FULLSCREEN: case HB_GTI_KBDSUPPORT: pInfo->pResult = hb_itemPutL( pInfo->pResult, TRUE ); break; case HB_GTI_WINTITLE: { TCHAR buff[ 256 ]; char * szTitle; DWORD dwLen; dwLen = GetConsoleTitle( buff, sizeof( buff ) / sizeof( TCHAR ) ); szTitle = ( char * ) hb_xgrab( dwLen + 1 ); HB_TCHAR_GETFROM( szTitle, buff, dwLen ); pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, szTitle, dwLen ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) { LPTSTR lpTitle = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); SetConsoleTitle( lpTitle ); HB_TCHAR_FREE( lpTitle ); } break; } case HB_GTI_VIEWMAXHEIGHT: { COORD coBuf = GetLargestConsoleWindowSize( s_HOutput ); pInfo->pResult = hb_itemPutNI( pInfo->pResult, coBuf.Y - 1 ); break; } case HB_GTI_VIEWMAXWIDTH: { COORD coBuf = GetLargestConsoleWindowSize( s_HOutput ); pInfo->pResult = hb_itemPutNI( pInfo->pResult, coBuf.X - 1 ); break; } case HB_GTI_VIEWPORTHEIGHT: pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_csbi.srWindow.Bottom - s_csbi.srWindow.Top ); break; case HB_GTI_VIEWPORTWIDTH: pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_csbi.srWindow.Right - s_csbi.srWindow.Left ); break; case HB_GTI_KBDSHIFTS: pInfo->pResult = hb_itemPutNI( pInfo->pResult, hb_gt_w32_getKbdState() ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) hb_gt_w32_setKbdState( hb_itemGetNI( pInfo->pNewVal ) ); break; case HB_GTI_KBDSPECIAL: pInfo->pResult = hb_itemPutL( pInfo->pResult, s_bSpecialKeyHandling ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_LOGICAL ) s_bSpecialKeyHandling = hb_itemGetL( pInfo->pNewVal ); break; case HB_GTI_KBDALT: pInfo->pResult = hb_itemPutL( pInfo->pResult, s_bAltKeyHandling ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_LOGICAL ) s_bAltKeyHandling = hb_itemGetL( pInfo->pNewVal ); break; case HB_GTI_CLIPBOARDDATA: if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) { hb_gt_w32_setClipboard( CF_OEMTEXT, hb_itemGetCPtr( pInfo->pNewVal ), hb_itemGetCLen( pInfo->pNewVal ) ); } else { char * szClipboardData; ULONG ulLen; if( hb_gt_w32_getClipboard( CF_OEMTEXT, &szClipboardData, &ulLen ) ) { pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, szClipboardData, ulLen ); } else { pInfo->pResult = hb_itemPutC( pInfo->pResult, NULL ); } } break; default: return HB_GTSUPER_INFO( pGT, iType, pInfo ); } return TRUE; } | gtwin.c | 1573 |
STATIC BOOL | hb_gt_win_mouse_IsPresent( PHB_GT pGT )
static BOOL hb_gt_win_mouse_IsPresent( PHB_GT pGT ) { HB_SYMBOL_UNUSED( pGT ); return b_MouseEnable; } | gtwin.c | 1674 |
STATIC VOID | hb_gt_win_mouse_GetPos( PHB_GT pGT, int * piRow, int * piCol )
static void hb_gt_win_mouse_GetPos( PHB_GT pGT, int * piRow, int * piCol ) { HB_SYMBOL_UNUSED( pGT ); *piRow = hb_mouse_iRow; *piCol = hb_mouse_iCol; } | gtwin.c | 1681 |
STATIC BOOL | hb_gt_win_mouse_ButtonState( PHB_GT pGT, int iButton )
static BOOL hb_gt_win_mouse_ButtonState( PHB_GT pGT, int iButton ) { BOOL fReturn = FALSE; HB_SYMBOL_UNUSED( pGT ); if( iButton == 0 ) fReturn = ( GetKeyState( VK_LBUTTON ) & 0x8000 ) != 0; else if( iButton== 1 ) fReturn = ( GetKeyState( VK_RBUTTON ) & 0x8000 ) != 0; else if( iButton == 2 ) fReturn = ( GetKeyState( VK_MBUTTON ) & 0x8000 ) != 0; return fReturn; } | gtwin.c | 1689 |
STATIC INT | hb_gt_win_mouse_CountButton( PHB_GT pGT )
static int hb_gt_win_mouse_CountButton( PHB_GT pGT ) { DWORD dwCount = 0; HB_SYMBOL_UNUSED( pGT ); GetNumberOfConsoleMouseButtons( &dwCount ); return ( int ) dwCount; } | gtwin.c | 1705 |
STATIC VOID | hb_gt_win_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
static void hb_gt_win_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_win_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) ); if( iSize > 0 && s_pCharInfoScreen && iRow < ( int ) _GetScreenHeight() && iCol < ( int ) _GetScreenWidth() ) { BYTE bColor, bAttr; USHORT usChar; int iFirst = iCol; int i = ( iRow * _GetScreenWidth() + iCol ); while( iSize-- > 0 ) { if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol++, &bColor, &bAttr, &usChar ) ) break; s_pCharInfoScreen[i].Char.AsciiChar = ( CHAR ) s_charTrans[ usChar & 0xFF ]; s_pCharInfoScreen[i].Attributes = ( WORD ) ( bColor & 0xFF ); ++i; } hb_gt_win_xUpdtSet( ( USHORT ) iRow, ( USHORT ) iFirst, ( USHORT ) iRow, ( USHORT ) iCol - 1 ); } } | gtwin.c | 1718 |
STATIC VOID | hb_gt_win_Refresh( PHB_GT pGT )
static void hb_gt_win_Refresh( PHB_GT pGT ) { HB_TRACE( HB_TR_DEBUG, ("hb_gt_win_Refresh(%p)", pGT) ); HB_GTSUPER_REFRESH( pGT ); if( s_pCharInfoScreen ) { int iRow, iCol, iStyle; HB_GTSELF_GETSCRCURSOR( pGT, &iRow, &iCol, &iStyle ); s_sCurRow = ( SHORT ) iRow; s_sCurCol = ( SHORT ) iCol; if( iRow < 0 || iCol < 0 || iRow >= ( int ) _GetScreenHeight() || iCol >= ( int ) _GetScreenWidth() ) { s_usCursorStyle = SC_NONE; } else { s_usCursorStyle = ( USHORT ) iStyle; } hb_gt_win_xScreenUpdate(); } } | gtwin.c | 1745 |
STATIC BOOL | hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_FuncInit(%p)", pFuncTable)); pFuncTable->Init = hb_gt_win_Init; pFuncTable->Exit = hb_gt_win_Exit; pFuncTable->SetMode = hb_gt_win_SetMode; pFuncTable->Redraw = hb_gt_win_Redraw; pFuncTable->Refresh = hb_gt_win_Refresh; pFuncTable->Version = hb_gt_win_Version; pFuncTable->PostExt = hb_gt_win_PostExt; pFuncTable->Suspend = hb_gt_win_Suspend; pFuncTable->Resume = hb_gt_win_Resume; pFuncTable->Tone = hb_gt_win_Tone; pFuncTable->Info = hb_gt_win_Info; pFuncTable->SetDispCP = hb_gt_win_SetDispCP; pFuncTable->SetKeyCP = hb_gt_win_SetKeyCP; pFuncTable->ReadKey = hb_gt_win_ReadKey; pFuncTable->MouseIsPresent = hb_gt_win_mouse_IsPresent; pFuncTable->MouseGetPos = hb_gt_win_mouse_GetPos; pFuncTable->MouseButtonState = hb_gt_win_mouse_ButtonState; pFuncTable->MouseCountButton = hb_gt_win_mouse_CountButton; return TRUE; } /* ********************************************************************** */ static const HB_GT_INIT gtInit = { HB_GT_DRVNAME( HB_GT_NAME ), hb_gt_FuncInit, HB_GTSUPER, HB_GTID_PTR }; HB_GT_ANNOUNCE( HB_GT_NAME ) HB_CALL_ON_STARTUP_BEGIN( _hb_startup_gt_Init_ ) hb_gtRegister( >Init ); HB_CALL_ON_STARTUP_END( _hb_startup_gt_Init_ ) #if defined( HB_PRAGMA_STARTUP ) #pragma startup _hb_startup_gt_Init_ #elif defined( HB_MSC_STARTUP ) #if defined( HB_OS_WIN_64 ) #pragma section( HB_MSC_START_SEGMENT, long, read ) #endif #pragma data_seg( HB_MSC_START_SEGMENT ) static HB_$INITSYM hb_vm_auto__hb_startup_gt_Init_ = _hb_startup_gt_Init_; | gtwin.c | 1777 |
Page url: http://www.yourdomain.com/help/index.html?gtwin.htm