From cb0f27dc00f855ca6e31b7e6d887354ae06e50ba Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 18 Jun 2000 16:46:01 +0000 Subject: [PATCH] 2000-06-18 18:38 UTC+0100 Victor Szakats --- harbour/ChangeLog | 15 ++ harbour/source/lang/msgde.c | 256 +++++++++++++++------- harbour/source/rtl/gtcrs/gtcrs.c | 166 ++++++++------- harbour/source/rtl/gtcrs/kbdcrs.c | 318 ++++++++++++++-------------- harbour/source/rtl/gtcrs/mousecrs.c | 8 +- harbour/source/rtl/gtsln/gtsln.c | 299 +++++++++++++------------- harbour/source/rtl/gtsln/kbsln.c | 233 ++++++++++---------- harbour/source/rtl/gtsln/keytrans.c | 4 + 8 files changed, 715 insertions(+), 584 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cfa0ae8bcf..4e06a218c8 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,18 @@ +2000-06-18 18:38 UTC+0100 Victor Szakats + + * source/lang/msgde.c + * Updated, Thanks to Torsten. + + * source/rtl/gtcrs/* + * Some formatting + + * source/rtl/gtsln/* + * Some formatting, variables renamed. + ! Added CVS IDs + + WARNING! Please try to compile the SLANG and NCURSES GTs and report any + errors, since I could not test them. + 2000-06-18 20:16 GMT+3 Alexander Kresin * source/pp/ppcore.c *fixed some problems with [ ... ] in pp, reported by Brian Hays diff --git a/harbour/source/lang/msgde.c b/harbour/source/lang/msgde.c index 503fd65164..f81126402a 100644 --- a/harbour/source/lang/msgde.c +++ b/harbour/source/lang/msgde.c @@ -2,91 +2,189 @@ * $Id$ */ -/* Language Support Module */ +/* + * Harbour Project source code: + * Language Support Module (DE) + * + * Copyright 1999 {list of individual authors and e-mail addresses} + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version, with one exception: + * + * The exception is that if you link the Harbour Runtime Library (HRL) + * and/or the Harbour Virtual Machine (HVM) with other files to produce + * an executable, this does not by itself cause the resulting executable + * to be covered by the GNU General Public License. Your use of that + * executable is in no way restricted on account of linking the HRL + * and/or HVM code into it. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit + * their web site at http://www.gnu.org/). + * + */ /* Language name: German */ /* ISO language code (2 chars): DE */ -/* Codepage: ???? */ +/* Codepage: 850 */ -#include "hbdefs.h" +#include "hbapilng.h" -char *hb_dateMonthsName[ 12 ] = +static HB_LANG s_lang = { - "Januar", - "Februar", - "März", - "April", - "Mai", - "Juni", - "Juli", - "August", - "September", - "Oktober", - "November", - "Dezember" + { + /* Identification */ + + "DE", /* ID */ + "German", /* Name (in English) */ + "deutsch", /* Name (in native language) */ + "DE", /* RFC ID */ + "850", /* Codepage */ + "$Revision$ $Date$", /* Version */ + + /* Month names */ + + "Januar", + "Februar", + "M„rz", + "April", + "Mai", + "Juni", + "Juli", + "August", + "September", + "Oktober", + "November", + "Dezember", + + /* Day names */ + + "Sonntag", + "Montag", + "Dienstag", + "Mittwoch", + "Donnerstag", + "Freitag", + "Samstag", + + /* CA-Cl*pper compatible natmsg items */ + + "Datenbank Dateien Anz. S„tze Letzte Žnderung Gr”áe", + "M”chten Sie mehr Beispiele?", + "Anz. Seiten", + "** Zwischensumme **", + "* Teilsumme *", + "*** Summe ***", + "Einfg", + " ", + "Ungltiges Datum", + "Bereich: ", + " - ", + "J/N", + "UNGšLTIGER AUSDRUCK", + + /* Error description names */ + + "Unknown error", + "Argument error", + "Bound error", + "String overflow", + "Numeric overflow", + "Zero divisor", + "Numeric error", + "Syntax error", + "Operation too complex", + "", + "", + "Memory low", + "Undefined function", + "No exported method", + "Variable does not exist", + "Alias does not exist", + "No exported variable", + "Illegal characters in alias", + "Alias already in use", + "", + "Create error", + "Open error", + "Close error", + "Read error", + "Write error", + "Print error", + "", + "", + "", + "", + "Operation not supported", + "Limit exceeded", + "Corruption detected", + "Data type error", + "Data width error", + "Workarea not in use", + "Workarea not indexed", + "Exclusive required", + "Lock required", + "Write not allowed", + "Append lock failed", + "Lock Failure", + "", + "", + "", + "", + "array access", + "array assign", + "array dimension", + "not an array", + "conditional", + + /* Internal error names */ + + "Unrecoverable error %lu: ", + "Error recovery failure", + "No ERRORBLOCK() for error", + "Too many recursive error handler calls", + "RDD invalid or failed to load", + "Invalid method type from %s", + "hb_xgrab can't allocate memory", + "hb_xrealloc called with a NULL pointer", + "hb_xrealloc called with an invalid pointer", + "hb_xrealloc can't reallocate memory", + "hb_xfree called with an invalid pointer", + "hb_xfree called with a NULL pointer", + "Can\'t locate the starting procedure: \'%s\'", + "No starting procedure", + "Unsupported VM opcode", + "Symbol item expected from %s", + "Invalid symbol type for self from %s", + "Codeblock expected from %s", + "Incorrect item type on the stack trying to pop from %s", + "Stack underflow", + "An item was going to be copied to itself from %s", + "Invalid symbol item passed as memvar %s", + + /* Texts */ + + "DD.MM.YYYY", + "J", + "N" + } }; -char *hb_dateDaysName[ 7 ] = -{ - "Sonntag", - "Montag", - "Dienstag", - "Mittwoch", - "Donnerstag", - "Freitag", - "Samstag" -}; +HB_LANG_ANNOUNCE( DE ); + +HB_CALL_ON_STARTUP_BEGIN( hb_lang_Init_DE ) + hb_langRegister( &s_lang ); +HB_CALL_ON_STARTUP_END( hb_lang_Init_DE ) +#if ! defined(__GNUC__) && ! defined(_MSC_VER) + #pragma startup hb_lang_Init_DE +#endif -char *hb_errorsGeneric[] = -{ - "Unknown error", - "Argument error", - "Bound error", - "String overflow", - "Numeric overflow", - "Zero divisor", - "Numeric error", - "Syntax error", - "Operation too complex", - "", - "", - "Memory low", - "Undefined function", - "No exported method", - "Variable does not exist", - "Alias does not exist", - "No exported variable", - "Illegal characters in alias", - "Alias already in use", - "", - "Create error", - "Open error", - "Close error", - "Read error", - "Write error", - "Print error", - "", - "", - "", - "", - "Operation not supported", - "Limit exceeded", - "Corruption detected", - "Data type error", - "Data width error", - "Workarea not in use", - "Workarea not indexed", - "Exclusive required", - "Lock required", - "Write not allowed", - "Append lock failed", - "Lock Failure", - "", - "", - "", - "Incorrect number of arguments", - "array access", - "array assign", - "not an array", - "conditional" -}; diff --git a/harbour/source/rtl/gtcrs/gtcrs.c b/harbour/source/rtl/gtcrs/gtcrs.c index 7321f5dbaa..c97468648c 100644 --- a/harbour/source/rtl/gtcrs/gtcrs.c +++ b/harbour/source/rtl/gtcrs/gtcrs.c @@ -43,14 +43,14 @@ */ static USHORT s_uiDispCount; -static void gt_GetMaxRC(int* r, int* c); -static void gt_GetRC(int* r, int* c); -static void gt_SetRC(int r, int c); +static void gt_GetMaxRC( int * r, int * c ); +static void gt_GetRC( int * r, int * c ); +static void gt_SetRC( int r, int c ); static unsigned s_attribmap_table[ 256 ]; /* mapping from DOS style attributes */ static BOOL s_under_xterm; static int s_alternate_char_set; -static char s_xTermBox[ 10 ] = "lqkxjqmx "; +static char s_xTermBox[ 10 ] = "lqkxjqmx "; extern void hb_gt_Initialize_Mouse( void ); extern void hb_gt_Initialize_Keyboard( void ); @@ -87,19 +87,21 @@ static void hb_gt_Initialize_Terminal( void ) static char color_map[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; start_color(); - for( backg=0; backg> 4 ) & 0x07; /* bits 4-6, bit 7 is blinking attribute */ - foreg = ( i & 0x07 ); - s_attribmap_table[ i ] = COLOR_PAIR( backg*COLORS + foreg ); - if( i & 0x08 ) - s_attribmap_table[ i ] |= A_BOLD; /* 4-th bit is an intensity bit */ - if( i & 0x80 ) - s_attribmap_table[ i ] |= A_BLINK; /* 7-th bit is blinking bit */ + foreg = ( i & 0x07 ); + s_attribmap_table[ i ] = COLOR_PAIR( backg * COLORS + foreg ); + if( i & 0x08 ) + s_attribmap_table[ i ] |= A_BOLD; /* 4-th bit is an intensity bit */ + if( i & 0x80 ) + s_attribmap_table[ i ] |= A_BLINK; /* 7-th bit is blinking bit */ } } @@ -109,24 +111,23 @@ static void hb_gt_Initialize_Terminal( void ) nodelay( stdscr, TRUE ); keypad( stdscr, FALSE ); - s_under_xterm = !strncmp( getenv("TERM"), "xterm", 5 ); - if( s_under_xterm ) - { - /* Alternate characters set will be enabled only by request because - * it changes character mapping under xterm - */ - s_alternate_char_set = 0; - } - else - { - /* If running under Linux console enable alternate character set - * by default - */ - s_alternate_char_set = A_ALTCHARSET; - } + s_under_xterm = ( strncmp( getenv( "TERM" ), "xterm", 5 ) == 0 ); + if( s_under_xterm ) + { + /* Alternate characters set will be enabled only by request because + * it changes character mapping under xterm + */ + s_alternate_char_set = 0; + } + else + { + /* If running under Linux console enable alternate character set + * by default + */ + s_alternate_char_set = A_ALTCHARSET; + } bkgdset( ' ' ); ripoffline( 0, NULL ); - } static void hb_gt_Exit_Terminal( void ) @@ -146,7 +147,6 @@ void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ) /* Mouse sub-sytem have to be initialized after ncurses initialization */ hb_gt_Initialize_Mouse(); hb_gt_Initialize_Keyboard(); - } void hb_gt_Exit( void ) @@ -223,7 +223,7 @@ USHORT hb_gt_GetScreenWidth( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenWidth()")); - gt_GetMaxRC(&r, &c); + gt_GetMaxRC( &r, &c ); return c; } @@ -233,7 +233,7 @@ USHORT hb_gt_GetScreenHeight( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenHeight()")); - gt_GetMaxRC(&r, &c); + gt_GetMaxRC( &r, &c ); return r; } @@ -241,7 +241,7 @@ void hb_gt_SetPos( SHORT iRow, SHORT iCol ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd)", iRow, iCol)); - gt_SetRC(iRow, iCol); + gt_SetRC( iRow, iCol ); } SHORT hb_gt_Col( void ) @@ -250,7 +250,7 @@ SHORT hb_gt_Col( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()")); - gt_GetRC(&r, &c); + gt_GetRC( &r, &c ); return c; } @@ -260,7 +260,7 @@ SHORT hb_gt_Row( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()")); - gt_GetRC(&r, &c); + gt_GetRC( &r, &c ); return r; } @@ -291,7 +291,9 @@ static void hb_gt_xPutch( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_xPutch(%hu, %hu, %d, %i)", uiRow, uiCol, (int) byAttr, byChar)); move( uiRow, uiCol ); + addch( byChar | s_alternate_char_set | s_attribmap_table[ byAttr ] ); + if( s_uiDispCount == 0 ) refresh(); } @@ -309,8 +311,10 @@ void hb_gt_Puts( USHORT uiRow, attr = s_alternate_char_set | s_attribmap_table[ byAttr ]; move( uiRow, uiCol ); + for( i = 0; i < ulLen; ++i ) addch( pbyStr[ i ] | attr ); + if( s_uiDispCount == 0 ) refresh(); } @@ -327,7 +331,7 @@ void hb_gt_GetText( USHORT uiTop, BYTE * pbyDst ) { int i; - chtype *pBuffer = (chtype *)pbyDst; + chtype * pBuffer = ( chtype * ) pbyDst; HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbyDst)); @@ -336,7 +340,7 @@ void hb_gt_GetText( USHORT uiTop, while( uiTop <= uiBottom ) { - for( i=uiLeft; i<=uiRight; i++, pBuffer++ ) + for( i = uiLeft; i <= uiRight; i++, pBuffer++ ) *pBuffer = mvinch( uiTop, i ); ++uiTop; } @@ -349,7 +353,7 @@ void hb_gt_PutText( USHORT uiTop, BYTE * pbySrc ) { int Cols; - chtype *pBuffer = (chtype *)pbySrc; + chtype * pBuffer = ( chtype * ) pbySrc; HB_TRACE(HB_TR_DEBUG, ("hb_gt_PutText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbySrc)); @@ -357,9 +361,10 @@ void hb_gt_PutText( USHORT uiTop, while( uiTop <= uiBottom ) { mvaddchnstr( uiTop, uiLeft, pBuffer, Cols ); - pBuffer +=Cols; + pBuffer += Cols; ++uiTop; } + if( s_uiDispCount == 0 ) refresh(); } @@ -380,15 +385,15 @@ void hb_gt_SetAttribute( USHORT uiTop, while( uiTop <= uiBottom ) { - for ( dx=uiLeft; dx<=uiRight; dx++ ) + for( dx = uiLeft; dx <= uiRight; dx++ ) { - c = mvinch( uiTop, dx ); - /* extract character only (remember about alternate chars) */ - c &= (A_CHARTEXT | A_ALTCHARSET); - /* set new attribute */ - c |= newAttr; - if (addch(c) == ERR) /* Stop on error */ - return; + c = mvinch( uiTop, dx ); + /* extract character only (remember about alternate chars) */ + c &= ( A_CHARTEXT | A_ALTCHARSET ); + /* set new attribute */ + c |= newAttr; + if( addch( c ) == ERR ) /* Stop on error */ + return; } uiTop++; } @@ -410,9 +415,9 @@ void hb_gt_Scroll( USHORT uiTop, if( iRows == 0 && iCols == 0 ) { /* Clear the specified rectangle */ - WINDOW *subw; + WINDOW * subw; - subw = subwin( stdscr, uiBottom-uiTop+1, uiRight-uiLeft+1, uiTop, uiLeft ); + subw = subwin( stdscr, uiBottom - uiTop + 1, uiRight - uiLeft + 1, uiTop, uiLeft ); wbkgdset( subw, ' ' | s_attribmap_table[ byAttr ] ); wclear( subw ); touchwin( stdscr ); @@ -423,9 +428,9 @@ void hb_gt_Scroll( USHORT uiTop, { if( iRows != 0 ) { - WINDOW *subw; + WINDOW * subw; - subw = subwin( stdscr, uiBottom-uiTop+1, uiRight-uiLeft+1, uiTop, uiLeft ); + subw = subwin( stdscr, uiBottom - uiTop + 1, uiRight - uiLeft + 1, uiTop, uiLeft ); wbkgdset( subw, ' ' | s_attribmap_table[ byAttr ] ); scrollok( subw, TRUE ); wscrl( subw, iRows ); @@ -434,7 +439,7 @@ void hb_gt_Scroll( USHORT uiTop, if( iCols != 0 ) { - chtype *pScreen, *pTmp; + chtype * pScreen, * pTmp; int memsize; int RowCount, ColCount; int i, j; @@ -447,37 +452,37 @@ void hb_gt_Scroll( USHORT uiTop, newAttr = ' ' | s_attribmap_table[ byAttr ]; memsize = hb_gt_RectSize( RowCount, ColCount ); - pScreen = (chtype *) hb_xgrab( memsize ); - hb_gt_GetText( uiTop, uiLeft, uiBottom, uiRight, (BYTE *)pScreen ); + pScreen = ( chtype * ) hb_xgrab( memsize ); + hb_gt_GetText( uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) pScreen ); if( iCols > 0 ) { pTmp = pScreen; - for( i=0; i=iCols; j-- ) - pTmp[ j ] = pTmp[ j-1 ]; - for( j=0; j= iCols; j-- ) + pTmp[ j ] = pTmp[ j - 1 ]; + for( j = 0; j < iCols; j++ ) pTmp[ j ] = newAttr; pTmp += ColCount; } } else { - int ColMove = ColCount + iCols; + int ColMove = ColCount + iCols; pTmp = pScreen; - for( i=0; ilength) && (memcmp( tmp->key_string, key_codes, i ) == 0 ) ) + if( ( i == tmp->length ) && ( memcmp( tmp->key_string, key_codes, i ) == 0 ) ) { - ch = tmp->inkey_code; /* keycode found */ + ch = tmp->inkey_code; /* keycode found */ tmp = NULL; /* NOTE: tmp->inkey_code can be set to 0 */ } else @@ -303,7 +302,7 @@ fflush( stderr ); } if( ch == 0 ) - { + { if( s_mouse_event_len ) { /* check for mouse event */ @@ -321,7 +320,7 @@ fflush( stderr ); key_waiting = 0; /* return raw key sequence */ ch = K_HB_KEYCODES; } - } + } } } return ch; @@ -330,44 +329,41 @@ fflush( stderr ); static void hb_gt_Add_keymap( int InkeyCode, char *key_string ) { - struct key_map_struc *keymap; + struct key_map_struc * keymap; int iLength = strlen( key_string ); int i = 0; BYTE sum = 0; + if( iLength && iLength <= HB_MAX_KEYMAP_CHARS ) + { + while( i < iLength ) + sum += key_string[ i++ ]; + sum &= HB_HASH_KEY - 1; - if( iLength && iLength <= HB_MAX_KEYMAP_CHARS ) + keymap = hb_xgrab( sizeof( struct key_map_struc ) ); + keymap->inkey_code = InkeyCode; + keymap->key_string = key_string; + keymap->length = iLength; + keymap->Next = NULL; + + if( s_keymap_table[ sum ] ) { - while( i < iLength ) - sum += key_string[ i++ ]; - sum &= HB_HASH_KEY-1; - - keymap = hb_xgrab( sizeof( struct key_map_struc ) ); - keymap->inkey_code = InkeyCode; - keymap->key_string = key_string; - keymap->length = iLength; - keymap->Next = NULL; - - if( s_keymap_table[ sum ] ) - { - struct key_map_struc *tmp = s_keymap_table[ sum ]; - while( tmp->Next ) - tmp =tmp->Next; - tmp->Next = keymap; - } - else - s_keymap_table[ sum ] = keymap; - } + struct key_map_struc * tmp = s_keymap_table[ sum ]; + while( tmp->Next ) + tmp = tmp->Next; + tmp->Next = keymap; + } + else + s_keymap_table[ sum ] = keymap; + } } -static void hb_gt_Add_terminfo_keymap( int InkeyCode, char *capname ) +static void hb_gt_Add_terminfo_keymap( int InkeyCode, char * capname ) { char * code; code = tigetstr( capname ); - if( (code != NULL) && (code != (char *)-1) ) - { - hb_gt_Add_keymap( InkeyCode, code ); - } + if( ( code != NULL ) && ( code != ( char * ) -1 ) ) + hb_gt_Add_keymap( InkeyCode, code ); } diff --git a/harbour/source/rtl/gtcrs/mousecrs.c b/harbour/source/rtl/gtcrs/mousecrs.c index 0af508ffad..3d8a129518 100644 --- a/harbour/source/rtl/gtcrs/mousecrs.c +++ b/harbour/source/rtl/gtcrs/mousecrs.c @@ -219,11 +219,13 @@ BOOL hb_mouse_IsButtonPressed( int iButton ) USHORT uKey; USHORT i; - uKey = (iButton == 1) ? INKEY_LDOWN : INKEY_RDOWN; + uKey = ( iButton == 1 ) ? INKEY_LDOWN : INKEY_RDOWN; i = 0; while( i <= s_last_event ) + { if( s_event_queue[ i++ ].key & uKey ) return TRUE; + } } return FALSE; } @@ -245,10 +247,10 @@ void hb_mouse_GetBounds( int * piTop, int * piLeft, int * piBottom, int * piRigh { int r, c; - getmaxyx(stdscr, r, c); + getmaxyx( stdscr, r, c ); *piTop = *piLeft = 0; *piBottom = r; - *piRight = c; + *piRight = c; } diff --git a/harbour/source/rtl/gtsln/gtsln.c b/harbour/source/rtl/gtsln/gtsln.c index 316f4e1149..cfdc6f0061 100644 --- a/harbour/source/rtl/gtsln/gtsln.c +++ b/harbour/source/rtl/gtsln/gtsln.c @@ -1,3 +1,7 @@ +/* + * $Id$ + */ + /* * Harbour Project source code: * Video subsystem based on Slang screen library. @@ -32,18 +36,18 @@ /* NOTE: User programs should never call this layer directly! */ #ifdef __linux__ - #include + #include #else - #include + #include #endif /* missing defines in previous versions of Slang - this was not TESTED !! */ #if SLANG_VERSION < 10401 - typedef unsigned short SLsmg_Char_Type; - #define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFF) - #define SLSMG_EXTRACT_COLOR(x) (((x)>>8)&0xFF) - #define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(unsigned char)(ch))|((color)<<8)) - #define SLSMG_BOARD_CHAR 'h' - #define SLSMG_BLOCK_CHAR '0' + typedef unsigned short SLsmg_Char_Type; + #define SLSMG_EXTRACT_CHAR( x ) ( ( x ) & 0xFF ) + #define SLSMG_EXTRACT_COLOR( x ) ( ( ( x ) >> 8 ) & 0xFF ) + #define SLSMG_BUILD_CHAR( ch, color ) ( ( ( SLsmg_Char_Type ) ( unsigned char )( ch ) ) | ( ( color ) << 8 ) ) + #define SLSMG_BOARD_CHAR 'h' + #define SLSMG_BLOCK_CHAR '0' #endif #include @@ -52,25 +56,25 @@ #include "inkey.ch" #ifdef IBMPC_SYSTEM -int SLtt_Has_Alt_Charset = 1; -char *SLtt_Graphics_Char_Pairs = ""; + int SLtt_Has_Alt_Charset = 1; + char * SLtt_Graphics_Char_Pairs = ""; #endif extern int hb_gt_Init_Terminal( int phase ); static void hb_gt_build_conv_tabs(); -static USHORT uiDispCount; +static USHORT s_uiDispCount; /* on Unix systems always assume cursor is visible on startup - look later */ -static int cursorVisible = 1; -static int linuxConsole = 0; -static int underXTerm = 0; +static int s_cursorVisible = 1; +static BOOL s_linuxConsole = FALSE; +static BOOL s_underXTerm = FALSE; /* indicate if we are currently running a command from system */ static BOOL s_bSuspended = FALSE; /* to convert high characters (mostly graphics and control chars) */ -static unsigned char convHighChars[ 256 ]; +static unsigned char s_convHighChars[ 256 ]; /* to convert colors to Clipper mode */ -static char *colorNames[] = +static char * s_colorNames[] = { "black" , "blue" , @@ -90,48 +94,48 @@ static char *colorNames[] = "white" }; -volatile int Screen_Size_Changed = 0; +volatile BOOL hb_gt_sln_bScreen_Size_Changed = FALSE; #ifndef IBMPC_SYSTEM /* window resize handler */ -static void sigwinch_handler (int sig) +static void sigwinch_handler( int sig ) { - Screen_Size_Changed = 1; - SLsignal (SIGWINCH, sigwinch_handler); + hb_gt_sln_bScreen_Size_Changed = TRUE; + SLsignal( SIGWINCH, sigwinch_handler ); } #endif /* I think this function should not be void. It should be BOOL */ void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ) { - int gt_Inited = 0; + BOOL gt_Inited = FALSE; HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()")); - uiDispCount = 0; + s_uiDispCount = 0; /* read a terminal descripion from a terminfo database */ - SLtt_get_terminfo (); + SLtt_get_terminfo(); /* initialize higher-level Slang routines */ - if ( SLkp_init() != (-1) ) + if( SLkp_init() != -1 ) { /* initialize a terminal stuff and a Slang keyboard subsystem for the first time */ - if ( hb_gt_Init_Terminal( 0 ) ) + if( hb_gt_Init_Terminal( 0 ) ) { /* initialize a screen handling subsytem */ - if ( SLsmg_init_smg () != (-1) ) + if( SLsmg_init_smg() != -1 ) { #ifndef IBMPC_SYSTEM /* install window resize handler */ - SLsignal (SIGWINCH, sigwinch_handler); + SLsignal( SIGWINCH, sigwinch_handler ); #endif /* do not indicate USER_BREAK in SLang_Error - ??? */ SLang_Ignore_User_Abort = 1; /* default abort procesing */ - SLang_set_abort_signal(NULL); + SLang_set_abort_signal( NULL ); /* NOTE: this is incompatible with CLIPPER but under Unix we should assume cursor is @@ -139,18 +143,18 @@ void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ) out a current cursor state */ /* turn on a cursor visibility */ - if ( SLtt_set_cursor_visibility(1) != (-1) ) + if( SLtt_set_cursor_visibility( 1 ) != -1 ) { hb_gt_SetCursorStyle( 1 ); - cursorVisible = 1; + s_cursorVisible = 1; } else - cursorVisible = -1; + s_cursorVisible = -1; /* an uncertain way to check if we run under linux console */ - linuxConsole = ( !strncmp ( getenv("TERM"), "linux", 5 ) ); + s_linuxConsole = ( strncmp( getenv("TERM"), "linux", 5 ) == 0 ); /* an uncertain way to check if we run under xterm */ - underXTerm = ( strstr( getenv("TERM"), "xterm" ) != NULL ); + s_underXTerm = ( strstr( getenv("TERM"), "xterm" ) != NULL ); /* NOTE: this driver is implemented in a way that it is imposible to get intensity/blinking background mode @@ -176,12 +180,12 @@ void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ) #endif SLtt_cls(); SLsmg_set_color( 7 ); - gt_Inited = 1; + gt_Inited = TRUE; } } } - if ( !gt_Inited ) + if( ! gt_Inited ) { /* something went wrong - restore default settings */ SLang_reset_tty(); @@ -198,11 +202,11 @@ void hb_gt_Exit( void ) NOTE: This is incompatible with Clipper - on exit leave a cursor visible - if ( cursorVisible != (-1) ) - hb_gt_SetCursorStyle( 1 ); + if( s_cursorVisible != -1 ) + hb_gt_SetCursorStyle( 1 ); */ SLsmg_refresh(); - SLsmg_reset_smg (); + SLsmg_reset_smg(); SLang_reset_tty(); } @@ -306,19 +310,19 @@ USHORT hb_gt_GetCursorStyle( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetCursorStyle()")); - if( cursorVisible == 0 ) + if( s_cursorVisible == 0 ) uiStyle = SC_NONE; - else if( cursorVisible == 1 ) + else if( s_cursorVisible == 1 ) uiStyle = SC_NORMAL; - else if( cursorVisible == 2 ) + else if( s_cursorVisible == 2 ) uiStyle = SC_INSERT; - else if( cursorVisible == 3 ) + else if( s_cursorVisible == 3 ) uiStyle = SC_SPECIAL1; - else if( cursorVisible == 4 ) + else if( s_cursorVisible == 4 ) uiStyle = SC_SPECIAL2; else @@ -340,52 +344,52 @@ void hb_gt_SetCursorStyle( USHORT uiStyle ) switch( uiStyle ) { case SC_NONE: - if ( cursorVisible != (-1) ) + if( s_cursorVisible != -1 ) { - SLtt_set_cursor_visibility(0); - cursorVisible = 0; - if ( linuxConsole ) + SLtt_set_cursor_visibility( 0 ); + s_cursorVisible = 0; + if( s_linuxConsole ) { - cursDefseq[3] = '1'; + cursDefseq[ 3 ] = '1'; SLtt_write_string( cursDefseq ); } } break; case SC_NORMAL: - if ( cursorVisible != (-1) ) + if( s_cursorVisible != -1 ) { - SLtt_set_cursor_visibility(1); - cursorVisible = 1; - if ( linuxConsole ) + SLtt_set_cursor_visibility( 1 ); + s_cursorVisible = 1; + if( s_linuxConsole ) { - cursDefseq[3] = '2'; + cursDefseq[ 3 ] = '2'; SLtt_write_string( cursDefseq ); } } break; case SC_INSERT: - if ( cursorVisible != (-1) ) + if( s_cursorVisible != -1 ) { - SLtt_set_cursor_visibility(1); - cursorVisible = 2; - if ( linuxConsole ) + SLtt_set_cursor_visibility( 1 ); + s_cursorVisible = 2; + if( s_linuxConsole ) { - cursDefseq[3] = '4'; + cursDefseq[ 3 ] = '4'; SLtt_write_string( cursDefseq ); } } break; case SC_SPECIAL1: - if ( cursorVisible != (-1) ) + if( s_cursorVisible != -1 ) { - SLtt_set_cursor_visibility(1); - cursorVisible = 3; - if ( linuxConsole ) + SLtt_set_cursor_visibility( 1 ); + s_cursorVisible = 3; + if( s_linuxConsole ) { - cursDefseq[3] = '8'; + cursDefseq[ 3 ] = '8'; SLtt_write_string( cursDefseq ); } } @@ -406,13 +410,13 @@ static void hb_gt_xPutch( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_xPutch(%hu, %hu, %d, %i)", uiRow, uiCol, (int) byAttr, byChar)); /* build Slang converted char - note we are clearing a high bit of color */ - SLchar = SLSMG_BUILD_CHAR( convHighChars[ byChar ], byAttr & 0x7F ); + SLchar = SLSMG_BUILD_CHAR( s_convHighChars[ byChar ], byAttr & 0x7F ); /* alternate char set */ - if ( byChar > 127 ) + if( byChar > 127 ) SLchar |= 0x8000; - SLsmg_gotorc(uiRow, uiCol); + SLsmg_gotorc( uiRow, uiCol ); SLsmg_write_raw( &SLchar, 1 ); } @@ -420,35 +424,35 @@ void hb_gt_Puts( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE * pbyStr, ULONG u { ULONG i; BYTE byChar; - SLsmg_Char_Type SLchar, *pScr; + SLsmg_Char_Type SLchar, * pScr; HB_TRACE(HB_TR_DEBUG, ("hb_gt_Puts(%hu, %hu, %d, %p, %lu)", uiRow, uiCol, (int) byAttr, pbyStr, ulLen)); - pScr = (SLsmg_Char_Type *)hb_xgrab( (ulLen+1) * sizeof( SLsmg_Char_Type ) ); + pScr = ( SLsmg_Char_Type * ) hb_xgrab( ( ulLen + 1 ) * sizeof( SLsmg_Char_Type ) ); - for ( i=0; i 127 ) + if( byChar > 127 ) SLchar |= 0x8000; - *(pScr+i) = SLchar; + *( pScr + i ) = SLchar; } SLsmg_gotorc(uiRow, uiCol); - if ( ulLen > 0 ) + if( ulLen > 0 ) SLsmg_write_raw( pScr, ulLen ); hb_xfree( ( BYTE * )pScr ); - if( uiDispCount == 0 ) + if( s_uiDispCount == 0 ) SLsmg_refresh(); } @@ -460,7 +464,7 @@ int hb_gt_RectSize( USHORT rows, USHORT cols ) void hb_gt_GetText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyDst ) { int Cols; - SLsmg_Char_Type *pBuf = (SLsmg_Char_Type *)pbyDst; + SLsmg_Char_Type * pBuf = ( SLsmg_Char_Type * ) pbyDst; HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbyDst)); @@ -477,7 +481,7 @@ void hb_gt_GetText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight void hb_gt_PutText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbySrc ) { int Cols; - SLsmg_Char_Type *pBuf = (SLsmg_Char_Type *)pbySrc; + SLsmg_Char_Type * pBuf = ( SLsmg_Char_Type * ) pbySrc; HB_TRACE(HB_TR_DEBUG, ("hb_gt_PutText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbySrc)); @@ -486,11 +490,11 @@ void hb_gt_PutText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight { SLsmg_gotorc( uiTop, uiLeft ); SLsmg_write_raw( pBuf, Cols ); - pBuf +=Cols; + pBuf += Cols; ++uiTop; } - if( uiDispCount == 0 ) + if( s_uiDispCount == 0 ) SLsmg_refresh(); } @@ -506,7 +510,7 @@ void hb_gt_SetAttribute( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT ui /* note we are clearing a high bit of color */ SLsmg_set_color_in_region( byAttr & 0x7F, uiTop, uiLeft, Rows, Cols ); - if( uiDispCount == 0 ) + if( s_uiDispCount == 0 ) SLsmg_refresh(); } @@ -570,7 +574,7 @@ void hb_gt_Scroll( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight, hb_gtSetPos( usSaveRow, usSaveCol ); - if( uiDispCount == 0 ) + if( s_uiDispCount == 0 ) SLsmg_refresh(); } } @@ -579,14 +583,14 @@ void hb_gt_DispBegin( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_DispBegin()")); - ++uiDispCount; + ++s_uiDispCount; } void hb_gt_DispEnd() { HB_TRACE(HB_TR_DEBUG, ("hb_gt_DispEnd()")); - if ( --uiDispCount == 0) + if( --s_uiDispCount == 0 ) SLsmg_refresh(); } @@ -636,38 +640,38 @@ char * hb_gt_Version( void ) USHORT hb_gt_DispCount() { - return uiDispCount; + return s_uiDispCount; } void hb_gt_Replicate( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar, ULONG ulLen ) { ULONG i; - SLsmg_Char_Type SLchar, *pScr; + SLsmg_Char_Type SLchar, * pScr; HB_TRACE(HB_TR_DEBUG, ("hb_gt_Replicate(%hu, %hu, %i, %i, %lu)", uiRow, uiCol, byAttr, byChar, nLength)); - pScr = (SLsmg_Char_Type *)hb_xgrab( (ulLen+1) * sizeof( SLsmg_Char_Type ) ); + pScr = ( SLsmg_Char_Type * ) hb_xgrab( ( ulLen + 1 ) * sizeof( SLsmg_Char_Type ) ); - for ( i=0; i 127 ) + if( byChar > 127 ) SLchar |= 0x8000; - *(pScr+i) = SLchar; + *( pScr + i ) = SLchar; } - SLsmg_gotorc(uiRow, uiCol); + SLsmg_gotorc( uiRow, uiCol ); - if ( ulLen > 0 ) + if( ulLen > 0 ) SLsmg_write_raw( pScr, ulLen ); - hb_xfree( (BYTE *)pScr ); + hb_xfree( ( BYTE * ) pScr ); - if( uiDispCount == 0 ) + if( s_uiDispCount == 0 ) SLsmg_refresh(); } @@ -837,61 +841,60 @@ static void hb_gt_build_conv_tabs() some problems. */ /* init colors */ - for( i=0; i<256; i++ ) + for( i = 0; i < 256; i++ ) { - fg = ( i & 0x0F ); - bg = ( i >> 4 ) & 0x07; /* bit 7 is a blinking attribute - not used here */ + fg = ( i & 0x0F ); + bg = ( i >> 4 ) & 0x07; /* bit 7 is a blinking attribute - not used here */ - SLtt_set_color ( i, (char *)NULL, colorNames[fg], colorNames[bg] ); + SLtt_set_color( i, ( char * ) NULL, s_colorNames[ fg ], s_colorNames[ bg ] ); } /* build alternate chars table */ - for ( i=0; i<32; i++ ) + for( i = 0; i < 32; i++ ) /* under Unix control-chars are not visible in a general meaning */ - convHighChars[ i ] = '.'; - for ( i=32; i<256; i++ ) - convHighChars[ i ] = i; - + s_convHighChars[ i ] = '.'; + for( i = 32; i < 256; i++ ) + s_convHighChars[ i ] = i; #ifndef IBMPC_SYSTEM /* init an alternate chars table */ - if ( ( p = SLtt_Graphics_Char_Pairs ) ) + if( ( p = SLtt_Graphics_Char_Pairs ) ) { len = strlen( p ); - for ( i=0; i + #include #else -# include + #include #endif #include #ifdef M_UNIX -# include -# include + #include + #include #endif #ifndef IBMPC_SYSTEM -# include /* we're assuming target has termios - should be better done */ + #include /* we're assuming target has termios - should be better done */ #endif #include "hbapigt.h" @@ -56,9 +60,9 @@ /* abort key is Ctrl+C on Unix (arbitrary chosen), on Dos it works as Alt+C (strange !) */ #ifdef OS_UNIX_COMPATIBLE -# define CTRL_C 3 + #define CTRL_C 3 #else -# define CTRL_C 46 + #define CTRL_C 46 #endif #define HB_GT_ABORT_KEY CTRL_C @@ -68,24 +72,24 @@ /* keyboard states - these should be taken from system includes, not be hard coded */ -#if defined(__linux__) -# define SHIFT_PRESSED 1 -# define ALTR_PRESSED 2 -# define CONTROL_PRESSED 4 -# define ALTL_PRESSED 8 -# define ALT_PRESSED (ALTL_PRESSED || ALTR_PRESSED) +#ifdefined(__linux__) + #define SHIFT_PRESSED 1 + #define ALTR_PRESSED 2 + #define CONTROL_PRESSED 4 + #define ALTL_PRESSED 8 + #define ALT_PRESSED (ALTL_PRESSED || ALTR_PRESSED) #elif defined(M_UNIX) /* SCO */ -# define SHIFT_PRESSED 1 -# define ALTR_PRESSED 8 -# define CONTROL_PRESSED 2 -# define ALTL_PRESSED 4 -# define ALT_PRESSED (ALTL_PRESSED || ALTR_PRESSED) + #define SHIFT_PRESSED 1 + #define ALTR_PRESSED 8 + #define CONTROL_PRESSED 2 + #define ALTL_PRESSED 4 + #define ALT_PRESSED (ALTL_PRESSED || ALTR_PRESSED) #else /* we don't know how to do this */ -# define SHIFT_PRESSED 0 -# define ALTR_PRESSED 0 -# define CONTROL_PRESSED 0 -# define ALTL_PRESSED 0 -# define ALT_PRESSED (ALTL_PRESSED || ALTR_PRESSED) + #define SHIFT_PRESSED 0 + #define ALTR_PRESSED 0 + #define CONTROL_PRESSED 0 + #define ALTL_PRESSED 0 + #define ALT_PRESSED (ALTL_PRESSED || ALTR_PRESSED) #endif /* extra keysyms definitions */ @@ -94,10 +98,10 @@ #define SL_KEY_ALT_L( ch ) ( SL_KEY_MAX + ( ( unsigned int )ch ) ) /* indicates that screen size has changed */ -extern int Screen_Size_Changed; +extern BOOL hb_gt_sln_bScreen_Size_Changed; -static int linuxConsole = 0; -static int underXTerm = 0; +static BOOL s_linuxConsole = FALSE; +static BOOL s_underXTerm = FALSE; int hb_gt_Kbd_State(); @@ -116,38 +120,38 @@ static void hb_gt_Init_KeyTranslat() keyname[ 3 ] = 0; /* define Shft/Ctrl/Alt+Fn on DOS - these are hard coded in Slang */ - for ( ch = 0x54; ch <= 0x71; ch++ ) + for( ch = 0x54; ch <= 0x71; ch++ ) { - keyname[ 2 ] = ch; - SLkp_define_keysym( keyname, SL_KEY_F(keynum) ); - keynum++; + keyname[ 2 ] = ch; + SLkp_define_keysym( keyname, SL_KEY_F(keynum) ); + keynum++; } /* define Alt+Key on DOS - these are hard coded in Slang */ i = 0; - while ( i < sizeof( transDosScanCodeTab ) ) + while( i < sizeof( transDosScanCodeTab ) ) { - i++; - if ( transDosScanCodeTab[i] < 32 ) - { - keyname[ 2 ] = '^'; - keyname[ 3 ] = transDosScanCodeTab[i]+'A'-1; - keyname[ 4 ] = 0; - } + i++; + if( transDosScanCodeTab[i] < 32 ) + { + keyname[ 2 ] = '^'; + keyname[ 3 ] = transDosScanCodeTab[i]+'A'-1; + keyname[ 4 ] = 0; + } /* - else if ( transDosScanCodeTab[i] >= 127 ) - { - sprintf( &keyname[ 2 ], "\\x%02X", transDosScanCodeTab[i] ); - keyname[ 6 ] = 0; - } + else if( transDosScanCodeTab[i] >= 127 ) + { + sprintf( &keyname[ 2 ], "\\x%02X", transDosScanCodeTab[i] ); + keyname[ 6 ] = 0; + } */ - else - { - keyname[ 2 ] = transDosScanCodeTab[i]; - keyname[ 3 ] = 0; - } - SLkp_define_keysym( keyname, SL_KEY_ALT_L( transDosScanCodeTab[i-1] ) ); - i++; + else + { + keyname[ 2 ] = transDosScanCodeTab[i]; + keyname[ 3 ] = 0; + } + SLkp_define_keysym( keyname, SL_KEY_ALT_L( transDosScanCodeTab[i-1] ) ); + i++; } #else @@ -171,21 +175,23 @@ static void hb_gt_Init_KeyTranslat() /* Shft & Ctrl FKeys definition takes place in two phases : from '1' to '9' and from 'A' to 'K' */ - for ( i=1; i<=2; i++ ) - for ( ch = ( i==1 ? '1' : 'A' ); ch <= ( i==1 ? '9' : 'K' ); ch++ ) + for( i=1; i<=2; i++ ) + { + for( ch = ( i==1 ? '1' : 'A' ); ch <= ( i==1 ? '9' : 'K' ); ch++ ) { keyname[ 1 ] = ch; keyseq = SLtt_tgetstr( keyname ); - if ( (keyseq != NULL) && (keyseq[0] != 0) ) + if( (keyseq != NULL) && (keyseq[0] != 0) ) { - if ( (keyseq != NULL) && (keyseq[0] != 0) ) + if( (keyseq != NULL) && (keyseq[0] != 0) ) SLkp_define_keysym( keyseq, SL_KEY_F(keynum) ); } keynum++; } + } /* if we are on linux console pressing Alt generates ^[ before sequence */ - if ( linuxConsole || underXTerm ) + if( s_linuxConsole || s_underXTerm ) { keyname[ 0 ] = 033; keyname[ 2 ] = 0; @@ -193,19 +199,21 @@ static void hb_gt_Init_KeyTranslat() /* Alt+Letter & Alt+digit definition takes place in two phases : from '0' to '9' and from 'A' to 'Z' */ - for ( i=1; i<=2; i++ ) - for ( ch = ( i==1 ? '0' : 'A' ); ch <= ( i==1 ? '9' : 'Z' ); ch++ ) + for( i=1; i<=2; i++ ) + { + for( ch = ( i==1 ? '0' : 'A' ); ch <= ( i==1 ? '9' : 'Z' ); ch++ ) { keyname[ 1 ] = ch; /* QUESTION: why Slang reports error for defining Alt+O ???. Have I any error in key definitiions ??? */ - if ( ch != 'O' ) + if( ch != 'O' ) SLkp_define_keysym( keyname, SL_KEY_ALT_L( ch ) ); keyname[ 1 ] = (ch+' '); SLkp_define_keysym( keyname, SL_KEY_ALT_L( ch+' ' ) ); } + } } #endif } @@ -218,17 +226,17 @@ int hb_gt_Init_Terminal(int phase) int ret = 0; /* Ctrl-C to abort, no flow-control, no output processing */ - if ( SLang_init_tty(HB_GT_ABORT_KEY, 0, 0) != (-1) ) + if( SLang_init_tty(HB_GT_ABORT_KEY, 0, 0) != (-1) ) { #ifndef IBMPC_SYSTEM /* do missing disable of start/stop processing */ - if ( tcgetattr( SLang_TT_Read_FD, &newTTY ) == 0 ) + if( tcgetattr( SLang_TT_Read_FD, &newTTY ) == 0 ) { newTTY.c_cc[VSTOP] = 255; /* disable ^S start/stop processing */ newTTY.c_cc[VSTART] = 255; /* disable ^Q start/stop processing */ newTTY.c_cc[VSUSP] = 255; /* disable ^Z suspend processing */ - if ( tcsetattr( SLang_TT_Read_FD, TCSADRAIN, &newTTY ) == 0 ) + if( tcsetattr( SLang_TT_Read_FD, TCSADRAIN, &newTTY ) == 0 ) /* everything looks ok so far */ #endif ret = 1; @@ -240,18 +248,18 @@ int hb_gt_Init_Terminal(int phase) /* first time init phase - we don't want this after return from system command ( see run.c ) */ - if ( ret && (phase == 0) ) + if( ret && (phase == 0) ) { /* an uncertain way to check if we run under linux console */ - linuxConsole = ( !strncmp ( getenv("TERM"), "linux", 5 ) ); + s_linuxConsole = ( !strncmp ( getenv("TERM"), "linux", 5 ) ); /* an uncertain way to check if we run under xterm */ - underXTerm = ( strstr( getenv("TERM"), "xterm" ) != NULL ); + s_underXTerm = ( strstr( getenv("TERM"), "xterm" ) != NULL ); /* define keyboard translations */ hb_gt_Init_KeyTranslat(); } - return ( ret ); + return ret; } #undef DO_LOCAL_DEBUG @@ -268,22 +276,22 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask ) HB_SYMBOL_UNUSED( eventmask ); /* user AbortKey break */ - if ( SLKeyBoard_Quit == 1 ) + if( SLKeyBoard_Quit == 1 ) return HB_BREAK_FLAG; /* has screen size changed ? */ - if (Screen_Size_Changed) + if( hb_gt_sln_bScreen_Size_Changed ) { - Screen_Size_Changed = 0; + hb_gt_sln_bScreen_Size_Changed = FALSE; SLtt_get_screen_size(); #if SLANG_VERSION > 10202 SLsmg_reinit_smg(); #endif /* TODO: we need here some kind of screen redrawing */ - //SLsmg_refresh (); + /*SLsmg_refresh ();*/ } - if ( SLang_input_pending( 0 ) > 0 ) + if( SLang_input_pending( 0 ) > 0 ) { kbdflags = hb_gt_Kbd_State(); @@ -294,10 +302,10 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask ) */ ch = SLang_getkey (); - if (ch == 033) /* escape */ + if( ch == 033 ) /* escape */ { - if (0 == SLang_input_pending (ESC_TIMEOUT)) - return 033; + if( 0 == SLang_input_pending (ESC_TIMEOUT) ) + return 033; } SLang_ungetkey (ch); @@ -306,7 +314,7 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask ) ch = SLkp_getkey(); - if ( ch != SL_KEY_ERR ) + if( ch != SL_KEY_ERR ) { int i; @@ -318,124 +326,125 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask ) #endif /* user AbortKey break */ - if ( ch == HB_GT_ABORT_KEY ) - return ( HB_BREAK_FLAG ); + if( ch == HB_GT_ABORT_KEY ) + return HB_BREAK_FLAG; - if ( ch < 32 ) /* control characters - simply return */ - return ( ch ); + if( ch < 32 ) /* control characters - simply return */ + return ch; - else if ( ( ch >= 32 ) && ( ch < 256 ) )/* normal characters ? */ + else if( ( ch >= 32 ) && ( ch < 256 ) )/* normal characters ? */ { - if ( kbdflags & ALT_PRESSED ) + if( kbdflags & ALT_PRESSED ) { /* lower to upper case */ - if ( (ch >= 'a') && (ch <= 'z') ) + if( (ch >= 'a') && (ch <= 'z') ) ch -= ' '; /* alt + letter */ - if ( (ch >= 'A') && (ch <= 'Z') ) + if( (ch >= 'A') && (ch <= 'Z') ) /* returned value is next in a table */ - return ( transAltKeyLetterTab[ (ch-'A')*2+1 ] ); + return transAltKeyLetterTab[ (ch-'A')*2+1 ]; /* alt + digit */ if ( (ch >= '0') && (ch <= '9') ) /* returned value is next in a table */ - return ( transAltKeyDigitTab[ (ch-'0')*2+1 ] ); + return transAltKeyDigitTab[ (ch-'0')*2+1 ]; } - return ( ch ); + return ch; } /* standard Slang keys */ - else if ( ( ch >= 256 ) && ( ch <= SL_KEY_ESC ) ) + else if( ( ch >= 256 ) && ( ch <= SL_KEY_ESC ) ) { for( i = 0; i < ( sizeof( transKeyFunTab ) / sizeof( int ) ); i++ ) + { if( transKeyFunTab[ i++ ] == ch ) - return ( transKeyFunTab[ i ] ); + return transKeyFunTab[ i ]; + } } /* Linux/Dos Alt+A-Z keys */ - else if ( ( ch >= SL_KEY_ALT_L( 'A' ) ) && ( ch <= SL_KEY_ALT_L( 'Z' ) ) ) + else if( ( ch >= SL_KEY_ALT_L( 'A' ) ) && ( ch <= SL_KEY_ALT_L( 'Z' ) ) ) /* returned value is next in a table */ - return ( transAltKeyLetterTab[ (ch-SL_KEY_MAX-'A')*2+1 ] ); + return transAltKeyLetterTab[ (ch-SL_KEY_MAX-'A')*2+1 ]; /* Linux Alt+a-z keys - lower to upper conersion */ - else if ( ( ch >= SL_KEY_ALT_L( 'a' ) ) && ( ch <= SL_KEY_ALT_L( 'z' ) ) ) + else if( ( ch >= SL_KEY_ALT_L( 'a' ) ) && ( ch <= SL_KEY_ALT_L( 'z' ) ) ) /* returned value is next in a table */ - return ( transAltKeyLetterTab[ (ch-SL_KEY_MAX-(' ')-('A'))*2+1 ] ); + return transAltKeyLetterTab[ (ch-SL_KEY_MAX-(' ')-('A'))*2+1 ]; /* Linux/Dos Alt+0-9 keys */ - else if ( ( ch >= SL_KEY_ALT_L( '0' ) ) && ( ch <= SL_KEY_ALT_L( '9' ) ) ) + else if( ( ch >= SL_KEY_ALT_L( '0' ) ) && ( ch <= SL_KEY_ALT_L( '9' ) ) ) /* returned value is next in a table */ - return ( transAltKeyDigitTab[ (ch-SL_KEY_MAX-'0')*2+1 ] ); + return transAltKeyDigitTab[ (ch-SL_KEY_MAX-'0')*2+1 ]; - return (ch); + return ch; } } - return (0); + return 0; } static int hb_gt_try_get_Kbd_State() { #if defined(__linux__) - unsigned char modifiers = 6; + unsigned char modifiers = 6; - if (ioctl (0, TIOCLINUX, &modifiers) < 0) - return 0; + if( ioctl (0, TIOCLINUX, &modifiers) < 0 ) + return 0; - return (int) modifiers; + return ( int ) modifiers; #elif defined(M_UNIX) int modifiers = 0; int IOcommand = 0; - if (ioctl(0, TCGETSC, &modifiers) >= 0) + if( ioctl(0, TCGETSC, &modifiers) >= 0 ) { - if (modifiers == KB_XSCANCODE) + if( modifiers == KB_XSCANCODE ) { IOcommand = KB_ISSCANCODE; - if (ioctl(0, TCSETSC, &IOcommand) >= 0) + if( ioctl(0, TCSETSC, &IOcommand) >= 0 ) { - if (ioctl(0, KDGKBSTATE, &modifiers) < 0) + if( ioctl(0, KDGKBSTATE, &modifiers) < 0 ) modifiers = 0; } else modifiers = 0; IOcommand = KB_XSCANCODE; - if (ioctl(0, TCSETSC, &IOcommand) < 0) + if( ioctl(0, TCSETSC, &IOcommand) < 0 ) modifiers = 0; } - else - if (ioctl(0, KDGKBSTATE, &modifiers) < 0) - modifiers = 0; + else if( ioctl(0, KDGKBSTATE, &modifiers) < 0 ) + modifiers = 0; return modifiers; } #endif - return (int)0; + return 0; } int hb_gt_Shft_Pressed() { - return( (hb_gt_try_get_Kbd_State() & SHIFT_PRESSED) != 0 ); + return (hb_gt_try_get_Kbd_State() & SHIFT_PRESSED) != 0; } int hb_gt_Ctrl_Pressed() { - return( (hb_gt_try_get_Kbd_State() & CONTROL_PRESSED) != 0 ); + return (hb_gt_try_get_Kbd_State() & CONTROL_PRESSED) != 0; } int hb_gt_Alt_Pressed() { - return( (hb_gt_try_get_Kbd_State() & ALT_PRESSED) != 0 ); + return (hb_gt_try_get_Kbd_State() & ALT_PRESSED) != 0; } int hb_gt_Kbd_State() { - return ( hb_gt_try_get_Kbd_State() ); + return hb_gt_try_get_Kbd_State(); } diff --git a/harbour/source/rtl/gtsln/keytrans.c b/harbour/source/rtl/gtsln/keytrans.c index 0d526e00c0..2af34e18b2 100644 --- a/harbour/source/rtl/gtsln/keytrans.c +++ b/harbour/source/rtl/gtsln/keytrans.c @@ -1,3 +1,7 @@ +/* + * $Id$ + */ + /* * Harbour Project source code: * Video subsystem based on Slang screen library.