]> git.neil.brown.name Git - edlib.git/commitdiff
Discard key_handle_xy API
authorNeilBrown <neil@brown.name>
Mon, 22 Feb 2016 06:38:07 +0000 (17:38 +1100)
committerNeilBrown <neil@brown.name>
Mon, 22 Feb 2016 06:38:07 +0000 (17:38 +1100)
Fold this into lib-input, the only place that uses it.

Signed-off-by: NeilBrown <neil@brown.name>
core-keymap.c
core.h
lang-python.c
lib-input.c

index 2508abd18e1501492631592ca48085ba9e567ae7..bf553a21977de33bd1c8ae635d7e20fe2741cc1a 100644 (file)
@@ -340,39 +340,3 @@ int key_handle(const struct cmd_info *ci)
        return key_handle_filter(ci);
 }
 
-int key_handle_xy(struct cmd_info *ci)
-{
-       /* Handle this in child with x,y co-ords */
-       struct pane *p = ci->home;
-       int x = ci->x;
-       int y = ci->y;
-       if (!p)
-               p = ci->focus;
-
-       while (1) {
-               struct pane *t, *chld = NULL;
-
-               list_for_each_entry(t, &p->children, siblings) {
-                       if (x < t->x || x >= t->x + t->w)
-                               continue;
-                       if (y < t->y || y >= t->y + t->h)
-                               continue;
-                       if (chld == NULL || t->z > chld->z)
-                               chld = t;
-               }
-               /* descend into chld */
-               if (!chld)
-                       break;
-               x -= chld->x;
-               y -= chld->y;
-               p = chld;
-               if (!ci->mark)
-                       ci->mark = p->pointer;
-       }
-       ci->x = x;
-       ci->y = y;
-       ci->focus = p;
-       ci->home = p;
-       ci->comm = NULL;
-       return key_handle(ci);
-}
diff --git a/core.h b/core.h
index 9ea863cb226792a2a049302a2a7f925fb5d3b2a2..7d71b09ce1d8685a53c09006fb6ff95db1ab532b 100644 (file)
--- a/core.h
+++ b/core.h
@@ -300,7 +300,6 @@ struct map *key_alloc(void);
 void key_free(struct map *m);
 int key_handle_filter(const struct cmd_info *ci);
 int key_handle(const struct cmd_info *ci);
-int key_handle_xy(struct cmd_info *ci);
 int key_lookup(struct map *m, const const struct cmd_info *ci);
 struct command *key_lookup_cmd(struct map *m, char *c);
 void key_add(struct map *map, char *k, struct command *comm);
index 986fc078c665f4efc9f633b1b72e6beacb452bdb..d6af5b77772dbacc96f0789790e4c25eeda20216 100644 (file)
@@ -321,34 +321,6 @@ static PyObject *Pane_call(Pane *self, PyObject *args, PyObject *kwds)
        return PyInt_FromLong(rv);
 }
 
-static PyObject *Pane_call_xy(Pane *self, PyObject *args, PyObject *kwds)
-{
-       struct cmd_info ci = {0};
-       int rv;
-
-       ci.focus = self->pane;
-
-       rv = get_cmd_info(&ci, args, kwds);
-
-       if (rv <= 0)
-               return NULL;
-       if (rv != 2) {
-               PyErr_SetString(PyExc_TypeError, "x,y not given with call_xy");
-               return NULL;
-       }
-       rv = key_handle_xy(&ci);
-
-       if (!rv) {
-               Py_INCREF(Py_None);
-               return Py_None;
-       }
-       if (rv < 0) {
-               PyErr_SetObject(Edlib_CommandFailed, PyInt_FromLong(rv));
-               return NULL;
-       }
-       return PyInt_FromLong(rv);
-}
-
 static PyObject *Pane_call_filter(Pane *self, PyObject *args, PyObject *kwds)
 {
        struct cmd_info ci = {0};
@@ -470,8 +442,6 @@ static PyMethodDef pane_methods[] = {
         "Trigger refresh on this pane"},
        {"call", (PyCFunction)Pane_call, METH_VARARGS|METH_KEYWORDS,
         "Call a command from a pane"},
-       {"call_xy", (PyCFunction)Pane_call_xy, METH_VARARGS|METH_KEYWORDS,
-        "Call a command from a pane, follow x,y out to leaf"},
        {"call_filter", (PyCFunction)Pane_call_filter, METH_VARARGS|METH_KEYWORDS,
         "Call a command from a pane, search searching from given pane, not leaf"},
        {"abs", (PyCFunction)Pane_abs, METH_VARARGS,
index 40a3c25a91327c21cfd9441613e8b2013a832bde..24ee3a4b587849265fe4553fc0f1dc92a9b8b722 100644 (file)
@@ -98,7 +98,28 @@ DEF_CMD(mouse_event)
        im->numeric = NO_NUMERIC;
        im->extra = 0;
 
-       key_handle_xy(&ci2);
+       while (1) {
+               struct pane *t, *chld = NULL;
+
+               list_for_each_entry(t, &ci2.focus->children, siblings) {
+                       if (ci2.x < t->x || ci2.x >= t->x + t->w)
+                               continue;
+                       if (ci2.y < t->y || ci2.y >= t->y + t->h)
+                               continue;
+                       if (chld == NULL || t->z > chld->z)
+                               chld = t;
+               }
+               /* descend into chld */
+               if (!chld)
+                       break;
+               ci2.x -= chld->x;
+               ci2.y -= chld->y;
+               ci2.focus = chld;
+               if (!ci2.mark)
+                       ci2.mark = chld->pointer;
+       }
+
+       key_handle(&ci2);
        return 0;
 }