summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/alloc.c2
-rw-r--r--src/cm.h2
-rw-r--r--src/dispextern.h1
-rw-r--r--src/dispnew.c3
-rw-r--r--src/keyboard.c2
-rw-r--r--src/keyboard.h2
-rw-r--r--src/menu.h2
-rw-r--r--src/term.c117
-rw-r--r--src/termhooks.h7
-rw-r--r--src/w32console.c8
-rw-r--r--src/xdisp.c3
11 files changed, 118 insertions, 31 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 0989e63664f..a8cbee1cf36 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3378,7 +3378,6 @@ make_save_obj_obj_obj_obj (Lisp_Object a, Lisp_Object b, Lisp_Object c,
return val;
}
-#if defined HAVE_NS || defined HAVE_NTGUI
Lisp_Object
make_save_ptr (void *a)
{
@@ -3388,7 +3387,6 @@ make_save_ptr (void *a)
p->data[0].pointer = a;
return val;
}
-#endif
Lisp_Object
make_save_ptr_int (void *a, ptrdiff_t b)
diff --git a/src/cm.h b/src/cm.h
index 6d49dda9419..f3455b79569 100644
--- a/src/cm.h
+++ b/src/cm.h
@@ -139,7 +139,7 @@ struct cm
#define MultiDownCost(tty) (tty)->Wcm->cc_multidown
#define MultiLeftCost(tty) (tty)->Wcm->cc_multileft
#define MultiRightCost(tty) (tty)->Wcm->cc_multiright
-#endif
+#endif /* NoCMShortHand */
#define cmat(tty,row,col) (curY(tty) = (row), curX(tty) = (col))
#define cmplus(tty,n) \
diff --git a/src/dispextern.h b/src/dispextern.h
index f86059e9889..0e6d934991a 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3460,6 +3460,7 @@ extern bool update_frame (struct frame *, bool, bool);
extern void update_frame_with_menu (struct frame *);
extern void bitch_at_user (void);
void adjust_glyphs (struct frame *);
+struct glyph_matrix *save_current_matrix (struct frame *);
void free_glyphs (struct frame *);
void free_window_matrices (struct window *);
void check_glyph_memory (void);
diff --git a/src/dispnew.c b/src/dispnew.c
index 824c62bcf33..2378e72091e 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3185,8 +3185,9 @@ void
update_frame_with_menu (struct frame *f)
{
struct window *root_window = XWINDOW (f->root_window);
+ bool paused_p;
- xassert (FRAME_TERMCAP_P (f));
+ eassert (FRAME_TERMCAP_P (f));
/* We are working on frame matrix basis. Set the frame on whose
frame matrix we operate. */
diff --git a/src/keyboard.c b/src/keyboard.c
index c90ddba81c7..1150064a10f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -292,7 +292,7 @@ static struct input_event * volatile kbd_store_ptr;
at inopportune times. */
/* Symbols to head events. */
-static Lisp_Object Qmouse_movement;
+Lisp_Object Qmouse_movement;
static Lisp_Object Qscroll_bar_movement;
Lisp_Object Qswitch_frame;
static Lisp_Object Qfocus_in, Qfocus_out;
diff --git a/src/keyboard.h b/src/keyboard.h
index 1ee4a97c5c5..b015f3fe4d3 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -453,7 +453,7 @@ extern Lisp_Object Qswitch_frame;
extern Lisp_Object Qevent_kind;
/* The values of Qevent_kind properties. */
-extern Lisp_Object Qmouse_click;
+extern Lisp_Object Qmouse_click, Qmouse_movement;
extern Lisp_Object Qhelp_echo;
diff --git a/src/menu.h b/src/menu.h
index c2dd376fcbb..cdc1838ff9f 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -51,6 +51,6 @@ extern Lisp_Object ns_menu_show (struct frame *, int, int, bool, bool,
Lisp_Object, const char **);
extern Lisp_Object xmenu_show (struct frame *, int, int, bool, bool,
Lisp_Object, const char **, Time);
-extern Lisp_Object tty_menu_show (FRAME_PTR, int, int, int, int,
+extern Lisp_Object tty_menu_show (struct frame *, int, int, int, int,
Lisp_Object, const char **);
#endif /* MENU_H */
diff --git a/src/term.c b/src/term.c
index 806e038da9a..f3a750c70b6 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2935,8 +2935,8 @@ tty_menu_display (tty_menu *menu, int y, int x, int pn, int *faces,
menu_help_message = NULL;
width = menu->width;
- col = curX (tty);
- row = curY (tty);
+ col = cursorX (tty);
+ row = cursorY (tty);
#if 0
IT_update_begin (sf); /* FIXME: do we need an update_begin_hook? */
#endif
@@ -2974,8 +2974,8 @@ have_menus_p (void) { return 1; }
/* Create a new pane and place it on the outer-most level. */
-int
-tty_menu_add_pane (Display *foo, tty_menu *menu, const char *txt)
+static int
+tty_menu_add_pane (tty_menu *menu, const char *txt)
{
int len;
const char *p;
@@ -3112,6 +3112,7 @@ free_saved_screen (struct glyph_matrix *saved)
for (i = 0; i < saved->nrows; ++i)
{
struct glyph_row *from = saved->rows + i;
+ short nbytes;
xfree (from->glyphs[TEXT_AREA]);
nbytes = from->used[LEFT_MARGIN_AREA];
@@ -3145,7 +3146,7 @@ read_menu_input (int *x, int *y)
while (1)
{
do {
- c = read_char (-2, 0, NULL, Qnil, NULL, NULL);
+ c = read_char (-2, Qnil, Qnil, NULL, NULL);
} while (BUFFERP (c) || (INTEGERP (c) && XINT (c) == -2));
if (INTEGERP (c))
@@ -3188,6 +3189,38 @@ read_menu_input (int *x, int *y)
}
}
+/* FIXME */
+static bool mouse_visible;
+static void
+mouse_off (void)
+{
+ mouse_visible = false;
+}
+
+static void
+mouse_on (void)
+{
+ mouse_visible = true;
+}
+
+static bool
+mouse_pressed (int b, int *x, int *y)
+{
+ return false;
+}
+
+static bool
+mouse_button_depressed (int b, int *x, int *y)
+{
+ return false;
+}
+
+static bool
+mouse_released (int b, int *x, int *y)
+{
+ return true;
+}
+
/* Display menu, wait for user's response, and return that response. */
int
tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
@@ -3195,7 +3228,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
void (*help_callback)(char const *, int, int))
{
struct tty_menu_state *state;
- int statecount, x, y, i, b, screensize, leave, result, onepane;
+ int statecount, x, y, i, b, leave, result, onepane;
int title_faces[4]; /* face to display the menu title */
int faces[4], buffers_num_deleted = 0;
struct frame *sf = SELECTED_FRAME ();
@@ -3208,12 +3241,13 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
if (y0 <= 0)
y0 = 1;
+#if 0
/* We will process all the mouse events directly. */
mouse_preempted++;
+#endif
state = alloca (menu->panecount * sizeof (struct tty_menu_state));
memset (state, 0, sizeof (*state));
- screensize = screen_size * 2;
faces[0]
= lookup_derived_face (sf, intern ("tty-menu-disabled-face"),
DEFAULT_FACE_ID, 1);
@@ -3287,6 +3321,8 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
leave = 0;
while (!leave)
{
+ int mouse_button_count = 3; /* FIXME */
+
if (!mouse_visible) mouse_on ();
read_menu_input (&x, &y);
if (sf->mouse_moved)
@@ -3317,7 +3353,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
{
statecount--;
mouse_off (); /* FIXME */
- screen_update (state[statecount].screen_behind);
+ screen_update (sf, state[statecount].screen_behind);
state[statecount].screen_behind = NULL;
}
if (i == statecount - 1 && state[i].menu->submenu[dy])
@@ -3412,11 +3448,15 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
(which invoked the menu) too quickly. If we don't remove these events,
Emacs will process them after we return and surprise the user. */
discard_mouse_events ();
+#if 0
mouse_clear_clicks ();
- if (!kbd_buffer_events_waiting (1))
+#endif
+ if (!kbd_buffer_events_waiting ())
clear_input_pending ();
+#if 0
/* Allow mouse events generation by dos_rawgetc. */
mouse_preempted--;
+#endif
return result;
}
@@ -3440,8 +3480,53 @@ tty_menu_destroy (tty_menu *menu)
menu_help_message = prev_menu_help_message = NULL;
}
+static struct frame *tty_menu_help_frame;
+
+/* Show help HELP_STRING, or clear help if HELP_STRING is null.
+
+ PANE is the pane number, and ITEM is the menu item number in
+ the menu (currently not used).
+
+ This cannot be done with generating a HELP_EVENT because
+ XMenuActivate contains a loop that doesn't let Emacs process
+ keyboard events.
+
+ FIXME: Do we need this in TTY menus? */
+
+static void
+tty_menu_help_callback (char const *help_string, int pane, int item)
+{
+ Lisp_Object *first_item;
+ Lisp_Object pane_name;
+ Lisp_Object menu_object;
+
+ first_item = XVECTOR (menu_items)->contents;
+ if (EQ (first_item[0], Qt))
+ pane_name = first_item[MENU_ITEMS_PANE_NAME];
+ else if (EQ (first_item[0], Qquote))
+ /* This shouldn't happen, see xmenu_show. */
+ pane_name = empty_unibyte_string;
+ else
+ pane_name = first_item[MENU_ITEMS_ITEM_NAME];
+
+ /* (menu-item MENU-NAME PANE-NUMBER) */
+ menu_object = list3 (Qmenu_item, pane_name, make_number (pane));
+ show_help_echo (help_string ? build_string (help_string) : Qnil,
+ Qnil, menu_object, make_number (item));
+}
+
+static void
+tty_pop_down_menu (Lisp_Object arg)
+{
+ tty_menu *menu = XSAVE_POINTER (arg, 0);
+
+ block_input ();
+ tty_menu_destroy (menu);
+ unblock_input ();
+}
+
Lisp_Object
-tty_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
+tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
Lisp_Object title, const char **error_name)
{
tty_menu *menu;
@@ -3457,7 +3542,7 @@ tty_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
if (! FRAME_TERMCAP_P (f))
- abort ();
+ emacs_abort ();
*error_name = 0;
if (menu_items_n_panes == 0)
@@ -3631,15 +3716,13 @@ tty_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
pane = selidx = 0;
- record_unwind_protect (pop_down_menu,
- Fcons (make_save_value (f, 0),
- make_save_value (menu, 0)));
+ record_unwind_protect (tty_pop_down_menu, make_save_ptr (menu));
/* Help display under X won't work because XMenuActivate contains
- a loop that doesn't give Emacs a chance to process it. */
- menu_help_frame = f;
+ a loop that doesn't give Emacs a chance to process it. FIXME. */
+ tty_menu_help_frame = f;
status = tty_menu_activate (menu, &pane, &selidx, x, y, &datap,
- menu_help_callback);
+ tty_menu_help_callback);
entry = pane_prefix = Qnil;
switch (status)
diff --git a/src/termhooks.h b/src/termhooks.h
index 437089ebf7a..3e4ec1d7e6d 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -664,8 +664,11 @@ extern void close_gpm (int gpm_fd);
#endif
#ifdef WINDOWSNT
-extern int curX (struct tty_display_info *);
-extern int curY (struct tty_display_info *);
+extern int cursorX (struct tty_display_info *);
+extern int cursorY (struct tty_display_info *);
+#else
+#define cursorX(t) curX(t)
+#define cursorY(t) curY(t)
#endif
INLINE_HEADER_END
diff --git a/src/w32console.c b/src/w32console.c
index a85469cb382..cb42bae1421 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -553,16 +553,16 @@ Wcm_clear (struct tty_display_info *tty)
/* Report the current cursor position. The following two functions
- mirror cm.h macros and are used in term.c's tty menu code, so they
- are not really "stubs". */
+ are used in term.c's tty menu code, so they are not really
+ "stubs". */
int
-curX (struct tty_display_info *tty)
+cursorX (struct tty_display_info *tty)
{
return cursor_coords.X;
}
int
-curY (struct tty_display_info *tty)
+cursorY (struct tty_display_info *tty)
{
return cursor_coords.Y;
}
diff --git a/src/xdisp.c b/src/xdisp.c
index 27ce653952f..2d015fca887 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -20602,10 +20602,11 @@ display_tty_menu_item (const char *item_text, int face_id, int x, int y,
{
struct it it;
struct frame *f = SELECTED_FRAME ();
+ struct window *w = XWINDOW (f->selected_window);
int saved_used, saved_truncated, saved_width;
struct glyph_row *row;
- xassert (FRAME_TERMCAP_P (f));
+ eassert (FRAME_TERMCAP_P (f));
init_iterator (&it, w, -1, -1, f->desired_matrix->rows + y, MENU_FACE_ID);
it.first_visible_x = 0;