still tring to get 'doc' references out of non-core/doc code.
Signed-off-by: NeilBrown <neil@brown.name>
struct mark *point_dup(struct mark *p);
wint_t mark_step(struct doc *d, struct mark *m, int forward, int move, struct cmd_info *ci);
wint_t mark_step2(struct doc *d, struct mark *m, int forward, int move);
+wint_t mark_step_pane(struct pane *p, struct mark *m, int forward, int move, struct cmd_info *ci);
+
wint_t mark_next(struct doc *d, struct mark *m);
wint_t mark_prev(struct doc *d, struct mark *m);
wint_t mark_next_pane(struct pane *p, struct mark *m);
{
return mark_step2(d, m, 1, 0);
}
+static inline wint_t doc_following_pane(struct pane *p, struct mark *m)
+{
+ return mark_step_pane(p, m, 1, 0, NULL);
+}
static inline wint_t doc_prior(struct doc *d, struct mark *m)
{
return mark_step2(d, m, 0, 0);
DEF_CMD(text_search)
{
struct mark *m, *endmark = NULL;;
- struct doc *d;
unsigned short *rxl;
struct match_state *st;
int since_start, len;
- if (!ci->str|| !ci->mark)
+ if (!ci->str|| !ci->mark || !ci->focus)
return -1;
- d = doc_from_pane(ci->focus);
- if (!d)
- return -1;
m = ci->mark;
rxl = rxl_parse(ci->str, NULL, 1);
if (!rxl)
st = rxl_prepare(rxl);
since_start = -1;
while (since_start < 0 || len != -2) {
- wint_t wch = mark_next(d, m);
+ wint_t wch = mark_next_pane(ci->focus, m);
if (wch == WEOF)
break;
struct move_command *mv = container_of(ci->comm, struct move_command, cmd);
int ret = 0;
struct mark *m;
- struct doc *d = doc_from_pane(ci->home);
m = mark_dup(ci->mark, 1);
if (strcmp(mv->type, "Move-EOL") == 0 &&
mv->direction == 1 && RPT_NUM(ci) == 1 &&
- doc_following(d, m) == '\n')
+ doc_following_pane(ci->focus, m) == '\n')
ret = call3("Move-Char", ci->focus, mv->direction * RPT_NUM(ci), m);
else
ret = call3(mv->type, ci->focus, mv->direction * RPT_NUM(ci), m);
int field = 0;
int rv;
- if (!d || !ci->mark)
+ if (!d || !ci->mark || !ci->focus)
return -1;
if (pm && !mark_same_pane(ci->home, pm, m, NULL))
pm = NULL;
- ch = doc_following(d, m);
+ ch = doc_following_pane(ci->focus, m);
if (ch == WEOF)
return 1;
buf_init(&ret);
;
else {
buf_append(&ret, '\n');
- mark_next(d, m);
+ mark_next_pane(ci->focus, m);
}
}
rv = comm_call(ci->comm2, "callback:render", ci->focus, 0, NULL,
DEF_CMD(render_line_prev)
{
struct mark *m = ci->mark;
- struct doc *d = doc_from_pane(ci->home);
if (RPT_NUM(ci) == 0)
/* always at start-of-line */
return 1;
- if (mark_prev(d, m) == WEOF)
+ if (mark_prev_pane(ci->home, m) == WEOF)
/* Hit start-of-file */
return -1;
return 1;
DEF_CMD(format_move_line)
{
- struct doc *d = doc_from_pane(ci->focus);
int rpt = RPT_NUM(ci);
struct rf_data *rf = ci->home->data;
while (rpt > 1) {
- if (mark_next(d, ci->mark) == WEOF)
+ if (mark_next_pane(ci->focus, ci->mark) == WEOF)
break;
rpt -= 1;
}
while (rpt < -1) {
- if (mark_prev(d, ci->mark) == WEOF)
+ if (mark_prev_pane(ci->focus, ci->mark) == WEOF)
break;
rpt += 1;
}
/* Horizonal movement - adjust ->rpos within fields, or
* move to next line
*/
- struct doc *d = doc_from_pane(ci->focus);
struct rf_data *rf = ci->home->data;
int rpt = RPT_NUM(ci);
if (rf->fields < 2)
return 1;
- while (rpt > 0 && doc_following(d, ci->mark) != WEOF) {
+ while (rpt > 0 && doc_following_pane(ci->focus, ci->mark) != WEOF) {
if (ci->mark->rpos < rf->fields - rf->home_field + 1)
ci->mark->rpos += 1;
else {
- if (mark_next(d, ci->mark) == WEOF)
+ if (mark_next_pane(ci->focus, ci->mark) == WEOF)
break;
ci->mark->rpos = -rf->home_field;
}
if (ci->mark->rpos > -rf->home_field)
ci->mark->rpos -= 1;
else {
- if (mark_prev(d, ci->mark) == WEOF)
+ if (mark_prev_pane(ci->focus, ci->mark) == WEOF)
break;
ci->mark->rpos = rf->fields - rf->home_field + 1;
}
DEF_CMD(render_hex_eol)
{
- struct doc *d = doc_from_pane(ci->home);
wint_t ch = 1;
int rpt = RPT_NUM(ci);
int pos;
pos = attr_find_int(*mark_attr(ci->mark), "chars");
while (rpt > 0 && ch != WEOF) {
while ((pos & 15) != 15 &&
- (ch = mark_next(d, ci->mark)) != WEOF)
+ (ch = mark_next_pane(ci->focus, ci->mark)) != WEOF)
pos += 1;
rpt -= 1;
if (rpt) {
- ch = mark_next(d, ci->mark);
+ ch = mark_next_pane(ci->focus, ci->mark);
pos += 1;
}
}
while (rpt < 0 && ch != WEOF) {
while ((pos & 15) != 0 &&
- (ch = mark_prev(d, ci->mark)) != WEOF)
+ (ch = mark_prev_pane(ci->focus, ci->mark)) != WEOF)
pos -= 1;
rpt += 1;
if (rpt) {
- ch = mark_prev(d, ci->mark);
+ ch = mark_prev_pane(ci->focus, ci->mark);
pos -= 1;
}
}
struct buf ret;
struct cmd_info ci2 = {0};
struct mark *m = NULL;
- struct doc *d = doc_from_pane(ci->home);
struct mark *pm = ci->mark2;
int pos;
int i;
char buf[10];
int rv;
- if (!d || !ci->mark)
+ if (!ci->focus || !ci->mark)
return -1;
ci2.key = "CountLines";
pos = attr_find_int(*mark_attr(ci->mark), "chars");
buf_init(&ret);
- if (doc_following(d, ci->mark) == WEOF)
+ if (doc_following_pane(ci->focus, ci->mark) == WEOF)
goto done;
sprintf(buf, "<bold>%08x:</> ", pos);
buf_concat(&ret, buf);
ci->numeric <= ret.len)
goto done;
- ch = mark_next(d, m2);
+ ch = mark_next_pane(ci->focus, m2);
if (ch == WEOF)
strcpy(buf, " ");
else
for (i = 0; i < 16; i++) {
wint_t ch;
- ch = mark_next(d, m);
+ ch = mark_next_pane(ci->focus, m);
if (ch == WEOF)
ch = ' ';
if (ch < ' ')
/* If ->numeric is 0, round down to multiple of 16.
* if it is 1, subtract a further 16.
*/
- struct doc *d = doc_from_pane(ci->home);
struct cmd_info ci2 = {0};
int to, from;
if (ci->numeric && to >= 16)
to -= 16;
while (to < from) {
- mark_prev(d, ci->mark);
+ mark_prev_pane(ci->focus, ci->mark);
from -= 1;
}
return 1;