aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
authorEli Zaretskii2013-09-21 17:53:04 +0300
committerEli Zaretskii2013-09-21 17:53:04 +0300
commitf0177f86f745ef86357214b110f9d98e4ed63b7a (patch)
tree85f8cbb3a930a39ea84bb02637279b7a783d37eb /src/term.c
parente11a3bd1d1848d0a3a2ac21a48360eb628127ed9 (diff)
downloademacs-f0177f86f745ef86357214b110f9d98e4ed63b7a.tar.gz
emacs-f0177f86f745ef86357214b110f9d98e4ed63b7a.zip
Fix infinite loop in menu input due to block_input.
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c91
1 files changed, 44 insertions, 47 deletions
diff --git a/src/term.c b/src/term.c
index 553cc1b6084..a600a3b33b4 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2815,6 +2815,9 @@ static int menu_help_paneno, menu_help_itemno;
2815 2815
2816static int menu_x, menu_y; 2816static int menu_x, menu_y;
2817 2817
2818static Lisp_Object Qright_char, Qleft_char, Qforward_char, Qbackward_char;
2819static Lisp_Object Qnext_line, Qprevious_line, Qnewline;
2820
2818typedef struct tty_menu_struct 2821typedef struct tty_menu_struct
2819{ 2822{
2820 int count; 2823 int count;
@@ -3171,51 +3174,31 @@ read_menu_input (struct frame *sf, int *x, int *y, bool *first_time)
3171 3174
3172 while (1) 3175 while (1)
3173 { 3176 {
3174#if 0 3177#if 1
3175 do { 3178 extern Lisp_Object read_menu_command (void);
3176 c = read_char (-2, Qnil, Qnil, NULL, NULL); 3179 Lisp_Object cmd = read_menu_command ();
3177 } while (BUFFERP (c) || (INTEGERP (c) && XINT (c) == -2)); 3180 int usable_input = 1;
3178 3181 int st = 0;
3179 if (INTEGERP (c)) 3182
3183 if (NILP (cmd))
3184 return -1;
3185 if (EQ (cmd, Qright_char) || EQ (cmd, Qforward_char))
3186 *x += 1;
3187 else if (EQ (cmd, Qleft_char) || EQ (cmd, Qbackward_char))
3188 *x -= 1;
3189 else if (EQ (cmd, Qnext_line))
3190 *y += 1;
3191 else if (EQ (cmd, Qprevious_line))
3192 *y -= 1;
3193 else if (EQ (cmd, Qnewline))
3194 st = 1;
3195 else
3180 { 3196 {
3181 int ch = XINT (c); 3197 usable_input = 0;
3182 int usable_input = 1; 3198 st = -1;
3183
3184 /* FIXME: Exceedingly primitive! Can we support arrow keys? */
3185 switch (ch && ~CHAR_MODIFIER_MASK)
3186 {
3187 case 7: /* ^G */
3188 return -1;
3189 case 6: /* ^F */
3190 *x += 1;
3191 break;
3192 case 2: /* ^B */
3193 *x -= 1;
3194 break;
3195 case 14: /* ^N */
3196 *y += 1;
3197 break;
3198 case 16: /* ^P */
3199 *y -= 1;
3200 break;
3201 default:
3202 usable_input = 0;
3203 break;
3204 }
3205 if (usable_input)
3206 sf->mouse_moved = 1;
3207 break;
3208 }
3209
3210 else if (EVENT_HAS_PARAMETERS (c))
3211 {
3212 if (EQ (EVENT_HEAD (c), Qmouse_movement))
3213 {
3214 }
3215 else if (EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click))
3216 {
3217 }
3218 } 3199 }
3200 if (usable_input)
3201 sf->mouse_moved = 1;
3219#else 3202#else
3220 int volatile dx = 0; 3203 int volatile dx = 0;
3221 int volatile dy = 0; 3204 int volatile dy = 0;
@@ -3225,11 +3208,11 @@ read_menu_input (struct frame *sf, int *x, int *y, bool *first_time)
3225 *y += dy; 3208 *y += dy;
3226 if (dx != 0 || dy != 0) 3209 if (dx != 0 || dy != 0)
3227 sf->mouse_moved = 1; 3210 sf->mouse_moved = 1;
3211 Sleep (300);
3212#endif
3228 menu_x = *x; 3213 menu_x = *x;
3229 menu_y = *y; 3214 menu_y = *y;
3230 Sleep (300);
3231 return st; 3215 return st;
3232#endif
3233 } 3216 }
3234 return 0; 3217 return 0;
3235} 3218}
@@ -3371,10 +3354,16 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
3371 while (!leave) 3354 while (!leave)
3372 { 3355 {
3373 int mouse_button_count = 3; /* FIXME */ 3356 int mouse_button_count = 3; /* FIXME */
3357 int input_status;
3374 3358
3375 if (!mouse_visible) mouse_on (); 3359 if (!mouse_visible) mouse_on ();
3376 if (read_menu_input (sf, &x, &y, &first_time) == -1) 3360 input_status = read_menu_input (sf, &x, &y, &first_time);
3377 leave = 1; 3361 if (input_status)
3362 {
3363 if (input_status == -1)
3364 result = TTYM_NO_SELECT;
3365 leave = 1;
3366 }
3378 else if (sf->mouse_moved) 3367 else if (sf->mouse_moved)
3379 { 3368 {
3380 sf->mouse_moved = 0; 3369 sf->mouse_moved = 0;
@@ -4607,4 +4596,12 @@ bigger, or it may make it blink, or it may do nothing at all. */);
4607 4596
4608 encode_terminal_src = NULL; 4597 encode_terminal_src = NULL;
4609 encode_terminal_dst = NULL; 4598 encode_terminal_dst = NULL;
4599
4600 DEFSYM (Qright_char, "right-char");
4601 DEFSYM (Qleft_char, "left-char");
4602 DEFSYM (Qforward_char, "forward-char");
4603 DEFSYM (Qbackward_char, "backward-char");
4604 DEFSYM (Qprevious_line, "previous-line");
4605 DEFSYM (Qnext_line, "next-line");
4606 DEFSYM (Qnewline, "newline");
4610} 4607}