summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvimboss <devnull@localhost>2007-09-05 19:47:23 +0000
committervimboss <devnull@localhost>2007-09-05 19:47:23 +0000
commitef3840b7a51d517bc802e00dcab177a5f6213189 (patch)
tree1a109da6e3f4caa4fb16c0d9ba18610842a4f09d
parent409a354b6b2840323416189c6a3ac34d84e25d86 (diff)
downloadvim-7.1.095.tar.gz
updated for version 7.1-095v7.1.095v7-1-095
-rw-r--r--src/eval.c30
-rw-r--r--src/getchar.c9
-rw-r--r--src/gui.c13
-rw-r--r--src/gui_gtk_x11.c11
-rw-r--r--src/keymap.h4
-rw-r--r--src/version.c2
6 files changed, 54 insertions, 15 deletions
diff --git a/src/eval.c b/src/eval.c
index 419a63b5..77d64137 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -9912,18 +9912,24 @@ f_getchar(argvars, rettv)
++no_mapping;
++allow_keys;
- if (argvars[0].v_type == VAR_UNKNOWN)
- /* getchar(): blocking wait. */
- n = safe_vgetc();
- else if (get_tv_number_chk(&argvars[0], &error) == 1)
- /* getchar(1): only check if char avail */
- n = vpeekc();
- else if (error || vpeekc() == NUL)
- /* illegal argument or getchar(0) and no char avail: return zero */
- n = 0;
- else
- /* getchar(0) and char avail: return char */
- n = safe_vgetc();
+ for (;;)
+ {
+ if (argvars[0].v_type == VAR_UNKNOWN)
+ /* getchar(): blocking wait. */
+ n = safe_vgetc();
+ else if (get_tv_number_chk(&argvars[0], &error) == 1)
+ /* getchar(1): only check if char avail */
+ n = vpeekc();
+ else if (error || vpeekc() == NUL)
+ /* illegal argument or getchar(0) and no char avail: return zero */
+ n = 0;
+ else
+ /* getchar(0) and char avail: return char */
+ n = safe_vgetc();
+ if (n == K_IGNORE)
+ continue;
+ break;
+ }
--no_mapping;
--allow_keys;
diff --git a/src/getchar.c b/src/getchar.c
index 23611a11..f77ddc2a 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1596,8 +1596,15 @@ vgetc()
continue;
}
#endif
-
#ifdef FEAT_GUI
+ /* The caller doesn't need to know that the focus event is delayed
+ * until getting a character. */
+ if (c == K_FOCUSGAINED || c == K_FOCUSLOST)
+ {
+ ui_focus_change(c == K_FOCUSGAINED);
+ continue;
+ }
+
/* Translate K_CSI to CSI. The special key is only used to avoid
* it being recognized as the start of a special key. */
if (c == K_CSI)
diff --git a/src/gui.c b/src/gui.c
index dcd81df4..b2b8e849 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -4519,7 +4519,18 @@ gui_focus_change(in_focus)
xim_set_focus(in_focus);
# endif
- ui_focus_change(in_focus);
+ /* Put events in the input queue only when allowed.
+ * ui_focus_change() isn't called directly, because it invokes
+ * autocommands and that must not happen asynchronously. */
+ if (!hold_gui_events)
+ {
+ char_u bytes[3];
+
+ bytes[0] = CSI;
+ bytes[1] = KS_EXTRA;
+ bytes[2] = in_focus ? (int)KE_FOCUSGAINED : (int)KE_FOCUSLOST;
+ add_to_input_buf(bytes, 3);
+ }
#endif
}
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 541240de..c5b11285 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -813,10 +813,15 @@ focus_in_event(GtkWidget *widget, GdkEventFocus *event, gpointer data)
if (blink_state == BLINK_NONE)
gui_mch_start_blink();
- /* make sure keyboard input goes to the draw area (if this is focus for a window) */
+ /* make sure keyboard input goes to the draw area (if this is focus for a
+ * window) */
if (widget != gui.drawarea)
gtk_widget_grab_focus(gui.drawarea);
+ /* make sure the input buffer is read */
+ if (gtk_main_level() > 0)
+ gtk_main_quit();
+
return TRUE;
}
@@ -829,6 +834,10 @@ focus_out_event(GtkWidget *widget, GdkEventFocus *event, gpointer data)
if (blink_state != BLINK_NONE)
gui_mch_stop_blink();
+ /* make sure the input buffer is read */
+ if (gtk_main_level() > 0)
+ gtk_main_quit();
+
return TRUE;
}
diff --git a/src/keymap.h b/src/keymap.h
index 376ac9c0..39837e55 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -254,6 +254,8 @@ enum key_extra
, KE_DROP /* DnD data is available */
, KE_CURSORHOLD /* CursorHold event */
, KE_NOP /* doesn't do something */
+ , KE_FOCUSGAINED /* focus gained */
+ , KE_FOCUSLOST /* focus lost */
};
/*
@@ -445,6 +447,8 @@ enum key_extra
#define K_CMDWIN TERMCAP2KEY(KS_EXTRA, KE_CMDWIN)
#define K_DROP TERMCAP2KEY(KS_EXTRA, KE_DROP)
+#define K_FOCUSGAINED TERMCAP2KEY(KS_EXTRA, KE_FOCUSGAINED)
+#define K_FOCUSLOST TERMCAP2KEY(KS_EXTRA, KE_FOCUSLOST)
#define K_CURSORHOLD TERMCAP2KEY(KS_EXTRA, KE_CURSORHOLD)
diff --git a/src/version.c b/src/version.c
index 854d9e77..82371a90 100644
--- a/src/version.c
+++ b/src/version.c
@@ -667,6 +667,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 95,
+/**/
94,
/**/
93,