Mercurial > hg > xemacs-beta
comparison src/menubar-msw.c @ 327:03446687b7cc r21-0-61
Import from CVS: tag r21-0-61
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:48:16 +0200 |
parents | 70ad99077275 |
children | fbbf69b4e8a7 |
comparison
equal
deleted
inserted
replaced
326:e2671bc7f66a | 327:03446687b7cc |
---|---|
128 /* We construct the name in a static buffer. That's fine, beause | 128 /* We construct the name in a static buffer. That's fine, beause |
129 menu items longer than 128 chars are probably programming errors, | 129 menu items longer than 128 chars are probably programming errors, |
130 and better be caught than displayed! */ | 130 and better be caught than displayed! */ |
131 | 131 |
132 static char buf[MAX_MENUITEM_LENGTH+2]; | 132 static char buf[MAX_MENUITEM_LENGTH+2]; |
133 char *ptr; | |
133 unsigned int ll, lr; | 134 unsigned int ll, lr; |
134 | 135 |
135 /* Left flush part of the string */ | 136 /* Left flush part of the string */ |
136 ll = gui_item_display_flush_left (pgui_item, buf, MAX_MENUITEM_LENGTH); | 137 ll = gui_item_display_flush_left (pgui_item, buf, MAX_MENUITEM_LENGTH); |
138 | |
139 /* Escape '&' as '&&' */ | |
140 ptr = buf; | |
141 while ((ptr=memchr (ptr, '&', ll-(ptr-buf))) != NULL) | |
142 { | |
143 if (ll+2 >= MAX_MENUITEM_LENGTH) | |
144 signal_simple_error ("Menu item produces too long displayable string", | |
145 pgui_item->name); | |
146 memmove (ptr+1, ptr, ll-(ptr-buf)); | |
147 ll++; | |
148 ptr+=2; | |
149 } | |
150 | |
151 /* Replace XEmacs accelerator '%_' with Windows accelerator '&' */ | |
152 ptr = buf; | |
153 while ((ptr=memchr (ptr, '%', ll-(ptr-buf))) != NULL) | |
154 { | |
155 if (*(ptr+1) == '_') | |
156 { | |
157 *ptr = '&'; | |
158 memmove (ptr+1, ptr+2, ll-(ptr-buf+2)); | |
159 ll--; | |
160 } | |
161 ptr++; | |
162 } | |
137 | 163 |
138 /* Right flush part */ | 164 /* Right flush part */ |
139 assert (MAX_MENUITEM_LENGTH > ll + 1); | 165 assert (MAX_MENUITEM_LENGTH > ll + 1); |
140 lr = gui_item_display_flush_right (pgui_item, buf + ll + 1, | 166 lr = gui_item_display_flush_right (pgui_item, buf + ll + 1, |
141 MAX_MENUITEM_LENGTH - ll - 1); | 167 MAX_MENUITEM_LENGTH - ll - 1); |