}
}
+Lisp_Object
+read_menu_command (void)
+{
+ Lisp_Object cmd;
+ Lisp_Object keybuf[30];
+ int i = read_key_sequence (keybuf, sizeof keybuf / sizeof keybuf[0],
+ Qnil, 0, 1, 1);
+
+ if (! FRAME_LIVE_P (XFRAME (selected_frame)))
+ Fkill_emacs (Qnil);
+ if (i == 0 || i == -1)
+ return Qnil;
+
+ return read_key_sequence_cmd;
+}
+
/* Adjust point to a boundary of a region that has such a property
that should be treated intangible. For the moment, we check
`composition', `display' and `invisible' properties.
#endif
/* Display them in a menu. */
- block_input ();
/* FIXME: Use a terminal hook! */
#if defined HAVE_NTGUI
selection = tty_menu_show (f, xpos, ypos, for_click,
keymaps, title, &error_name);
- unblock_input ();
-
#ifdef HAVE_NS
unbind_to (specpdl_count, Qnil);
#else
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
widget_value *wv, *first_wv = 0;
+ block_input ();
+
p.x = x; p.y = y;
/* now parse stage 2 as in ns_update_menubar */
popup_activated_flag = 0;
[[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
+ unblock_input ();
return tem;
}
static int menu_x, menu_y;
+static Lisp_Object Qright_char, Qleft_char, Qforward_char, Qbackward_char;
+static Lisp_Object Qnext_line, Qprevious_line, Qnewline;
+
typedef struct tty_menu_struct
{
int count;
while (1)
{
-#if 0
- do {
- c = read_char (-2, Qnil, Qnil, NULL, NULL);
- } while (BUFFERP (c) || (INTEGERP (c) && XINT (c) == -2));
-
- if (INTEGERP (c))
+#if 1
+ extern Lisp_Object read_menu_command (void);
+ Lisp_Object cmd = read_menu_command ();
+ int usable_input = 1;
+ int st = 0;
+
+ if (NILP (cmd))
+ return -1;
+ if (EQ (cmd, Qright_char) || EQ (cmd, Qforward_char))
+ *x += 1;
+ else if (EQ (cmd, Qleft_char) || EQ (cmd, Qbackward_char))
+ *x -= 1;
+ else if (EQ (cmd, Qnext_line))
+ *y += 1;
+ else if (EQ (cmd, Qprevious_line))
+ *y -= 1;
+ else if (EQ (cmd, Qnewline))
+ st = 1;
+ else
{
- int ch = XINT (c);
- int usable_input = 1;
-
- /* FIXME: Exceedingly primitive! Can we support arrow keys? */
- switch (ch && ~CHAR_MODIFIER_MASK)
- {
- case 7: /* ^G */
- return -1;
- case 6: /* ^F */
- *x += 1;
- break;
- case 2: /* ^B */
- *x -= 1;
- break;
- case 14: /* ^N */
- *y += 1;
- break;
- case 16: /* ^P */
- *y -= 1;
- break;
- default:
- usable_input = 0;
- break;
- }
- if (usable_input)
- sf->mouse_moved = 1;
- break;
- }
-
- else if (EVENT_HAS_PARAMETERS (c))
- {
- if (EQ (EVENT_HEAD (c), Qmouse_movement))
- {
- }
- else if (EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click))
- {
- }
+ usable_input = 0;
+ st = -1;
}
+ if (usable_input)
+ sf->mouse_moved = 1;
#else
int volatile dx = 0;
int volatile dy = 0;
*y += dy;
if (dx != 0 || dy != 0)
sf->mouse_moved = 1;
+ Sleep (300);
+#endif
menu_x = *x;
menu_y = *y;
- Sleep (300);
return st;
-#endif
}
return 0;
}
while (!leave)
{
int mouse_button_count = 3; /* FIXME */
+ int input_status;
if (!mouse_visible) mouse_on ();
- if (read_menu_input (sf, &x, &y, &first_time) == -1)
- leave = 1;
+ input_status = read_menu_input (sf, &x, &y, &first_time);
+ if (input_status)
+ {
+ if (input_status == -1)
+ result = TTYM_NO_SELECT;
+ leave = 1;
+ }
else if (sf->mouse_moved)
{
sf->mouse_moved = 0;
encode_terminal_src = NULL;
encode_terminal_dst = NULL;
+
+ DEFSYM (Qright_char, "right-char");
+ DEFSYM (Qleft_char, "left-char");
+ DEFSYM (Qforward_char, "forward-char");
+ DEFSYM (Qbackward_char, "backward-char");
+ DEFSYM (Qprevious_line, "previous-line");
+ DEFSYM (Qnext_line, "next-line");
+ DEFSYM (Qnewline, "newline");
}
f = SELECTED_FRAME ();
if (!FRAME_W32_P (f))
- return;
+ {
+ unblock_input ();
+ return;
+ }
w32_show_hourglass (f);
unblock_input ();
while (nev > 0)
{
struct input_event inev;
+ /* Having a separate variable with this value makes
+ debugging easier, as otherwise the compiler might
+ rearrange the switch below in a way that makes it hard to
+ track the event type. */
+ unsigned evtype = queue_ptr->EventType;
EVENT_INIT (inev);
inev.kind = NO_EVENT;
inev.arg = Qnil;
- switch (queue_ptr->EventType)
+ switch (evtype)
{
case KEY_EVENT:
add = key_event (&queue_ptr->Event.KeyEvent, &inev, &isdead);
return Qnil;
}
+ block_input ();
+
/* Create a tree of widget_value objects
representing the panes and their items. */
wv = xmalloc_widget_value ();
if (!NILP (subprefix_stack[j]))
entry = Fcons (subprefix_stack[j], entry);
}
+ unblock_input ();
return entry;
}
i += MENU_ITEMS_ITEM_LENGTH;
}
}
else if (!for_click)
- /* Make "Cancel" equivalent to C-g. */
- Fsignal (Qquit, Qnil);
+ {
+ unblock_input ();
+ /* Make "Cancel" equivalent to C-g. */
+ Fsignal (Qquit, Qnil);
+ }
+ unblock_input ();
return Qnil;
}
\f
return Qnil;
}
+ block_input ();
+
/* Create a tree of widget_value objects
representing the panes and their items. */
wv = xmalloc_widget_value ();
if (!NILP (subprefix_stack[j]))
entry = Fcons (subprefix_stack[j], entry);
}
+ unblock_input ();
return entry;
}
i += MENU_ITEMS_ITEM_LENGTH;
}
}
else if (!for_click)
- /* Make "Cancel" equivalent to C-g. */
- Fsignal (Qquit, Qnil);
+ {
+ unblock_input ();
+ /* Make "Cancel" equivalent to C-g. */
+ Fsignal (Qquit, Qnil);
+ }
+ unblock_input ();
return Qnil;
}
\f
return Qnil;
}
+ block_input ();
+
/* Figure out which root window F is on. */
XGetGeometry (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &root,
&dummy_int, &dummy_int, &dummy_uint, &dummy_uint,
if (menu == NULL)
{
*error_name = "Can't create menu";
+ unblock_input ();
return Qnil;
}
{
XMenuDestroy (FRAME_X_DISPLAY (f), menu);
*error_name = "Can't create pane";
+ unblock_input ();
return Qnil;
}
i += MENU_ITEMS_PANE_LENGTH;
{
XMenuDestroy (FRAME_X_DISPLAY (f), menu);
*error_name = "Can't add selection to menu";
+ unblock_input ();
return Qnil;
}
i += MENU_ITEMS_ITEM_LENGTH;
/* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means
the menu was invoked with a mouse event as POSITION). */
if (! for_click)
- Fsignal (Qquit, Qnil);
+ {
+ unblock_input ();
+ Fsignal (Qquit, Qnil);
+ }
break;
}
+ unblock_input ();
unbind_to (specpdl_count, Qnil);
return entry;