2001-07-01 21:20 GMT+3 Alexander Kresin <alex@belacy.belgorod.su>

This commit is contained in:
Alexander S.Kresin
2001-04-07 17:30:59 +00:00
parent f4a6e32259
commit 03c9010517
5 changed files with 187 additions and 142 deletions

View File

@@ -1,3 +1,13 @@
2001-07-01 21:20 GMT+3 Alexander Kresin <alex@belacy.belgorod.su>
Changes, provided by Marek Paliwoda.
*doc/en/gtslang.txt
*source/rtl/gtsln/gtsln.c
*source/rtl/gtsln/kbsln.c
*source/rtl/gtsln/keytrans.c
! Fixed a bug with processing '.' key
* Added support for an Alt emulation using Meta key (which is
an ESC key as in most Linux applications).
2001-04-04 01:20 UTC-0800 Brian Hays <bhays@abacuslaw.com>
* source/vm/dynsym.c
* added test for spaces to hb_dynsymFindName so

View File

@@ -194,10 +194,10 @@ Here is a (probably not complete) list of them :
although they work on a textmode Linux console. This is a very big
problem and at least any solution should be developed to emulate this.
One attempt is a Dead key workaround I've implemented for national
characters
characters and a Meta key for simulate Alt key. By default as a Meta
key I've chosen ESC key pressed once.
- abort key is CTRL+C not ALT+C on Unixes, although it still is ALT+C
on Linux text console
- abort key is CTRL+\ not CTRL+BREAK on Unixes
- to get an ESC key you have to press ESC twice. This is an issue
related to OS behavior where ESC begins a control sequence

View File

@@ -91,7 +91,7 @@ static BOOL s_bSuspended = FALSE;
/* to convert high characters (mostly graphics, nation and control chars) */
static SLsmg_Char_Type s_convHighChars[ 256 ];
/* bit indication if char is a nation char - assums char is 8-bit */
/* bit indication if char is a nation char - assumes char is 8-bit */
static unsigned char s_IsNationChar[ 128 / 8 ];
/* to convert colors to Clipper mode */
@@ -157,13 +157,13 @@ void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
/* do not indicate USER_BREAK in SLang_Error - ??? */
SLang_Ignore_User_Abort = 1;
/* default abort procesing */
/* no default abort procesing */
SLang_set_abort_signal( NULL );
/* NOTE: this is incompatible with CLIPPER
but under Unix we should assume cursor is
visible on startup because we cannot figure
out a current cursor state
out a current cursor state
*/
/* turn on a cursor visibility */
if( SLtt_set_cursor_visibility( 1 ) == -1 )
@@ -225,7 +225,7 @@ void hb_gt_Exit( void )
hb_mouse_Exit();
/* NOTE: This is incompatible with Clipper
- on exit leave a cursor visible */
- on exit leave a cursor visible */
if( s_sCursorStyle != SC_UNAVAIL )
hb_gt_SetCursorStyle( SC_NORMAL );
@@ -378,6 +378,7 @@ void hb_gt_SetCursorStyle( USHORT uiStyle )
s_sCursorStyle = uiStyle;
SLtt_set_cursor_visibility( s_sCursorStyle != SC_NONE );
#ifdef __linux__
/* NOTE: cursor apearence works only under linux console */
if( s_linuxConsole )
{
@@ -411,6 +412,7 @@ void hb_gt_SetCursorStyle( USHORT uiStyle )
if( s_uiDispCount == 0 )
SLsmg_refresh();
}
#endif
}
}
@@ -435,7 +437,7 @@ static void hb_gt_xPutch( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar )
Pos = ( unsigned char ) ( ( byChar & 0x7F ) >> 3 );
Mask = ( unsigned char ) ( 1 << ( byChar & 0x07 ) );
/* this hack turns on Normal Char Set when we should draw nation char. */
/* this hack turns on Normal Char Set when we should draw a nation char. */
/* build a Slang converted char - note we are clearing a high bit of color */
if( s_bUse_Alt_Char_Hack || !( s_IsNationChar[ Pos ] & Mask ) )
SLchar = s_convHighChars[ byChar ] | ( SLsmg_Char_Type )( ( ( (int)byAttr + SLANG_RESERVED_COLORS ) & 0x7F ) << 8 );
@@ -467,7 +469,7 @@ void hb_gt_Puts( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE * pbyStr, ULONG u
Pos = ( unsigned char ) ( ( byChar & 0x7F ) >> 3 );
Mask = ( unsigned char ) ( 1 << ( byChar & 0x07 ) );
/* this hack turns on Normal Char Set when we should draw nation char. */
/* this hack turns on Normal Char Set when we should draw a nation char. */
/* build a Slang converted char - note we are clearing a high bit of color */
if( s_bUse_Alt_Char_Hack || !( s_IsNationChar[ Pos ] & Mask ) )
SLchar = s_convHighChars[ byChar ] | ( SLsmg_Char_Type )( ( ( (int)byAttr + SLANG_RESERVED_COLORS ) & 0x7F ) << 8 );
@@ -723,7 +725,7 @@ void hb_gt_Replicate( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar, ULON
Pos = ( unsigned char ) ( ( byChar & 0x7F ) >> 3 );
Mask = ( unsigned char ) ( 1 << ( byChar & 0x07 ) );
/* this hack turns on Normal Char Set when we should draw nation char. */
/* this hack turns on Normal Char Set when we should draw a nation char. */
/* build a Slang converted char - note we are clearing a high bit of color */
if( s_bUse_Alt_Char_Hack || !( s_IsNationChar[ Pos ] & Mask ) )
SLchar = s_convHighChars[ byChar ] | ( SLsmg_Char_Type )( ( ( (int)byAttr + SLANG_RESERVED_COLORS ) & 0x7F ) << 8 );
@@ -979,7 +981,7 @@ static void hb_gt_build_conv_tabs()
SLtt_set_color( 0, ( char * ) NULL, s_colorNames[ 7 ], s_colorNames[ 0 ] );
SLtt_set_color( 1, ( char * ) NULL, s_colorNames[ 0 ], s_colorNames[ 7 ] );
/* build an conversion chars table */
/* build a conversion chars table */
for( i = 0; i < 32; i++ )
/* under Unix control-chars are not visible in a general meaning */
s_convHighChars[ i ] = ( SLsmg_Char_Type ) '.';
@@ -1028,24 +1030,24 @@ static void hb_gt_build_conv_tabs()
case SLSMG_BULLET_CHAR : s_convHighChars[ ] = SLch; break;
*/
#if SLANG_VERSION > 10400
case SLSMG_DIAMOND_CHAR : s_convHighChars[ 04 ] = SLch;
case SLSMG_DIAMOND_CHAR : s_convHighChars[ 04 ] = SLch;
break;
case SLSMG_LARROW_CHAR : s_convHighChars[ 17 ] = SLch;
s_convHighChars[ 27 ] = SLch;
break;
s_convHighChars[ 27 ] = SLch;
break;
case SLSMG_RARROW_CHAR : s_convHighChars[ 16 ] = SLch;
s_convHighChars[ 26 ] = SLch;
break;
break;
case SLSMG_DARROW_CHAR : s_convHighChars[ 25 ] = SLch;
s_convHighChars[ 31 ] = SLch;
s_convHighChars[ 31 ] = SLch;
break;
case SLSMG_UARROW_CHAR : s_convHighChars[ 24 ] = SLch;
s_convHighChars[ 30 ] = SLch;
s_convHighChars[ 30 ] = SLch;
break;
#endif
case SLSMG_BOARD_CHAR : s_convHighChars[ 178 ] = SLch;
case SLSMG_BOARD_CHAR : s_convHighChars[ 178 ] = SLch;
break;
case SLSMG_BLOCK_CHAR : s_convHighChars[ 219 ] = SLch;
case SLSMG_BLOCK_CHAR : s_convHighChars[ 219 ] = SLch;
break;
}
@@ -1105,7 +1107,7 @@ static void hb_gt_build_conv_tabs()
s_IsNationChar[ Pos ] |= Mask;
++p;
}
/*
/*
for( i=0; i <= ( ( int ) s_convKDeadKeys[ 0 ] ) * 2; i++ )
fprintf( stderr, "%3d %c\r\n", i, s_convKDeadKeys[ i ] );
ch=getc( stdin );

View File

@@ -82,13 +82,14 @@
( ( SHIFT_PRESSED | CONTROL_PRESSED | ALTL_PRESSED ) << 16 )
/* extra keysyms definitions */
#define SL_KEY_NUM_5 SL_KEY_B2 /* this is checked explicitly */
#define SL_KEY_MAX ( ( unsigned int ) 0x1000 )
#define SL_KEY_ESC ( SL_KEY_MAX + 1 )
#define SL_KEY_NUM_5 SL_KEY_B2 /* this is checked explicitly */
#define SL_KEY_MAX ( ( unsigned int ) 0x1000 )
#define SL_KEY_ESC ( SL_KEY_MAX + 1 )
#define SL_KEY_ALT( ch ) ( SL_KEY_MAX + ( ( unsigned int ) ch ) )
/* abort key is Ctrl+C on Unix ( but Alt+C on Linux console ) */
static int s_hb_gt_Abort_Key = K_CTRL_C;
/* we choose Ctrl+\ as an abort key on Unixes where it is a SIGQUIT key by default */
/* abort key is Ctrl+\ on Unix ( but Ctrl+@ on Linux console ) */
static int s_hb_gt_Abort_key = 28;
/* *********************************************************************** */
@@ -115,13 +116,20 @@ int hb_gt_Kbd_State();
/* *********************************************************************** */
static void hb_gt_Init_KeyTranslat()
static void hb_gt_Init_KeyTranslations()
{
char ch, keyname[ SLANG_MAX_KEYMAP_KEY_SEQ + 1 ];
int keynum, i;
char * keyseq;
/* for defining ^[<Key> sequences - this simulates Alt+Keys */
char AltChars[][ 2 ] =
{
{ '0', '9' },
{ 'A', 'Z' },
{ 'a', 'z' }
};
/* on Unix systems ESC is a special key so let
assume ESC is a doble pressed ESC key */
SLkp_define_keysym( "^[^[", SL_KEY_ESC );
@@ -148,38 +156,31 @@ static void hb_gt_Init_KeyTranslat()
}
}
/* if we are on linux console pressing Alt generates ^[ before sequence */
if( s_linuxConsole || s_underXTerm )
/* We assume Esc key is a Meta key which is treated as an Alt key.
Also pressing Alt+Key on linux console and xterm gives the same
key sequences so we are happy */
keyname[ 0 ] = 033;
keyname[ 2 ] = 0;
/* Alt+Letter & Alt+digit definition takes place in three phases :
from '0' to '9', from 'A' to 'Z' and from 'a' to 'z' */
for( i = 0; i < 3; i++ )
{
char AltChars[][ 2 ] =
for( ch = AltChars[ i ][ 0 ]; ch <= AltChars[ i ][ 1 ]; ch++ )
{
{ '0', '9' },
{ 'A', 'Z' },
{ 'a', 'z' }
};
/* fprintf( stderr, "%d %c\n", i, ch ); */
keyname[ 1 ] = ch;
keyname[ 0 ] = 033;
keyname[ 2 ] = 0;
/* Alt+Letter & Alt+digit definition takes place in three phases :
from '0' to '9', from 'A' to 'Z' and from 'a' to 'z' */
for( i = 0; i < 3; i++ )
{
for( ch = AltChars[ i ][ 0 ]; ch <= AltChars[ i ][ 1 ]; ch++ )
{
/* fprintf( stderr, "%d %c\n", i, ch ); */
keyname[ 1 ] = ch;
/* QUESTION: why Slang reports error for defining Alt+O ???.
Have I any error in key definitiions ??? */
if( ch != 'O' )
SLkp_define_keysym( keyname, SL_KEY_ALT( ch ) );
}
/* QUESTION: why Slang reports error for defining Alt+O ???.
Have I any hidden error in key definitiions ??? */
if( ch != 'O' )
SLkp_define_keysym( keyname, SL_KEY_ALT( ch ) );
}
/* five on numeric console */
/* SLkp_define_keysym( "^[[G", SL_KEY_NUM_5 ); */
}
/* five on numeric console */
/* SLkp_define_keysym( "^[[G", SL_KEY_NUM_5 ); */
}
/* *********************************************************************** */
@@ -190,6 +191,8 @@ int hb_gt_Init_Terminal( int phase )
unsigned char *p;
int ret = 0;
/* first time init phase - we don't want this after
return from system command ( see run.c ) */
if( phase == 0 )
{
/* an uncertain way to check if we run under linux console */
@@ -197,9 +200,11 @@ int hb_gt_Init_Terminal( int phase )
/* an uncertain way to check if we run under linux xterm */
s_underXTerm = ( strstr( getenv( "TERM" ), "xterm" ) != NULL );
/* for Linux console and for Linux xterm */
if( s_linuxConsole || s_underXTerm )
s_hb_gt_Abort_Key = K_ALT_C;
#ifdef __linux__
/* for Linux console */
if( s_linuxConsole )
s_hb_gt_Abort_key = 0;
#endif
/* get Dead key definition */
if( ( p = getenv( hb_DeadKeyEnvName ) ) )
@@ -208,10 +213,13 @@ int hb_gt_Init_Terminal( int phase )
if( len > 0 )
hb_DeadKey = ( int ) *p;
}
/* number of keys dealing with a Dead key */
s_convKDeadKeys[ 0 ] = 0;
}
/* Ctrl-C to abort, no flow-control, no output processing */
if( SLang_init_tty( s_hb_gt_Abort_Key, 0, 0 ) != -1 )
/* Ctrl+\ to abort, no flow-control, no output processing */
if( SLang_init_tty( s_hb_gt_Abort_key, 0, 0 ) != -1 )
{
/* do missing disable of start/stop processing */
if( tcgetattr( SLang_TT_Read_FD, &newTTY ) == 0 )
@@ -219,6 +227,8 @@ int hb_gt_Init_Terminal( int phase )
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 */
/* already done in Slang */
/* newTTY.c_cc[ VDSUSP ] = 255; */ /* disable ^Y delayed suspend processing */
if( tcsetattr( SLang_TT_Read_FD, TCSADRAIN, &newTTY ) == 0 )
/* everything looks ok so far */
@@ -231,9 +241,9 @@ int hb_gt_Init_Terminal( int phase )
if( ret && ( phase == 0 ) )
{
/* define keyboard translations */
hb_gt_Init_KeyTranslat();
hb_gt_Init_KeyTranslations();
/* for binary search of key translations */
hb_gt_SortKeyTrans();
hb_gt_SortKeyTranslationTable();
}
return ret;
@@ -280,6 +290,31 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
kbdflags = 0;
#endif
#if 1
/* ------- one key ESC handling ----------------- */
/* NOTE: This will probably not work on slow terminals
or on very busy lines (i.e. modem lines )
I plan to remove it. */
ch = SLang_getkey();
#ifdef DO_LOCAL_DEBUG
hb_gtGetPos( &savy, &savx );
SLsmg_gotorc( 23, 40 );
SLsmg_printf( " %8x %d ", ch, kbdflags );
SLsmg_gotorc( savy, savx );
#endif
if( ch == 033 ) /* escape */
if( 0 == SLang_input_pending( 10 ) )
return( 0 );
/* user AbortKey break */
if( ch == s_hb_gt_Abort_key )
return HB_BREAK_FLAG;
SLang_ungetkey( ch );
/* ------------------------------------------------- */
#endif
ch = SLkp_getkey();
if( ch != SL_KEY_ERR )
@@ -292,10 +327,6 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
SLsmg_printf( " %8x %d ", ch, kbdflags );
SLsmg_gotorc( savy, savx );
#endif
/* user AbortKey break */
if( ch == s_hb_gt_Abort_Key )
return HB_BREAK_FLAG;
/* Dead key handling */
if( InDeadState )
{
@@ -317,10 +348,10 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
/* any special key ? */
if( ( tmp = ( ch | ( kbdflags << 16 ) ) ) > 256 )
{
tmp = hb_gt_FindKeyTrans( tmp );
tmp = hb_gt_FindKeyTranslation( tmp );
if( tmp == 0 )
{
tmp = hb_gt_FindKeyTrans( ch );
tmp = hb_gt_FindKeyTranslation( ch );
/* TOFIX: this can generate problems with values returned */
if( tmp == 0 && ch < 256 ) tmp = ch;
}

View File

@@ -41,7 +41,7 @@
/* *********************************************************************** */
/* a table of keys translation */
static int KeyTrans[][ 2 ] =
static int KeyTranslationTable[][ 2 ] =
{
{ SL_KEY_UP, K_UP },
{ SL_KEY_DOWN, K_DOWN },
@@ -115,50 +115,6 @@ static int KeyTrans[][ 2 ] =
{ K_TAB | ( SHIFT_PRESSED << 16 ), K_SH_TAB },
#endif
{ SL_KEY_F(1), K_F1 },
{ SL_KEY_F(2), K_F2 },
{ SL_KEY_F(3), K_F3 },
{ SL_KEY_F(4), K_F4 },
{ SL_KEY_F(5), K_F5 },
{ SL_KEY_F(6), K_F6 },
{ SL_KEY_F(7), K_F7 },
{ SL_KEY_F(8), K_F8 },
{ SL_KEY_F(9), K_F9 },
{ SL_KEY_F(10), K_F10 },
{ SL_KEY_F(11), K_SH_F1 },
{ SL_KEY_F(12), K_SH_F2 },
{ SL_KEY_F(13), K_SH_F3 },
{ SL_KEY_F(14), K_SH_F4 },
{ SL_KEY_F(15), K_SH_F5 },
{ SL_KEY_F(16), K_SH_F6 },
{ SL_KEY_F(17), K_SH_F7 },
{ SL_KEY_F(18), K_SH_F8 },
{ SL_KEY_F(19), K_SH_F9 },
{ SL_KEY_F(20), K_SH_F10 },
{ SL_KEY_F(21), K_CTRL_F1 },
{ SL_KEY_F(22), K_CTRL_F2 },
{ SL_KEY_F(23), K_CTRL_F3 },
{ SL_KEY_F(24), K_CTRL_F4 },
{ SL_KEY_F(25), K_CTRL_F5 },
{ SL_KEY_F(26), K_CTRL_F6 },
{ SL_KEY_F(27), K_CTRL_F7 },
{ SL_KEY_F(28), K_CTRL_F8 },
{ SL_KEY_F(29), K_CTRL_F9 },
{ SL_KEY_F(30), K_CTRL_F10 },
{ SL_KEY_F(31), K_ALT_F1 },
{ SL_KEY_F(32), K_ALT_F2 },
{ SL_KEY_F(33), K_ALT_F3 },
{ SL_KEY_F(34), K_ALT_F4 },
{ SL_KEY_F(35), K_ALT_F5 },
{ SL_KEY_F(36), K_ALT_F6 },
{ SL_KEY_F(37), K_ALT_F7 },
{ SL_KEY_F(38), K_ALT_F8 },
{ SL_KEY_F(39), K_ALT_F9 },
{ SL_KEY_F(40), K_ALT_F10 },
#if HB_GT_KBD_MODIF_MASK
#ifdef __linux__
{ SL_KEY_ALT( 'A' ) | ( ALTL_PRESSED << 16 ), K_ALT_A },
@@ -350,43 +306,88 @@ static int KeyTrans[][ 2 ] =
{ SL_KEY_ALT( '6' ), K_ALT_6 },
{ SL_KEY_ALT( '7' ), K_ALT_7 },
{ SL_KEY_ALT( '8' ), K_ALT_8 },
{ SL_KEY_ALT( '9' ), K_ALT_9 }
{ SL_KEY_ALT( '9' ), K_ALT_9 },
{ SL_KEY_F(1), K_F1 },
{ SL_KEY_F(2), K_F2 },
{ SL_KEY_F(3), K_F3 },
{ SL_KEY_F(4), K_F4 },
{ SL_KEY_F(5), K_F5 },
{ SL_KEY_F(6), K_F6 },
{ SL_KEY_F(7), K_F7 },
{ SL_KEY_F(8), K_F8 },
{ SL_KEY_F(9), K_F9 },
{ SL_KEY_F(10), K_F10 },
{ SL_KEY_F(11), K_SH_F1 },
{ SL_KEY_F(12), K_SH_F2 },
{ SL_KEY_F(13), K_SH_F3 },
{ SL_KEY_F(14), K_SH_F4 },
{ SL_KEY_F(15), K_SH_F5 },
{ SL_KEY_F(16), K_SH_F6 },
{ SL_KEY_F(17), K_SH_F7 },
{ SL_KEY_F(18), K_SH_F8 },
{ SL_KEY_F(19), K_SH_F9 },
{ SL_KEY_F(20), K_SH_F10 },
{ SL_KEY_F(21), K_CTRL_F1 },
{ SL_KEY_F(22), K_CTRL_F2 },
{ SL_KEY_F(23), K_CTRL_F3 },
{ SL_KEY_F(24), K_CTRL_F4 },
{ SL_KEY_F(25), K_CTRL_F5 },
{ SL_KEY_F(26), K_CTRL_F6 },
{ SL_KEY_F(27), K_CTRL_F7 },
{ SL_KEY_F(28), K_CTRL_F8 },
{ SL_KEY_F(29), K_CTRL_F9 },
{ SL_KEY_F(30), K_CTRL_F10 },
{ SL_KEY_F(31), K_ALT_F1 },
{ SL_KEY_F(32), K_ALT_F2 },
{ SL_KEY_F(33), K_ALT_F3 },
{ SL_KEY_F(34), K_ALT_F4 },
{ SL_KEY_F(35), K_ALT_F5 },
{ SL_KEY_F(36), K_ALT_F6 },
{ SL_KEY_F(37), K_ALT_F7 },
{ SL_KEY_F(38), K_ALT_F8 },
{ SL_KEY_F(39), K_ALT_F9 },
{ SL_KEY_F(40), K_ALT_F10 }
};
/* *********************************************************************** */
#define KeyTransSize ( sizeof( KeyTrans ) / ( 2 * sizeof ( int ) ) )
#define KeyTranslationTableSize \
( sizeof( KeyTranslationTable ) / ( 2 * sizeof ( int ) ) )
static void hb_gt_SortKeyTrans( void )
static void hb_gt_SortKeyTranslationTable( void )
{
int i, j, min, KeyTmp[ 2 ];
for ( i = 0; i < ( KeyTransSize - 1 ); i++ )
for ( i = 0; i < ( KeyTranslationTableSize - 1 ); i++ )
{
min = i;
for ( j = i + 1; j < KeyTransSize; j++ )
for ( j = i + 1; j < KeyTranslationTableSize; j++ )
{
if ( KeyTrans[ j ][ 0 ] < KeyTrans[ min ][ 0 ] )
if ( KeyTranslationTable[ j ][ 0 ] < KeyTranslationTable[ min ][ 0 ] )
min = j;
}
if ( min > i )
{
KeyTmp[ 0 ] = KeyTrans[ i ][ 0 ];
KeyTmp[ 1 ] = KeyTrans[ i ][ 1 ];
KeyTmp[ 0 ] = KeyTranslationTable[ i ][ 0 ];
KeyTmp[ 1 ] = KeyTranslationTable[ i ][ 1 ];
KeyTrans[ i ][ 0 ] = KeyTrans[ min ][ 0 ];
KeyTrans[ i ][ 1 ] = KeyTrans[ min ][ 1 ];
KeyTranslationTable[ i ][ 0 ] = KeyTranslationTable[ min ][ 0 ];
KeyTranslationTable[ i ][ 1 ] = KeyTranslationTable[ min ][ 1 ];
KeyTrans[ min ][ 0 ] = KeyTmp[ 0 ];
KeyTrans[ min ][ 1 ] = KeyTmp[ 1 ];
KeyTranslationTable[ min ][ 0 ] = KeyTmp[ 0 ];
KeyTranslationTable[ min ][ 1 ] = KeyTmp[ 1 ];
}
}
/*
for ( i = 0; i < KeyTransSize; i++ )
fprintf( stderr, "%02x %8x %8x\n", i, KeyTrans[ i ][ 0 ], KeyTrans[ i ][ 1 ] );
for ( i = 0; i < KeyTranslationTableSize; i++ )
fprintf( stderr, "%02x %8x %8x\n", i, KeyTranslationTable[ i ][ 0 ], KeyTranslationTable[ i ][ 1 ] );
*/
}
@@ -394,28 +395,28 @@ static void hb_gt_SortKeyTrans( void )
/* ************************************************************************* */
/* standard binary search */
static int hb_gt_FindKeyTrans( int SlangKey )
static int hb_gt_FindKeyTranslation( int SlangKey )
{
int Start,Stop,CurPos;
if ( ( SlangKey >= KeyTrans[ 0 ][ 0 ] ) &&
( SlangKey <= KeyTrans[ KeyTransSize - 1 ][ 0 ] ) )
if ( ( SlangKey >= KeyTranslationTable[ 0 ][ 0 ] ) &&
( SlangKey <= KeyTranslationTable[ KeyTranslationTableSize - 1 ][ 0 ] ) )
{
Start = 0; Stop = KeyTransSize - 1;
Start = 0; Stop = KeyTranslationTableSize - 1;
while( Start <= Stop )
{
CurPos = ( Start + Stop ) / 2;
/* fprintf( stderr, "%d %d %d\n", i, KeyTrans[ i ][ 0 ], KeyTrans[ i ][ 1 ] ); */
/* fprintf( stderr, "%d %d %d\n", i, KeyTranslationTable[ i ][ 0 ], KeyTranslationTable[ i ][ 1 ] ); */
if( SlangKey == KeyTrans[ CurPos ][ 0 ] )
return( KeyTrans[ CurPos ][ 1 ] );
if( SlangKey == KeyTranslationTable[ CurPos ][ 0 ] )
return( KeyTranslationTable[ CurPos ][ 1 ] );
else if( SlangKey < KeyTrans[ CurPos ][ 0 ] )
else if( SlangKey < KeyTranslationTable[ CurPos ][ 0 ] )
Stop = CurPos - 1;
else if( SlangKey > KeyTrans[ CurPos ][ 0 ] )
else if( SlangKey > KeyTranslationTable[ CurPos ][ 0 ] )
Start = CurPos + 1;
}
}
@@ -426,21 +427,22 @@ static int hb_gt_FindKeyTrans( int SlangKey )
/* ************************************************************************* */
int hb_gt_SetKeyTrans( int SlangKey, int ClipKey )
int hb_gt_SetKeyInKeyTranslationTable( int SlangKey, int ClipKey )
{
int i;
if ( ( SlangKey >= KeyTrans[ 0 ][ 0 ] ) &&
( SlangKey <= KeyTrans[ KeyTransSize - 1 ][ 0 ] ) )
if ( ( SlangKey >= KeyTranslationTable[ 0 ][ 0 ] ) &&
( SlangKey <= KeyTranslationTable[ KeyTranslationTableSize - 1 ][ 0 ] ) )
{
for ( i = 0; i < KeyTransSize; i++ )
for ( i = 0; i < KeyTranslationTableSize; i++ )
{
if ( SlangKey == KeyTrans[ i ][ 0 ] )
KeyTrans[ i ][ 1 ] = ClipKey;
if ( SlangKey == KeyTranslationTable[ i ][ 0 ] )
KeyTranslationTable[ i ][ 1 ] = ClipKey;
/* we don't break here because SlangKey can be defined more than once */
}
}
return( i < KeyTransSize );
return( i < KeyTranslationTableSize );
}
/* ************************************************************************* */