Less room for conversion, and best to do the work when it is needed.
Signed-off-by: NeilBrown <neil@brown.name>
if (ci->comm)
return ci->comm->func(ci);
- vci->hx = ci->x;
- vci->hy = ci->y;
-
/* If 'home' is set, search from there, else search
* from focus
*/
if (ret)
/* 'p' might have been destroyed */
break;
- if (ci->hx >= 0) {
- vci->hx += p->x;
- vci->hy += p->y;
- }
p = p->parent;
}
return ret;
return NULL;
return cr.p;
}
+
+/* convert pane-relative co-ords to absolute */
+void pane_absxy(struct pane *p, int *x, int *y)
+{
+ while (p) {
+ *x += p->x;
+ *y += p->y;
+ p = p->parent;
+ }
+}
+
+/* Convert absolute c-ords to relative */
+void pane_relxy(struct pane *p, int *x, int *y)
+{
+ while (p) {
+ *x -= p->x;
+ *y -= p->y;
+ p = p->parent;
+ }
+}
+
+void pane_map_xy(struct pane *orig, struct pane *target, int *x, int *y)
+{
+ pane_absxy(orig, x, y);
+ pane_relxy(target, x, y);
+}
struct pane *home, *focus;
int numeric, extra;
int x,y; /* relative to focus */
- int hx, hy; /* x,y mapped to 'home' */
char *str, *str2;
struct mark *mark, *mark2;
struct command *comm, *comm2;
void pane_text(struct pane *p, wchar_t ch, char *attrs, int x, int y);
char *pane_attr_get(struct pane *p, char *key);
char *pane_mark_attr(struct pane *p, struct mark *m, int forward, char *key);
+void pane_absxy(struct pane *p, int *x, int *y);
+void pane_relxy(struct pane *p, int *x, int *y);
+void pane_map_xy(struct pane *orig, struct pane *target, int *x, int *y);
struct pane *call_pane(char *key, struct pane *focus, int numeric,
struct mark *m, int extra);
PyDict_SetItemString(kwds, "numeric", Py_BuildValue("i", ci->numeric));
PyDict_SetItemString(kwds, "extra", Py_BuildValue("i", ci->extra));
PyDict_SetItemString(kwds, "xy", Py_BuildValue("ii", ci->x, ci->y));
- PyDict_SetItemString(kwds, "hxy", Py_BuildValue("ii", ci->hx, ci->hy));
if (pc->home_func)
PyDict_SetItemString(kwds, "data", ci->home->data);
PyObject *a;
int i;
int numeric_set = 0, extra_set = 0;
- int xy_set = 0, hxy_set = 0;
+ int xy_set = 0;
if (!PyTuple_Check(args))
return 0;
ci->x = PyInt_AsLong(n1);
ci->y = PyInt_AsLong(n2);
xy_set = 1;
- } else if (!hxy_set) {
- ci->hx = PyInt_AsLong(n1);
- ci->hy = PyInt_AsLong(n2);
- hxy_set = 1;
} else {
- PyErr_SetString(PyExc_TypeError, "Only two tuples permitted");
+ PyErr_SetString(PyExc_TypeError, "Only one tuple permitted");
return 0;
}
} else if (Py_TYPE(a) == &CommType) {
int l;
struct cmd_info ci2 = {0};
+
l = strlen(im->mode) + strlen(ci->str) + 1;
ci2.key = malloc(l);
strcat(strcpy(ci2.key, im->mode), ci->str);
ci2.focus = ci->home;
ci2.numeric = im->numeric;
ci2.extra = im->extra;
- ci2.x = ci->hx;
- ci2.y = ci->hy;
+ ci2.x = ci->x; ci2.y = ci->y;
+ pane_map_xy(ci->focus, ci2.focus, &ci2.x, &ci2.y);
im->mode = "";
im->numeric = NO_NUMERIC;
int mid = vd->scroll_bar_y;
char *key;
int num;
+ int cihx, cihy;
- if (ci->hx != 0)
+ cihx = ci->x; cihy = ci->y;
+ pane_map_xy(ci->focus, ci->home, &cihx, &cihy);
+
+ if (cihx != 0)
return 0;
if (p->h <= 4)
return 0;
key = "Move-View-Small";
num = RPT_NUM(ci);
- if (ci->hy == mid-1) {
+ if (cihy == mid-1) {
/* scroll up */
num = -num;
- } else if (ci->hy < mid-1) {
+ } else if (cihy < mid-1) {
/* big scroll up */
num = -num;
key = "Move-View-Large";
- } else if (ci->hy == mid+1) {
+ } else if (cihy == mid+1) {
/* scroll down */
- } else if (ci->hy > mid+1 && ci->hy < p->h-1) {
+ } else if (cihy > mid+1 && cihy < p->h-1) {
key = "Move-View-Large";
} else
return 0;
struct mark *m;
int y = rl->header_lines - rl->skip_lines;
int found = 0;
- int cihy;
+ int cihx, cihy;
render_lines_other_move_func(ci);
m = vmark_first(p, rl->typenum);
- cihy = ci->hy;
- if (y > ci->hy)
+ cihx = ci->x; cihy = ci->y;
+ pane_map_xy(ci->focus, ci->home, &cihx, &cihy);
+
+ if (y > cihy)
/* x,y is in header line - try lower */
cihy = y;
- while (y <= ci->hy && m && m->mdata) {
- int cx = ci->hx, cy = cihy, o = -1;
+ while (y <= cihy && m && m->mdata) {
+ int cx = cihx, cy = cihy, o = -1;
render_line(p, m->mdata, &y, 0, &cx, &cy, &o);
if (o >= 0) {
struct mark *m2 = call_render_line_offset(p, m, o);