summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux2014-10-23 12:12:17 -0400
committerQuentin Carbonneaux2014-10-23 12:12:17 -0400
commitb6d5fb8431a73ce7e4568d26d999b47e7734ba8c (patch)
treea2799ef0ab75365d90a18b53af51184253c324f5
parent0fde8d24f4008126d8334ba98939bb268717de43 (diff)
reset the command parser state before switching windows
-rw-r--r--cmd.h1
-rw-r--r--exec.c7
-rw-r--r--main.c21
-rw-r--r--vicmd.w5
4 files changed, 21 insertions, 13 deletions
diff --git a/cmd.h b/cmd.h
index 2f23ddc..b668b26 100644
--- a/cmd.h
+++ b/cmd.h
@@ -1,4 +1,3 @@
extern int mode;
void cmd_parse(Rune r);
-#define cmd_reset() cmd_parse(GKEsc);
diff --git a/exec.c b/exec.c
index 293b49a..da95c70 100644
--- a/exec.c
+++ b/exec.c
@@ -21,6 +21,7 @@
#include "evnt.h"
extern W *curwin;
+void chwin(W *);
void repaint(void);
void die(char *);
@@ -76,7 +77,7 @@ ex_run(W *w, unsigned p0)
e = lookup(&w->eb->b, p0, &p1);
if (e && e->f(win_text(w), w->eb, p1))
if (w == curwin && win_text(w) != w)
- curwin = win_tag_toggle(w);
+ chwin(win_tag_toggle(w));
return 0;
}
@@ -364,7 +365,7 @@ new(W *w, EBuf *eb, unsigned p0)
{
w = win_new();
if (w)
- curwin = win_tag_toggle(w);
+ chwin(win_tag_toggle(w));
else
err(eb, p0, "no more windows");
return 0;
@@ -375,7 +376,7 @@ del(W *w, EBuf *eb, unsigned p0)
{
w = win_kill(w);
if (w)
- curwin = w;
+ chwin(w);
else
err(eb, p0, "last window");
return 0;
diff --git a/main.c b/main.c
index 3cad2b9..8140dae 100644
--- a/main.c
+++ b/main.c
@@ -27,6 +27,13 @@ static struct gui *g;
static int clicks;
+void
+chwin(W *w)
+{
+ cmd_parse(GKEsc); /* reset command parser state */
+ curwin = w;
+}
+
static int
risword(Rune r)
{
@@ -34,6 +41,12 @@ risword(Rune r)
}
static void
+resetclicks()
+{
+ clicks = 0;
+}
+
+static void
redraw()
{
static W *old;
@@ -46,12 +59,6 @@ redraw()
needsredraw = 0;
}
-static void
-resetclicks()
-{
- clicks = 0;
-}
-
void
repaint()
{
@@ -98,7 +105,7 @@ gev(int fd, int flag, void *unused)
resizing = 1;
break;
}
- curwin = mousewin;
+ chwin(mousewin);
p0 = win_at(mousewin, e.mouse.x, e.mouse.y);
selbeg = p0;
ev_alarm(DoubleClick, resetclicks);
diff --git a/vicmd.w b/vicmd.w
index 5fdfac0..add0cba 100644
--- a/vicmd.w
+++ b/vicmd.w
@@ -18,7 +18,7 @@ then executed on the currently focused window. We try to follow the
@c
@<Header files to include@>@/
-@<External variables@>@/
+@<External variables and functions@>@/
@<Local types@>@/
@<Predeclared functions@>@/
@<File local variables@>@/
@@ -242,6 +242,7 @@ window. This window is accessible via a global program variable.
@<External...@>=
extern W *curwin;
+void chwin(W *);
@* Insertion mode. Insertions can be replayed---either using a count or
using the repeat command---so we keep track of all the typed runes in the
@@ -1117,7 +1118,7 @@ keyboard driven editor with minimal visual footprint.
static int a_tag(char buf, Cmd c, Cmd mc)
{
(void)buf; @+(void)c; @+(void)mc;
- curwin = win_tag_toggle(curwin);
+ chwin(win_tag_toggle(curwin));
return 0;
}