return 1;
}
+ if (strcmp(ci->key, "doc:find") == 0) {
+ ci->misc = d;
+ return 1;
+ }
+
if (strcmp(ci->key, "doc:vmark-get") == 0) {
ci->mark = do_vmark_first(d, ci->numeric);
ci->mark2 = do_vmark_last(d, ci->numeric);
DEF_CMD(docs_bury)
{
- struct pane *p = doc_get_pane(ci->home);
- struct doc *d = p->data;
+ struct doc *d = doc_from_pane(ci->home);
doc_destroy(d);
return 1;
return ci.extra;
}
-static inline struct pane *doc_get_pane(struct pane *p)
+static inline struct doc *doc_from_pane(struct pane *p)
{
struct cmd_info ci = {0};
ci.focus = p;
- ci.key = "doc:find-view";
- ci.comm2 = NULL;
+ ci.key = "doc:find";
if (key_handle_focus(&ci) == 0)
return NULL;
- return ci.home;
+ return ci.misc;
}
DEF_CMD(dir_close)
{
- struct pane *p = doc_get_pane(ci->home);
- struct doc *d = p->data;
+ struct doc *d = doc_from_pane(ci->home);
doc_destroy(d);
return 1;
DEF_CMD(search_forward)
{
struct es_info *esi = ci->home->data;
- struct pane *dp = doc_get_pane(esi->target);
- struct doc *d = dp ? dp->data : NULL;
+ struct doc *d = doc_from_pane(esi->target);
struct stk *s;
char *str;
bool first = 1;
DEF_CMD(search_add)
{
struct es_info *esi = ci->home->data;
- struct pane *dp = doc_get_pane(esi->target);
- struct doc *d = dp ? dp->data : NULL;
+ struct doc *d = doc_from_pane(esi->target);
wint_t wch;
char b[5];
struct cmd_info ci2 = {0};
DEF_CMD(count_lines)
{
- struct pane *dp = doc_get_pane(ci->home);
- struct doc *d = dp->data;
+ struct doc *d = doc_from_pane(ci->home);
/* FIXME optimise this away most of the time */
count_calculate(d, NULL, NULL);
DEF_CMD(text_search)
{
struct mark *m;
- struct pane *dp;
struct doc *d;
unsigned short *rxl;
struct match_state *st;
if (!ci->str|| !ci->mark)
return -1;
- dp = doc_get_pane(ci->focus);
- if (!dp)
+ d = doc_from_pane(ci->focus);
+ if (!d)
return -1;
- d = dp->data;
-
m = ci->mark;
rxl = rxl_parse(ci->str, NULL, 0);
if (!rxl)
int i;
int mid;
struct editor *ed = pane2ed(ci->home);
- struct pane *dp = doc_get_pane(ci->home);
- struct doc *d = dp->data;
+ struct doc *d = doc_from_pane(ci->home);
pane_check_size(p);
p->cx = 0; p->cy = 0;
struct cmd_info ci2 = {0};
int ret = 0;
struct mark *m;
- struct pane *dp = doc_get_pane(ci->home);
- struct doc *d = dp->data;
+ struct doc *d = doc_from_pane(ci->home);
m = mark_dup(ci->mark, 1);
ci2.focus = ci->focus;
DEF_CMD(emacs_kill_doc)
{
- struct pane *p = doc_get_pane(ci->home);
- struct doc *d = p ? p->data : NULL;
+ struct doc *d = doc_from_pane(ci->home);
if (d)
doc_destroy(d);
*/
struct cmd_info ci2 = {0};
struct complete_data *cd = ci->home->data;
- struct pane *dp = doc_get_pane(ci->home);
- struct doc *d = dp ? dp->data : NULL;
+ struct doc *d = doc_from_pane(ci->home);
int plen;
if (!d || !ci->mark)
char *body = pane_attr_get(ci->focus, "line-format");
struct rf_data *rf = ci->home->data;
struct buf ret;
- struct pane *dp = doc_get_pane(ci->home);
- struct doc *d = dp ? dp->data : NULL;
+ struct doc *d = doc_from_pane(ci->home);
struct mark *m = ci->mark;
struct mark *pm = ci->mark2;
char *n;
buf_append(&ret, ch);
continue;
}
- val = doc_attr(dp, m, 1, buf);
+ val = doc_attr(d->home, m, 1, buf);
if (!val)
val = "-";
if (*n != ':') {
DEF_CMD(render_line_prev)
{
struct mark *m = ci->mark;
- struct pane *dp = doc_get_pane(ci->home);
- struct doc *d = dp->data;
+ struct doc *d = doc_from_pane(ci->home);
if (RPT_NUM(ci) == 0 && doc_following(d, m) != WEOF)
/* always at start-of-line */
DEF_CMD(format_move_line)
{
- struct pane *dp = doc_get_pane(ci->focus);
- struct doc *d = dp->data;
+ struct doc *d = doc_from_pane(ci->focus);
int rpt = RPT_NUM(ci);
struct rf_data *rf = ci->home->data;
/* Horizonal movement - adjust ->rpos within fields, or
* move to next line
*/
- struct pane *dp = doc_get_pane(ci->focus);
- struct doc *d = dp->data;
+ struct doc *d = doc_from_pane(ci->focus);
struct rf_data *rf = ci->home->data;
int rpt = RPT_NUM(ci);
DEF_CMD(render_hex_eol)
{
- struct pane *dp = doc_get_pane(ci->home);
- struct doc *d = dp->data;
+ struct doc *d = doc_from_pane(ci->home);
struct editor *ed = pane2ed(ci->home);
wint_t ch = 1;
int rpt = RPT_NUM(ci);
struct buf ret;
struct cmd_info ci2 = {0};
struct mark *m = NULL;
- struct pane *dp = doc_get_pane(ci->home);
- struct doc *d = dp ? dp->data : NULL;
+ struct doc *d = doc_from_pane(ci->home);
struct mark *pm = ci->mark2;
int pos;
int i;
/* If ->numeric is 0, round down to multiple of 16.
* if it is 1, subtract a further 16.
*/
- struct pane *dp = doc_get_pane(ci->home);
- struct doc *d = dp->data;
+ struct doc *d = doc_from_pane(ci->home);
struct cmd_info ci2 = {0};
int to, from;
vm->mdata = NULL;
mark_free(vm);
}
- while ((vm = vmark_next(rm)) != NULL &&
- mark_same_pane(p, rm, vm, &ci2)) {
+ while ((vm = vmark_next(rm)) != NULL && mark_same_pane(p, rm, vm, &ci2)) {
free(vm->mdata);
vm->mdata = NULL;
mark_free(vm);