/* Display MENU at (X,Y) using FACES. */
static void
-tty_menu_display (tty_menu *menu, int y, int x, int pn, int *faces,
+tty_menu_display (tty_menu *menu, int x, int y, int pn, int *faces,
int disp_help)
{
int i, face, width, mx = -1, my = -1, enabled, mousehere, row, col;
menu_help_paneno = pn - 1;
menu_help_itemno = i;
}
- display_tty_menu_item (menu->text[i], face, y + i, x,
+ display_tty_menu_item (menu->text[i], face, x, y + i,
menu->submenu[i] != NULL);
}
update_frame_with_menu (sf);
puts us. We only consider mouse movement and click events and
keyboard movement commands; the rest are ignored. */
static void
-read_menu_input (int *x, int *y)
+read_menu_input (struct frame *sf, int *x, int *y, bool *first_time)
{
Lisp_Object c;
+ if (*first_time)
+ {
+ *first_time = false;
+ sf->mouse_moved = 1;
+ return;
+ }
+
while (1)
{
do {
break;
}
if (usable_input)
- return;
+ {
+ sf->mouse_moved = 1;
+ return;
+ }
}
else if (EVENT_HAS_PARAMETERS (c))
int title_faces[4]; /* face to display the menu title */
int faces[4], buffers_num_deleted = 0;
struct frame *sf = SELECTED_FRAME ();
+ bool first_time;
Lisp_Object saved_echo_area_message, selectface;
/* Don't allow non-positive x0 and y0, lest the menu will wrap
show_cursor (0); /* FIXME: need a new hook, for w32console. */
#endif
- /* Display the menu title. */
- tty_menu_display (menu, y0 - 1, x0 - 1, 1, title_faces, 0);
+ /* Display the menu title. We subtract 1 from x0 and y0 because we
+ want to interpret them as zero-based column and row coordinates,
+ and also because we want the first item of the menu, not its
+ title, to appear at x0,y0. */
+ tty_menu_display (menu, x0 - 1, y0 - 1, 1, title_faces, 0);
if (buffers_num_deleted)
menu->text[0][7] = ' ';
if ((onepane = menu->count == 1 && menu->submenu[0]))
x = state[0].x;
y = state[0].y;
+ first_time = true;
leave = 0;
while (!leave)
int mouse_button_count = 3; /* FIXME */
if (!mouse_visible) mouse_on ();
- read_menu_input (&x, &y);
+ read_menu_input (sf, &x, &y, &first_time);
if (sf->mouse_moved)
{
sf->mouse_moved = 0;
if (i == statecount - 1 && state[i].menu->submenu[dy])
{
tty_menu_display (state[i].menu,
- state[i].y,
state[i].x,
+ state[i].y,
state[i].pane,
faces, 1);
state[statecount].menu = state[i].menu->submenu[dy];
}
}
tty_menu_display (state[statecount - 1].menu,
- state[statecount - 1].y,
state[statecount - 1].x,
+ state[statecount - 1].y,
state[statecount - 1].pane,
faces, 1);
}
}
mouse_off (); /* FIXME */
+ sf->mouse_moved = 0;
+ /* FIXME: Since we set the fram's garbaged flag, do we need this
+ call to screen_update? */
screen_update (sf, state[0].screen_behind);
state[0].screen_behind = NULL;
#if 0
/* Allow mouse events generation by dos_rawgetc. */
mouse_preempted--;
#endif
+ SET_FRAME_GARBAGED (sf);
return result;
}
X and Y are coordinates of the first glyph in the desired matrix to
be overwritten by the menu item. Since this is a TTY, Y is the
- glyph row and X is the glyph number in the row, where to start
- displaying the item.
+ zero-based number of the glyph row and X is the zero-based glyph
+ number in the row, starting from left, where to start displaying
+ the item.
SUBMENU non-zero means this menu item drops down a submenu, which
should be indicated by displaying a proper visual cue after the
struct it it;
struct frame *f = SELECTED_FRAME ();
struct window *w = XWINDOW (f->selected_window);
- int saved_used, saved_truncated, saved_width;
+ int saved_used, saved_truncated, saved_width, saved_reversed;
struct glyph_row *row;
eassert (FRAME_TERMCAP_P (f));
it.first_visible_x = 0;
it.last_visible_x = FRAME_COLS (f);
row = it.glyph_row;
+ /* Copy the row contents from the current matrix. */
+ *row = f->current_matrix->rows[y];
saved_width = row->full_width_p;
row->full_width_p = 1;
+ saved_reversed = row->reversed_p;
+ row->reversed_p = 0;
/* Arrange for the menu item glyphs to start at X and have the
desired face. */
term.c:append_glyph. */
it.paragraph_embedding = L2R;
+ /* Pad with a space on the left. */
+ display_string (" ", Qnil, Qnil, 0, 0, &it, 1, 0, 0, -1);
if (submenu)
{
/* Indicate with ">" that there's a submenu. */
row->used[TEXT_AREA] = saved_used;
row->truncated_on_right_p = saved_truncated;
- row->hash - row_hash (row);
+ row->hash = row_hash (row);
row->full_width_p = saved_width;
+ row->reversed_p = saved_reversed;
}
#endif /* HAVE_MENUS */
\f