diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e22376d2ef..a39f4dfd4d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,14 @@ The license applies to all entries newer than 2009-04-28. */ +2012-04-25 02:20 UTC+0200 Viktor Szakats (harbour syenar.net) + * include/harbour.hbx + * src/rtl/inkey.c + + added HB_KEYCODE( ) -> + ; pls review me. It helps replacing ASC() calls in unicode apps + where it's used to convert characters (f.e. hotkeys) to keyboard + codes. + 2012-04-25 00:03 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbmisc/udpds.prg + updated to be CP agnostic diff --git a/harbour/include/harbour.hbx b/harbour/include/harbour.hbx index 512867a9a9..465d66a857 100644 --- a/harbour/include/harbour.hbx +++ b/harbour/include/harbour.hbx @@ -623,6 +623,7 @@ DYNAMIC hb_jsonDecode DYNAMIC hb_jsonEncode DYNAMIC hb_keyChar DYNAMIC hb_keyClear +DYNAMIC hb_keyCode DYNAMIC hb_keyIns DYNAMIC hb_keyLast DYNAMIC hb_keyNext diff --git a/harbour/src/rtl/inkey.c b/harbour/src/rtl/inkey.c index 2c88a0406f..9bdb5db5ee 100644 --- a/harbour/src/rtl/inkey.c +++ b/harbour/src/rtl/inkey.c @@ -54,7 +54,7 @@ * The following parts are Copyright of the individual authors. * www - http://harbour-project.org * - * Copyright 1999-2001 Viktor Szakats (harbour syenar.net) + * Copyright 1999-2012 Viktor Szakats (harbour syenar.net) * HB_KEYPUT() * * Copyright 2003-2012 Przemyslaw Czerpak @@ -220,6 +220,28 @@ HB_FUNC( HB_SETLASTKEY ) hb_retni( hb_inkeySetLast( hb_parni( 1 ) ) ); } +HB_FUNC( HB_KEYCODE ) +{ + const char * szValue = hb_parc( 1 ); + int iKey; + + if( szValue ) + { + PHB_CODEPAGE cdp = hb_vmCDP(); + HB_SIZE nIndex = 0; + HB_WCHAR wc; + + if( HB_CDPCHAR_GET( cdp, szValue, hb_parclen( 1 ), &nIndex, &wc ) ) + iKey = wc >= 128 ? HB_INKEY_NEW_UNICODE( wc ) : wc; + else + iKey = 0; + } + else + iKey = 0; + + hb_retni( iKey ); +} + HB_FUNC( HB_KEYCHAR ) { char szKeyChr[ HB_MAX_CHAR_LEN ];