diff options
| author | Eli Zaretskii | 2013-10-05 20:28:27 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-10-05 20:28:27 +0300 |
| commit | 401cf89091fc2f8f40b6668e996812f314060105 (patch) | |
| tree | 042a04b8dfc9162790a40a18d1137eeafd8a21cc /src | |
| parent | 72b70f6a68ac53cbab4db0e290259c1182a94db4 (diff) | |
| download | emacs-401cf89091fc2f8f40b6668e996812f314060105.tar.gz emacs-401cf89091fc2f8f40b6668e996812f314060105.zip | |
Account for character width on display in menu bar.
Diffstat (limited to 'src')
| -rw-r--r-- | src/menu.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/menu.c b/src/menu.c index 690955ca0ad..c3ab358bebf 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -30,6 +30,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 30 | #include "termhooks.h" | 30 | #include "termhooks.h" |
| 31 | #include "blockinput.h" | 31 | #include "blockinput.h" |
| 32 | #include "dispextern.h" | 32 | #include "dispextern.h" |
| 33 | #include "buffer.h" | ||
| 33 | 34 | ||
| 34 | #ifdef USE_X_TOOLKIT | 35 | #ifdef USE_X_TOOLKIT |
| 35 | #include "../lwlib/lwlib.h" | 36 | #include "../lwlib/lwlib.h" |
| @@ -1035,6 +1036,23 @@ find_and_return_menu_selection (struct frame *f, bool keymaps, void *client_data | |||
| 1035 | } | 1036 | } |
| 1036 | #endif /* HAVE_NS */ | 1037 | #endif /* HAVE_NS */ |
| 1037 | 1038 | ||
| 1039 | static int | ||
| 1040 | item_width (const char *str) | ||
| 1041 | { | ||
| 1042 | int len; | ||
| 1043 | const char *p; | ||
| 1044 | |||
| 1045 | for (len = 0, p = str; *p; ) | ||
| 1046 | { | ||
| 1047 | int ch_len; | ||
| 1048 | int ch = STRING_CHAR_AND_LENGTH (p, ch_len); | ||
| 1049 | |||
| 1050 | len += CHAR_WIDTH (ch); | ||
| 1051 | p += ch_len; | ||
| 1052 | } | ||
| 1053 | return len; | ||
| 1054 | } | ||
| 1055 | |||
| 1038 | DEFUN ("menu-bar-menu-at-x-y", Fmenu_bar_menu_at_x_y, Smenu_bar_menu_at_x_y, | 1056 | DEFUN ("menu-bar-menu-at-x-y", Fmenu_bar_menu_at_x_y, Smenu_bar_menu_at_x_y, |
| 1039 | 2, 3, 0, | 1057 | 2, 3, 0, |
| 1040 | doc: /* Return the menu-bar menu on FRAME at pixel coordinates X, Y. | 1058 | doc: /* Return the menu-bar menu on FRAME at pixel coordinates X, Y. |
| @@ -1077,7 +1095,10 @@ into menu items. */) | |||
| 1077 | pos = AREF (items, i + 3); | 1095 | pos = AREF (items, i + 3); |
| 1078 | if (NILP (str)) | 1096 | if (NILP (str)) |
| 1079 | return item; | 1097 | return item; |
| 1080 | if (XINT (pos) <= col && col < XINT (pos) + SCHARS (str)) | 1098 | if (XINT (pos) <= col |
| 1099 | /* We use <= so the blank between 2 items on a TTY is | ||
| 1100 | considered part of the previous item. */ | ||
| 1101 | && col <= XINT (pos) + item_width (SSDATA (str))) | ||
| 1081 | { | 1102 | { |
| 1082 | item = AREF (items, i); | 1103 | item = AREF (items, i); |
| 1083 | return item; | 1104 | return item; |