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);
-}
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);
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};
"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,
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;
}