#include "window.h"
#include "commands.h"
#include "buffer.h"
+#include "charset.h"
#include "disptab.h"
#include "dispextern.h"
#include "keyboard.h"
Lisp_Object Vlucid_menu_bar_dirty_flag;
Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
+Lisp_Object Qecho_area_clear_hook;
+
/* Hooks to run before and after each command. */
Lisp_Object Qpre_command_hook, Vpre_command_hook;
Lisp_Object Qpost_command_hook, Vpost_command_hook;
extern char *x_get_keysym_name ();
+static void record_menu_key ();
+
Lisp_Object Qpolling_period;
/* List of absolute timers. Appears in order of next scheduled event. */
command_loop_1 ()
{
Lisp_Object cmd, tem;
- int lose;
+ int lose, lose2;
int nonundocount;
Lisp_Object keybuf[30];
int i;
Fsit_for (make_number (2), Qnil, Qnil);
/* Clear the echo area. */
message2 (0);
+ safe_run_hooks (Qecho_area_clear_hook);
unbind_to (count, Qnil);
i = read_key_sequence (keybuf, sizeof keybuf / sizeof keybuf[0],
Qnil, 0, 1);
+ /* A filter may have run while we were reading the input. */
+ if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
+ set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
+
++num_input_keys;
/* Now we have read a key sequence of length I,
{
struct Lisp_Char_Table *dp
= window_display_table (XWINDOW (selected_window));
- lose = FETCH_CHAR (PT);
- SET_PT (PT + 1);
+ lose = FETCH_BYTE (PT);
+ SET_PT (forward_point (1));
if ((dp
? (VECTORP (DISP_CHAR_VECTOR (dp, lose))
? XVECTOR (DISP_CHAR_VECTOR (dp, lose))->size == 1
: (NILP (DISP_CHAR_VECTOR (dp, lose))
&& (lose >= 0x20 && lose < 0x7f)))
: (lose >= 0x20 && lose < 0x7f))
+ /* To extract the case of continuation on
+ wide-column characters. */
+ && (WIDTH_BY_CHAR_HEAD (FETCH_BYTE (PT)) == 1)
&& (XFASTINT (XWINDOW (selected_window)->last_modified)
>= MODIFF)
&& (XFASTINT (XWINDOW (selected_window)->last_overlay_modified)
{
struct Lisp_Char_Table *dp
= window_display_table (XWINDOW (selected_window));
- SET_PT (PT - 1);
- lose = FETCH_CHAR (PT);
+ SET_PT (forward_point (-1));
+ lose = FETCH_BYTE (PT);
if ((dp
? (VECTORP (DISP_CHAR_VECTOR (dp, lose))
? XVECTOR (DISP_CHAR_VECTOR (dp, lose))->size == 1
nonundocount = 0;
if (!lose
- && (PT == ZV || FETCH_CHAR (PT) == '\n'))
+ && (PT == ZV || FETCH_BYTE (PT) == '\n'))
{
struct Lisp_Char_Table *dp
= window_display_table (XWINDOW (selected_window));
/* Don't bring up a menu if we already have another event. */
&& NILP (Vunread_command_events)
&& unread_command_char < 0)
- c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu);
+ {
+ c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu);
+
+ /* Now that we have read an event, Emacs is not idle. */
+ timer_stop_idle ();
+
+ return c;
+ }
/* Maybe autosave and/or garbage collect due to idleness. */
}
/* Wipe the echo area. */
+ if (echo_area_glyphs)
+ safe_run_hooks (Qecho_area_clear_hook);
echo_area_glyphs = 0;
/* Handle things that only apply to characters. */
return c;
}
+/* Record a key that came from a mouse menu.
+ Record it for echoing, for this-command-keys, and so on. */
+
+static void
+record_menu_key (c)
+ Lisp_Object c;
+{
+ /* Wipe the echo area. */
+ echo_area_glyphs = 0;
+
+ record_char (c);
+
+ before_command_key_count = this_command_key_count;
+ before_command_echo_length = echo_length ();
+
+ /* Don't echo mouse motion events. */
+ if (echo_keystrokes)
+ {
+ echo_char (c);
+
+ /* Once we reread a character, echoing can happen
+ the next time we pause to read a new one. */
+ ok_to_echo_at_next_pause = 0;
+ }
+
+ /* Record this character as part of the current key. */
+ add_command_key (c);
+
+ /* Re-reading in the middle of a command */
+ last_input_char = c;
+ num_input_chars++;
+}
+
/* Return 1 if should recognize C as "the help character". */
int
#define FUNCTION_KEY_OFFSET 0xff00
+#ifdef XK_kana_A
+static char *lispy_kana_keys[] =
+ {
+ /* X Keysym value */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x400 .. 0x40f */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x410 .. 0x41f */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x420 .. 0x42f */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x430 .. 0x43f */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x440 .. 0x44f */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x450 .. 0x45f */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x460 .. 0x46f */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,"overline",0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x480 .. 0x48f */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x490 .. 0x49f */
+ 0, "kana-fullstop", "kana-openingbracket", "kana-closingbracket",
+ "kana-comma", "kana-conjunctive", "kana-WO", "kana-a",
+ "kana-i", "kana-u", "kana-e", "kana-o",
+ "kana-ya", "kana-yu", "kana-yo", "kana-tsu",
+ "prolongedsound", "kana-A", "kana-I", "kana-U",
+ "kana-E", "kana-O", "kana-KA", "kana-KI",
+ "kana-KU", "kana-KE", "kana-KO", "kana-SA",
+ "kana-SHI", "kana-SU", "kana-SE", "kana-SO",
+ "kana-TA", "kana-CHI", "kana-TSU", "kana-TE",
+ "kana-TO", "kana-NA", "kana-NI", "kana-NU",
+ "kana-NE", "kana-NO", "kana-HA", "kana-HI",
+ "kana-FU", "kana-HE", "kana-HO", "kana-MA",
+ "kana-MI", "kana-MU", "kana-ME", "kana-MO",
+ "kana-YA", "kana-YU", "kana-YO", "kana-RA",
+ "kana-RI", "kana-RU", "kana-RE", "kana-RO",
+ "kana-WA", "kana-N", "voicedsound", "semivoicedsound",
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x4e0 .. 0x4ef */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x4f0 .. 0x4ff */
+ };
+#endif /* XK_kana_A */
+
/* You'll notice that this table is arranged to be conveniently
indexed by X Windows keysym values. */
static char *lispy_function_keys[] =
0, 0, 0, 0, 0, 0, 0,
"escape",
0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff20...2f */
+ 0, "kanji", "muhenkan",
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff20...2f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff30...3f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff40...4f */
(unsigned)-1);
}
+#ifdef XK_kana_A
+ if (event->code >= 0x400 && event->code < 0x500)
+ return modify_event_symbol (event->code - 0x400,
+ event->modifiers & ~shift_modifier,
+ Qfunction_key, Qnil,
+ lispy_kana_keys, &func_key_syms,
+ (sizeof (lispy_kana_keys)
+ / sizeof (lispy_kana_keys[0])));
+#endif /* XK_kana_A */
+
return modify_event_symbol (event->code - FUNCTION_KEY_OFFSET,
event->modifiers,
Qfunction_key, Qnil,
else
{
int pixcolumn, pixrow;
- column -= XINT (XWINDOW (window)->left);
+ column -= WINDOW_LEFT_MARGIN (XWINDOW (window));
row -= XINT (XWINDOW (window)->top);
glyph_to_pixel_coords (f, column, row, &pixcolumn, &pixrow);
XSETINT (event->x, pixcolumn);
}
#ifdef WINDOWSNT
- case win32_scroll_bar_click:
+ case w32_scroll_bar_click:
{
int button = event->code;
int is_double;
Fcons (part, Qnil)))));
}
- /* Always treat Win32 scroll bar events as clicks. */
+ /* Always treat W32 scroll bar events as clicks. */
event->modifiers |= click_modifier;
{
if (WINDOWP (window))
{
int pixcolumn, pixrow;
- column -= XINT (XWINDOW (window)->left);
+ column -= WINDOW_LEFT_MARGIN (XWINDOW (window));
row -= XINT (XWINDOW (window)->top);
glyph_to_pixel_coords (frame, column, row, &pixcolumn, &pixrow);
XSETINT (x, pixcolumn);
/* No; let's create it. */
if (!NILP (name_alist))
value = Fcdr_safe (Fassq (symbol_int, name_alist));
- else if (name_table[symbol_num])
+ else if (name_table != 0 && name_table[symbol_num])
value = intern (name_table[symbol_num]);
#ifdef HAVE_WINDOW_SYSTEM
if (read_socket_hook)
/* No need for FIONREAD or fcntl; just say don't wait. */
- nread = (*read_socket_hook) (input_fd, buf, KBD_BUFFER_SIZE,
- expected, expected);
+ nread = (*read_socket_hook) (input_fd, buf, KBD_BUFFER_SIZE, expected);
else
{
/* Using KBD_BUFFER_SIZE - 1 here avoids reading more than
{
Lisp_Object tem;
+ record_menu_key (XCONS (value)->car);
+
/* If we got multiple events, unread all but
the first.
There is no way to prevent those unread events
they won't confuse things. */
for (tem = XCONS (value)->cdr; !NILP (tem);
tem = XCONS (tem)->cdr)
- if (SYMBOLP (XCONS (tem)->car)
- || INTEGERP (XCONS (tem)->car))
- XCONS (tem)->car
- = Fcons (XCONS (tem)->car, Qnil);
+ {
+ record_menu_key (XCONS (tem)->car);
+ if (SYMBOLP (XCONS (tem)->car)
+ || INTEGERP (XCONS (tem)->car))
+ XCONS (tem)->car
+ = Fcons (XCONS (tem)->car, Qnil);
+ }
/* If we got more than one event, put all but the first
onto this list to be read later.
cancel_echoing ();
- if (!NILP (Vquit_flag) && FRAME_TERMCAP_P (selected_frame))
+ if (!NILP (Vquit_flag)
+ && (FRAME_TERMCAP_P (selected_frame) || FRAME_MSDOS_P (selected_frame)))
{
+ /* If SIGINT isn't blocked, don't let us be interrupted by
+ another SIGINT, it might be harmful due to non-reentrancy
+ in I/O functions. */
+ sigblock (sigmask (SIGINT));
+
fflush (stdout);
reset_sys_modes ();
- sigfree ();
+
#ifdef SIGTSTP /* Support possible in later USG versions */
/*
* On systems which can suspend the current process and return to the original
#endif /* not MSDOS */
fflush (stdout);
init_sys_modes ();
+ sigfree ();
}
else
{
inhibit_local_menu_bar_menus = 0;
DEFVAR_INT ("num-input-keys", &num_input_keys,
- "Number of complete keys read from the keyboard so far.");
+ "Number of complete key sequences read from the keyboard so far.\n\
+This includes key sequences read from keyboard macros.\n\
+The number is effectively the number of interactive command invocations.");
num_input_keys = 0;
DEFVAR_LISP ("last-event-frame", &Vlast_event_frame,
This is measured in microseconds.");
post_command_idle_delay = 100000;
+#if 0
+ DEFVAR_LISP ("echo-area-clear-hook", ...,
+ "Normal hook run when clearing the echo area.");
+#endif
+ Qecho_area_clear_hook = intern ("echo-area-clear-hook");
+ XSYMBOL (Qecho_area_clear_hook)->value = Qnil;
+
DEFVAR_LISP ("lucid-menu-bar-dirty-flag", &Vlucid_menu_bar_dirty_flag,
"t means menu bar, specified Lucid style, needs to be recomputed.");
Vlucid_menu_bar_dirty_flag = Qnil;