summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux2014-09-05 21:02:12 -0400
committerQuentin Carbonneaux2014-09-05 21:02:12 -0400
commit7b186bbeef8d205a90b800a69bb7504c7c3614fd (patch)
tree40a21b6a58a6f21809375e3e133d133ccaeaa68e
parentbf4a4fdd88c686a0774d8321c6462fbe4588362a (diff)
use middle button to execute a command
-rw-r--r--exec.c10
-rw-r--r--exec.h2
-rw-r--r--main.c3
-rw-r--r--vicmd.w2
4 files changed, 10 insertions, 7 deletions
diff --git a/exec.c b/exec.c
index e4d6ad8..956f813 100644
--- a/exec.c
+++ b/exec.c
@@ -53,15 +53,15 @@ static ECmd etab[] = {
* the list of builtins, if not found, it is run in a shell.
*/
int
-ex_run(unsigned p0)
+ex_run(W *w, unsigned p0)
{
unsigned p1;
ECmd *e;
- e = lookup(&curwin->eb->b, p0, &p1);
- if (e && e->f(win_text(curwin), curwin->eb, p1))
- if (win_text(curwin) != curwin)
- curwin = win_tag_toggle(curwin);
+ 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);
return 0;
}
diff --git a/exec.h b/exec.h
index fafac79..66a4e0b 100644
--- a/exec.h
+++ b/exec.h
@@ -1,4 +1,4 @@
-int ex_run(unsigned);
+int ex_run(W *, unsigned);
int ex_look(W *, Rune *, unsigned);
int ex_put(EBuf *, char *);
int ex_get(EBuf *, char *);
diff --git a/main.c b/main.c
index 3f3774c..55d6a7c 100644
--- a/main.c
+++ b/main.c
@@ -103,6 +103,9 @@ gev(int fd, int flag, void *unused)
eb_setmark(curwin->eb, SelEnd, p1);
}
goto Setcursor;
+ } else if (e.mouse.button == GBMiddle) {
+ p0 = win_at(mousewin, e.mouse.x, e.mouse.y);
+ ex_run(mousewin, p0);
} else if (e.mouse.button == GBWheelUp) {
win_scroll(mousewin, -4);
} else if (e.mouse.button == GBWheelDown) {
diff --git a/vicmd.w b/vicmd.w
index 423cdf3..b4e8220 100644
--- a/vicmd.w
+++ b/vicmd.w
@@ -1121,7 +1121,7 @@ static int a_tag(char buf, Cmd c, Cmd mc)
static int a_run(char buf, Cmd c, Cmd mc)
{
(void)buf; @+(void) c; @+(void) mc;
- return ex_run(curwin->cu);
+ return ex_run(curwin, curwin->cu);
}
@ The insertion commands are all treated in the following procedure.