From 98e79a7e2fba7f620c969a2dc98ade2fd4254377 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 7 Aug 2008 22:30:53 +0000 Subject: [PATCH] 2008-08-08 00:30 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/bin/hb-func.sh + recognize -mwindows -mconsole MinGW-GCC switches and update library list for them * harbour/source/rtl/gtwvt/gtwvt.h * harbour/source/rtl/gtwvt/gtwvt.c + added support HB_SET{TERM|DISP|KEY}CP() in non Unicode builds --- harbour/ChangeLog | 9 ++++ harbour/bin/hb-func.sh | 28 +++++++--- harbour/source/rtl/gtwvt/gtwvt.c | 91 ++++++++++++++++++++++++++++++-- harbour/source/rtl/gtwvt/gtwvt.h | 4 ++ 4 files changed, 123 insertions(+), 9 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c69e7ab23d..62305b803a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-08-08 00:30 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/bin/hb-func.sh + + recognize -mwindows -mconsole MinGW-GCC switches and update + library list for them + + * harbour/source/rtl/gtwvt/gtwvt.h + * harbour/source/rtl/gtwvt/gtwvt.c + + added support HB_SET{TERM|DISP|KEY}CP() in non Unicode builds + 2008-08-07 23:04 UTC+0200 Viktor Szakats (harbour.01 syenar hu) - doc/es/simplex.txt * doc/es/Makefile diff --git a/harbour/bin/hb-func.sh b/harbour/bin/hb-func.sh index 883b59e849..3c0385d23d 100755 --- a/harbour/bin/hb-func.sh +++ b/harbour/bin/hb-func.sh @@ -290,6 +290,11 @@ HB_HWGUI="" HB_USRLIBS="" HB_USRLPATH="" HB_GEN="" +HB_MODE="" +LN_OPT="${CC_L_USR}" +CC_OPT="${CC_C_USR}" +HB_OPT="${CC_PRG_USR}" + [ -n "\$TMPDIR" ] || TMPDIR="\$TMP" [ -n "\$TMPDIR" ] || TMPDIR="\$TEMP" [ -n "\$TMPDIR" ] || TMPDIR="/tmp" @@ -325,6 +330,8 @@ while [ \$n -lt \${#P[@]} ]; do -nostrip) HB_STRIP="no" ;; -l[^-]*) HB_USRLIBS="\${HB_USRLIBS} \${v}" ;; -L[^-]*) HB_USRLPATH="\${HB_USRLPATH} \${v}" ;; + -mwindows) LN_OPT="\${LN_OPT} \${v}"; HB_MODE="gui" ;; + -mconsole) LN_OPT="\${LN_OPT} \${v}"; HB_MODE="std" ;; -main=*) HB_MAIN_FUNC="\${v#*=}" ;; -g[cohwij]) HB_GEN="\${v#-g}"; p="\${v}" ;; -gc[0-9]) HB_GEN="c"; p="\${v}" ;; @@ -362,9 +369,6 @@ HB_MAIN_FUNC=\`echo \${HB_MAIN_FUNC}|tr '[a-z]' '[A-Z]'\` HB_PATHS="-I\${HB_INC_INSTALL}" GCC_PATHS="\${HB_PATHS} -L\${HB_LIB_INSTALL}" -LN_OPT="${CC_L_USR}" -CC_OPT="${CC_C_USR}" -HB_OPT="${CC_PRG_USR}" [ "\${HB_GEN}" != "" ] || HB_OPT="\${HB_OPT} -gc0" HB_GPM_LIB="" @@ -484,9 +488,21 @@ else HARBOUR_LIBS="-Wl,--start-group \${HARBOUR_LIBS} -Wl,--end-group" fi -l="mainwin" -[ "\${HB_MT}" = "MT" ] && [ -f "\${HB_LIB_INSTALL}/lib\${l}mt.a" ] && l="\${l}mt" -[ -f "\${HB_LIB_INSTALL}/lib\${l}.a" ] && HARBOUR_LIBS="\${HARBOUR_LIBS} -l\${l}" +l="" +if [ "\${HB_COMPILER}" = "mingw32" ]; then + if [ -z "\${HB_MODE}" ]; then + LN_OPT="\${LN_OPT} -mwindows" + l="hbmainwin" + elif [ "\${HB_MODE}" = "gui" ]; then + l="hbmainwin" + elif [ "\${HB_MODE}" = "std" ]; then + l="hbmainstd" + fi +fi +if [ -n "\${l}" ]; then + [ "\${HB_MT}" = "MT" ] && [ -f "\${HB_LIB_INSTALL}/lib\${l}mt.a" ] && l="\${l}mt" + [ -f "\${HB_LIB_INSTALL}/lib\${l}.a" ] && HARBOUR_LIBS="\${HARBOUR_LIBS} -l\${l}" +fi l="hbfm" [ "\${HB_MT}" = "MT" ] && [ -f "\${HB_LIB_INSTALL}/lib\${l}mt.a" ] && l="\${l}mt" diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 1ced072d03..c58abd1f1a 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -1139,12 +1139,16 @@ static BOOL hb_gt_wvt_KeyEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, LPA hb_gt_wvt_AddCharToInputQueue( pWVT, K_ESC ); break; default: -#if defined(UNICODE) if( pWVT->inCDP ) + { +#if defined(UNICODE) c = hb_cdpGetChar( pWVT->inCDP, FALSE, ( USHORT ) c ); - else +#else + if( c > 0 && c <= 255 && pWVT->keyTransTbl[ c ] ) + c = pWVT->keyTransTbl[ c ]; #endif - if( pWVT->CodePage == OEM_CHARSET ) + } + else if( pWVT->CodePage == OEM_CHARSET ) c = hb_gt_wvt_key_ansi_to_oem( c ); hb_gt_wvt_AddCharToInputQueue( pWVT, c ); break; @@ -1339,6 +1343,8 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect ) #if defined(UNICODE) usChar = hb_cdpGetU16( pWVT->hostCDP, TRUE, ( BYTE ) usChar ); +#else + usChar = pWVT->chrTransTbl[ usChar & 0xff ]; #endif if( len == 0 ) { @@ -1633,7 +1639,15 @@ static void hb_gt_wvt_Init( PHB_GT pGT, FHANDLE hFilenoStdin, FHANDLE hFilenoStd #ifndef HB_CDP_SUPPORT_OFF pWVT->hostCDP = hb_cdp_page; +#if defined(UNICODE) pWVT->inCDP = hb_cdp_page; +#else + { + int i; + for( i = 0; i < 256; ++i ) + pWVT->chrTransTbl[ i ] = pWVT->keyTransTbl[ i ] = ( BYTE ) i; + } +#endif #endif /* Set default window title */ @@ -2522,6 +2536,8 @@ static BOOL hb_gt_wvt_SetDispCP( PHB_GT pGT, char * pszTermCDP, char * pszHostCD HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ); #ifndef HB_CDP_SUPPORT_OFF + +#if defined(UNICODE) /* * We are displaying text in U16 so pszTermCDP is unimportant. * We only have to know what is the internal application codepage @@ -2540,6 +2556,39 @@ static BOOL hb_gt_wvt_SetDispCP( PHB_GT pGT, char * pszTermCDP, char * pszHostCD if( cdpHost ) HB_GTWVT_GET( pGT )->hostCDP = cdpHost; } + +#else + + if( !pszHostCDP ) + pszHostCDP = hb_cdp_page->id; + if( !pszTermCDP ) + pszTermCDP = pszHostCDP; + + if( pszTermCDP && pszHostCDP ) + { + PHB_GTWVT pWVT = HB_GTWVT_GET( pGT ); + PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP ), + cdpHost = hb_cdpFind( pszHostCDP ); + int i; + + for( i = 0; i < 256; ++i ) + pWVT->chrTransTbl[ i ] = ( BYTE ) i; + + if( cdpTerm && cdpHost && cdpTerm != cdpHost && + cdpTerm->nChars && cdpTerm->nChars == cdpHost->nChars ) + { + for( i = 0; i < cdpHost->nChars; ++i ) + { + pWVT->chrTransTbl[ ( BYTE ) cdpHost->CharsUpper[ i ] ] = + ( BYTE ) cdpTerm->CharsUpper[ i ]; + pWVT->chrTransTbl[ ( BYTE ) cdpHost->CharsLower[ i ] ] = + ( BYTE ) cdpTerm->CharsLower[ i ]; + } + } + } + +#endif + #endif return TRUE; @@ -2550,6 +2599,8 @@ static BOOL hb_gt_wvt_SetKeyCP( PHB_GT pGT, char * pszTermCDP, char * pszHostCDP HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP ); #ifndef HB_CDP_SUPPORT_OFF + +#if defined(UNICODE) /* * We are receiving WM_CHAR events in U16 so pszTermCDP is unimportant. * We only have to know what is the internal application codepage @@ -2568,6 +2619,40 @@ static BOOL hb_gt_wvt_SetKeyCP( PHB_GT pGT, char * pszTermCDP, char * pszHostCDP if( cdpHost ) HB_GTWVT_GET( pGT )->inCDP = cdpHost; } + +#else + + if( !pszHostCDP ) + pszHostCDP = hb_cdp_page->id; + if( !pszTermCDP ) + pszTermCDP = pszHostCDP; + + if( pszTermCDP && pszHostCDP ) + { + PHB_GTWVT pWVT = HB_GTWVT_GET( pGT ); + PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP ), + cdpHost = hb_cdpFind( pszHostCDP ); + int i; + + for( i = 0; i < 256; ++i ) + pWVT->keyTransTbl[ i ] = ( BYTE ) i; + + if( cdpTerm && cdpHost && cdpTerm != cdpHost && + cdpTerm->nChars && cdpTerm->nChars == cdpHost->nChars ) + { + for( i = 0; i < cdpHost->nChars; ++i ) + { + pWVT->keyTransTbl[ ( BYTE ) cdpTerm->CharsUpper[ i ] ] = + ( BYTE ) cdpHost->CharsUpper[ i ]; + pWVT->keyTransTbl[ ( BYTE ) cdpTerm->CharsLower[ i ] ] = + ( BYTE ) cdpHost->CharsLower[ i ]; + } + } + + pWVT->inCDP = cdpTerm; + } +#endif + #endif return TRUE; diff --git a/harbour/source/rtl/gtwvt/gtwvt.h b/harbour/source/rtl/gtwvt/gtwvt.h index a923584dc0..f08abe8467 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.h +++ b/harbour/source/rtl/gtwvt/gtwvt.h @@ -146,6 +146,10 @@ typedef struct PHB_CODEPAGE hostCDP; /* Host/HVM CodePage for unicode output translations */ PHB_CODEPAGE inCDP; /* Host/HVM CodePage for unicode input translations */ +#if !defined(UNICODE) + BYTE keyTransTbl[ 256 ]; + BYTE chrTransTbl[ 256 ]; +#endif int CodePage; /* Code page to use for display characters */ BOOL Win9X; /* Flag to say if running on Win9X not NT/2000/XP */