Akihiro Sagawa : user32: Add support for legacy access keys.

Alexandre Julliard julliard at winehq.org
Thu Sep 6 13:37:23 CDT 2012


Module: wine
Branch: master
Commit: 70937bd8ddd7a4f40b844abf0dcb36c937d7ab45
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=70937bd8ddd7a4f40b844abf0dcb36c937d7ab45

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Wed Sep  5 20:31:17 2012 +0900

user32: Add support for legacy access keys.

---

 dlls/user32/menu.c |    7 +++++--
 dlls/user32/text.c |   27 ++++++++++++++++++++-------
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index f1beb94..b325372 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -773,15 +773,18 @@ static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu,
 	if( !forceMenuChar )
 	{
 	     UINT i;
+	     BOOL cjk = GetSystemMetrics( SM_DBCSENABLED );
 
 	     for (i = 0; i < menu->nItems; i++, item++)
 	     {
 		if( item->text)
 		{
-		    WCHAR *p = item->text - 2;
+		    const WCHAR *p = item->text - 2;
 		    do
 		    {
-		    	p = strchrW (p + 2, '&');
+			const WCHAR *q = p + 2;
+			p = strchrW (q, '&');
+			if (!p && cjk) p = strchrW (q, '\036'); /* Japanese Win16 */
 		    }
 		    while (p != NULL && p [1] == '&');
 		    if (p && (toupperW(p[1]) == toupperW(key))) return i;
diff --git a/dlls/user32/text.c b/dlls/user32/text.c
index d7188c8..8539bdf 100644
--- a/dlls/user32/text.c
+++ b/dlls/user32/text.c
@@ -87,6 +87,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(text);
 #define CR     13
 #define SPACE  32
 #define PREFIX 38
+#define ALPHA_PREFIX 30 /* Win16: Alphabet prefix */
+#define KANA_PREFIX  31 /* Win16: Katakana prefix */
 
 #define FORWARD_SLASH '/'
 #define BACK_SLASH '\\'
@@ -472,8 +474,9 @@ static void TEXT_SkipChars (int *new_count, const WCHAR **new_str,
         max -= n;
         while (n--)
         {
-            if (*start_str++ == PREFIX && max--)
+            if ((*start_str == PREFIX || *start_str == ALPHA_PREFIX) && max--)
                 start_str++;
+            start_str++;
         }
         start_count -= (start_str - str_on_entry);
     }
@@ -507,10 +510,10 @@ static int TEXT_Reprefix (const WCHAR *str, unsigned int ns,
                           const ellipsis_data *pe)
 {
     int result = -1;
-    unsigned int i = 0;
+    unsigned int i;
     unsigned int n = pe->before + pe->under + pe->after;
     assert (n <= ns);
-    while (i < n)
+    for (i = 0; i < n; i++, str++)
     {
         if (i == pe->before)
         {
@@ -523,16 +526,15 @@ static int TEXT_Reprefix (const WCHAR *str, unsigned int ns,
         }
         if (!ns) break;
         ns--;
-        if (*str++ == PREFIX)
+        if (*str == PREFIX || *str == ALPHA_PREFIX)
         {
+            str++;
             if (!ns) break;
             if (*str != PREFIX)
                 result = (i < pe->before || pe->under == 0) ? i : i - pe->under + pe->len;
                 /* pe->len may be non-zero while pe_under is zero */
-            str++;
             ns--;
         }
-        i++;
     }
     return result;
 }
@@ -631,8 +633,13 @@ static const WCHAR *TEXT_NextLineW( HDC hdc, const WCHAR *str, int *count,
                (str[i] != TAB || !(format & DT_EXPANDTABS)) &&
                ((str[i] != CR && str[i] != LF) || (format & DT_SINGLELINE)))
         {
-	    if (str[i] == PREFIX && !(format & DT_NOPREFIX) && *count > 1)
+            if ((format & DT_NOPREFIX) || *count <= 1)
             {
+                (*count)--; if (j < maxl) dest[j++] = str[i++]; else i++;
+                continue;
+            }
+
+            if (str[i] == PREFIX || str[i] == ALPHA_PREFIX) {
                 (*count)--, i++; /* Throw away the prefix itself */
                 if (str[i] == PREFIX)
                 {
@@ -648,6 +655,12 @@ static const WCHAR *TEXT_NextLineW( HDC hdc, const WCHAR *str, int *count,
                  * one.
                  */
 	    }
+            else if (str[i] == KANA_PREFIX)
+            {
+                /* Throw away katakana access keys */
+                (*count)--, i++; /* skip the prefix */
+                (*count)--, i++; /* skip the letter */
+            }
             else
             {
                 (*count)--; if (j < maxl) dest[j++] = str[i++]; else i++;




More information about the wine-cvs mailing list