aboutsummaryrefslogtreecommitdiffstats
path: root/src/msdos.c
diff options
context:
space:
mode:
authorEli Zaretskii2008-08-31 19:41:40 +0000
committerEli Zaretskii2008-08-31 19:41:40 +0000
commite52ab6c932fb28aa66ae666bfdcba19f7fbe09cd (patch)
tree0d9ab14c63627cfe302ae2eb312c6746e85e59f0 /src/msdos.c
parent87e204a2632ba4efdf147be3a0999c9a4bfcb56c (diff)
downloademacs-e52ab6c932fb28aa66ae666bfdcba19f7fbe09cd.tar.gz
emacs-e52ab6c932fb28aa66ae666bfdcba19f7fbe09cd.zip
(BUILD_CHAR_GLYPH): New macro.
(IT_menu_display): Use it instead of SET_CHAR_GLYPH to construct the menu.
Diffstat (limited to 'src/msdos.c')
-rw-r--r--src/msdos.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/msdos.c b/src/msdos.c
index 6b20d317df1..4063753c70a 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -3542,6 +3542,15 @@ IT_menu_calc_size (XMenu *menu, int *width, int *height)
3542 3542
3543/* Display MENU at (X,Y) using FACES. */ 3543/* Display MENU at (X,Y) using FACES. */
3544 3544
3545#define BUILD_CHAR_GLYPH(GLYPH, CODE, FACE_ID, PADDING_P) \
3546 do \
3547 { \
3548 (GLYPH).type = CHAR_GLYPH; \
3549 SET_CHAR_GLYPH ((GLYPH), CODE, FACE_ID, PADDING_P); \
3550 (GLYPH).charpos = -1; \
3551 } \
3552 while (0)
3553
3545static void 3554static void
3546IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help) 3555IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
3547{ 3556{
@@ -3553,7 +3562,9 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
3553 menu_help_message = NULL; 3562 menu_help_message = NULL;
3554 3563
3555 width = menu->width; 3564 width = menu->width;
3556 text = (struct glyph *) xmalloc ((width + 2) * sizeof (struct glyph)); 3565 /* We multiply width by 2 to account for possible control characters.
3566 FIXME: cater to non-ASCII characters in menus. */
3567 text = (struct glyph *) xmalloc ((width * 2 + 2) * sizeof (struct glyph));
3557 ScreenGetCursor (&row, &col); 3568 ScreenGetCursor (&row, &col);
3558 mouse_get_xy (&mx, &my); 3569 mouse_get_xy (&mx, &my);
3559 IT_update_begin (sf); 3570 IT_update_begin (sf);
@@ -3564,7 +3575,7 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
3564 IT_cursor_to (sf, y + i, x); 3575 IT_cursor_to (sf, y + i, x);
3565 enabled 3576 enabled
3566 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]); 3577 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]);
3567 mousehere = (y + i == my && x <= mx && mx < x + width + 2); 3578 mousehere = (y + i == my && x <= mx && mx < x + max_width);
3568 face = faces[enabled + mousehere * 2]; 3579 face = faces[enabled + mousehere * 2];
3569 /* The following if clause means that we display the menu help 3580 /* The following if clause means that we display the menu help
3570 strings even if the menu item is currently disabled. */ 3581 strings even if the menu item is currently disabled. */
@@ -3575,21 +3586,22 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
3575 menu_help_itemno = i; 3586 menu_help_itemno = i;
3576 } 3587 }
3577 p = text; 3588 p = text;
3578 SET_CHAR_GLYPH (*p, ' ', face, 0); 3589 BUILD_CHAR_GLYPH (*p, ' ', face, 0);
3579 p++; 3590 p++;
3580 for (j = 0, q = menu->text[i]; *q; j++) 3591 for (j = 0, q = menu->text[i]; *q; j++)
3581 { 3592 {
3582 if (*q > 26) 3593 if (*q > 26)
3583 { 3594 {
3584 SET_CHAR_GLYPH (*p, *q++, face, 0); 3595 BUILD_CHAR_GLYPH (*p, *q++, face, 0);
3585 p++; 3596 p++;
3586 } 3597 }
3587 else /* make '^x' */ 3598 else /* make '^x' */
3588 { 3599 {
3589 SET_CHAR_GLYPH (*p, '^', face, 0); 3600 /* FIXME: need to handle non-ASCII characters! */
3601 BUILD_CHAR_GLYPH (*p, '^', face, 0);
3590 p++; 3602 p++;
3591 j++; 3603 j++;
3592 SET_CHAR_GLYPH (*p, *q++ + 64, face, 0); 3604 BUILD_CHAR_GLYPH (*p, *q++ + 64, face, 0);
3593 p++; 3605 p++;
3594 } 3606 }
3595 } 3607 }
@@ -3600,9 +3612,11 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
3600 text[max_width - 1].u.ch = '$'; /* indicate it's truncated */ 3612 text[max_width - 1].u.ch = '$'; /* indicate it's truncated */
3601 } 3613 }
3602 for (; j < max_width - 2; j++, p++) 3614 for (; j < max_width - 2; j++, p++)
3603 SET_CHAR_GLYPH (*p, ' ', face, 0); 3615 BUILD_CHAR_GLYPH (*p, ' ', face, 0);
3604 3616
3605 SET_CHAR_GLYPH (*p, menu->submenu[i] ? 16 : ' ', face, 0); 3617 /* FIXME: should use Unicode codepoint for what Emacs 22.x
3618 displayed here. */
3619 BUILD_CHAR_GLYPH (*p, menu->submenu[i] ? '>' : ' ', face, 0);
3606 p++; 3620 p++;
3607 IT_write_glyphs (sf, text, max_width); 3621 IT_write_glyphs (sf, text, max_width);
3608 } 3622 }