if (strcmp(ci->key, "PointDup") == 0) {
struct point *pt = NULL;
- if (ci->home->point)
- point_dup(ci->home->point, &pt);
- ci->mark = &pt->m;
+ ci->mark = NULL;
+ if (ci->home->point) {
+ if (ci->extra == MARK_POINT) {
+ point_dup(ci->home->point, &pt);
+ ci->mark = &pt->m;
+ }
+ if (ci->extra == MARK_UNGROUPED)
+ ci->mark = mark_dup(&ci->home->point->m, 1);
+ }
return 1;
}
return ci.extra;
}
+static inline struct pane *doc_get_pane(struct pane *p)
+{
+ struct cmd_info ci = {0};
+ ci.focus = p;
+ ci.key = "doc:find-view";
+ ci.comm2 = NULL;
+ if (key_handle_focus(&ci) == 0)
+ return NULL;
+ return ci.home;
+}
+
/* TEMP HACK - please fix */
doc_set_attr(esi->end, "highlight", NULL);
- ci2.pointp = &esi->end;
+ ci2.focus = esi->target;
ci2.mark = mark_dup(esi->start, 1);
ci2.str = doc_getstr(esi->search, NULL);
ci2.key = "text-search";
esi->target = ci2.focus;
memset(&ci2, 0, sizeof(ci2));
ci2.key = "PointDup";
+ ci2.extra = MARK_POINT;
ci2.focus = esi->target;
key_handle_focus(&ci2);
if (!ci2.mark) {
DEF_CMD(text_search)
{
- struct point *pt;
struct mark *m;
+ struct pane *dp;
struct doc *d;
unsigned short *rxl;
struct match_state *st;
int since_start, len;
- if (!ci->pointp || !ci->str|| !ci->mark)
- return 0;
- pt = *ci->pointp;
- d = pt->doc;
+ if (!ci->str|| !ci->mark)
+ return -1;
+
+ dp = doc_get_pane(ci->focus);
+ if (!dp)
+ return -1;
+ d = dp->data;
m = ci->mark;
rxl = rxl_parse(ci->str, NULL, 0);
if (!ci->str || !ci->str[0])
return -1;
- ci2.pointp = pane_point(ci->focus);
- m = mark_dup(&(*ci2.pointp)->m, 1);
+
+ ci2.key = "PointDup";
+ ci2.focus = ci->home;
+ ci2.extra = MARK_UNGROUPED;
+ key_handle_focus(&ci2);
+ m = ci2.mark;
+
+ memset(&ci2, 0, sizeof(ci2));
+ ci2.focus = ci->home;
ci2.mark = m;
ci2.str = ci->str;
ci2.key = "text-search";