### doc-text
+- [ ] a single undo should never cross a save point!
- [ ] use larger buffers for adding text - especially when filling from pipe.
e.g. new buffer doubles each time??
- [ ] support disable of undo in text, e.g. for copybuf document.
return 1;
}
-DEF_CMD(log_step)
+static int log_step(struct pane *home safe, struct mark *mark safe, int num, int num2)
{
- struct doc *d = ci->home->data;
+ struct doc *d = home->data;
struct log *log = container_of(d, struct log, doc);
- struct mark *m = ci->mark;
- bool forward = ci->num;
- bool move = ci->num2;
+ struct mark *m = mark;
+ bool forward = num;
+ bool move = num2;
struct doc_ref ref;
wint_t ret;
- if (!m)
- return Enoarg;
-
ref = m->ref;
if (forward) {
if (!ref.b)
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&log_step, "", ci->home, forward, m, NULL, 1);
+ ret = log_step(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&log_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return log_step(ci->home, m, ci->num2 > 0, 0);
}
DEF_CMD(log_destroy)
key_add_chain(log_map, doc_default_cmd);
key_add(log_map, "doc:content", &log_content);
key_add(log_map, "doc:set-ref", &log_set_ref);
- key_add(log_map, "doc:step", &log_step);
key_add(log_map, "doc:char", &log_char);
key_add(log_map, "doc:destroy", &log_destroy);
key_add(log_map, "doc:log:append", &log_append);
return 1;
}
-DEF_CMD(dir_step)
+static int dir_step(struct pane *home safe, struct mark *mark safe,
+ int num, int num2)
{
- struct doc *doc = ci->home->data;
- struct mark *m = ci->mark;
- bool forward = ci->num;
- bool move = ci->num2;
+ struct doc *doc = home->data;
+ struct mark *m = mark;
+ bool forward = num;
+ bool move = num2;
struct directory *dr = container_of(doc, struct directory, doc);
struct dir_ent *d;
wint_t ret = '\n';
- if (!m)
- return Enoarg;
d = m->ref.d;
if (forward) {
if (d == NULL)
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&dir_step, "", ci->home, forward, m, NULL, 1);
+ ret = dir_step(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&dir_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return dir_step(ci->home, m, ci->num2 > 0, 0);
}
DEF_CMD(dir_set_ref)
key_add(doc_map, "doc:same-file", &dir_same_file);
key_add(doc_map, "doc:set-ref", &dir_set_ref);
key_add(doc_map, "doc:get-attr", &dir_doc_get_attr);
- key_add(doc_map, "doc:step", &dir_step);
key_add(doc_map, "doc:char", &dir_char);
key_add(doc_map, "doc:cmd-f", &dir_do_open);
key_add(doc_map, "doc:cmd-o", &dir_do_open_other);
return 1;
}
-DEF_CMD(docs_step)
+static int docs_step(struct pane *home safe, struct mark *mark safe,
+ int num, int num2)
{
- struct doc *doc = ci->home->data;
- struct mark *m = ci->mark;
- bool forward = ci->num;
- bool move = ci->num2;
+ struct doc *doc = home->data;
+ struct mark *m = mark;
+ bool forward = num;
+ bool move = num2;
int ret;
struct pane *p, *next;
struct docs *d = container_of(doc, struct docs, doc);
- if (!m)
- return Enoarg;
-
p = m->ref.p;
if (forward) {
/* report on d */
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&docs_step, "", ci->home, forward, m, NULL, 1);
+ ret = docs_step(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&docs_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return docs_step(ci->home, m, ci->num2 > 0, 0);
}
DEF_CMD(docs_set_ref)
key_add_chain(docs_map, doc_default_cmd);
key_add(docs_map, "doc:set-ref", &docs_set_ref);
key_add(docs_map, "doc:get-attr", &docs_doc_get_attr);
- key_add(docs_map, "doc:step", &docs_step);
key_add(docs_map, "doc:char", &docs_char);
key_add(docs_map, "doc:destroy", &docs_destroy);
key_add(docs_map, "doc:cmd-f", &docs_do_open);
return cnt;
}
-DEF_CMD(email_step)
+static int email_step(struct pane *home safe, struct mark *mark safe,
+ int num, int num2)
{
- struct pane *p = ci->home;
+ struct pane *p = home;
struct email_view *evi = p->data;
wint_t ret;
int n = -1;
- if (!ci->mark)
- return Enoarg;
- if (ci->num) {
- ret = home_call(p->parent, "doc:char", ci->focus,
- ci->num2 ? 1 : 0,
- ci->mark, evi->invis,
- ci->num2 ? 0 : 1);
- n = get_part(p->parent, ci->mark);
- if (ci->num2 && is_spacer(n)) {
+ if (num) {
+ ret = home_call(p->parent, "doc:char", home,
+ num2 ? 1 : 0,
+ mark, evi->invis,
+ num2 ? 0 : 1);
+ n = get_part(p->parent, mark);
+ if (num2 && is_spacer(n)) {
/* Moving in a spacer, If after valid buttons,
* move to end
*/
wint_t c;
unsigned int buttons;
- buttons = count_buttons(p, ci->mark);
- while ((c = doc_following(p->parent, ci->mark)) != WEOF
+ buttons = count_buttons(p, mark);
+ while ((c = doc_following(p->parent, mark)) != WEOF
&& iswdigit(c) && (c - '0') >= buttons)
- doc_next(p->parent, ci->mark);
+ doc_next(p->parent, mark);
}
} else {
- ret = home_call(p->parent, "doc:char", ci->focus,
- ci->num2 ? -1 : 0,
- ci->mark, evi->invis,
- ci->num2 ? 0 : -1);
- n = get_part(p->parent, ci->mark);
- if (is_spacer(n) && ci->num2 &&
+ ret = home_call(p->parent, "doc:char", home,
+ num2 ? -1 : 0,
+ mark, evi->invis,
+ num2 ? 0 : -1);
+ n = get_part(p->parent, mark);
+ if (is_spacer(n) && num2 &&
ret != CHAR_RET(WEOF) && iswdigit(ret & 0x1fffff)) {
/* Just stepped back over the 9 at the end of a spacer,
* Maybe step further if there aren't 10 buttons.
*/
- unsigned int buttons = count_buttons(p, ci->mark);
+ unsigned int buttons = count_buttons(p, mark);
wint_t c = ret & 0x1fffff;
while (c != WEOF && iswdigit(c) && c - '0' >= buttons)
- c = doc_prev(p->parent, ci->mark);
+ c = doc_prev(p->parent, mark);
ret = CHAR_RET(c);
}
}
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&email_step, "", ci->home,
- forward, m, NULL, 1);
+ ret = email_step(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num &&(ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&email_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return email_step(ci->home, m, ci->num2 > 0, 0);
}
DEF_CMD(email_content)
{
email_view_map = key_alloc();
key_add(email_view_map, "Free", &email_view_free);
- key_add(email_view_map, "doc:step", &email_step);
key_add(email_view_map, "doc:char", &email_char);
key_add(email_view_map, "doc:content", &email_content);
key_add(email_view_map, "doc:set-ref", &email_set_ref);
return ret;
}
-DEF_CMD(mp_step)
+static int mp_step(struct pane *home safe, struct mark *mark safe,
+ int num, int num2, const char *str)
{
- struct mp_info *mpi = ci->home->data;
+ struct mp_info *mpi = home->data;
struct mark *m1 = NULL;
- struct mark *m = ci->mark;
- const char *vis = ci->str && (int)strlen(ci->str) >= mpi->nparts ?
- ci->str : NULL;
+ struct mark *m = mark;
+ const char *vis = str && (int)strlen(str) >= mpi->nparts ?
+ str : NULL;
int n;
int ret;
* calls the document. Then make sure the marks are still in
* order.
*/
- mp_check_consistent(mpi);
- if (!m)
- return Enoarg;
mp_check_consistent(mpi);
- if (ci->num2) {
- mark_step(m, ci->num);
+ if (num2) {
+ mark_step(m, num);
pre_move(m);
}
ret = -1;
else
ret = home_call(mpi->parts[m->ref.docnum].pane,
- "doc:char", ci->focus,
- ci->num2 ? (ci->num ? 1 : -1) : 0,
- m1, ci->str,
- ci->num2 ? 0 : (ci->num ? 1 : -1),
- NULL, ci->str2, 0,0, ci->comm2);
+ "doc:char", home,
+ num2 ? (num ? 1 : -1) : 0,
+ m1, str,
+ num2 ? 0 : (num ? 1 : -1),
+ NULL, NULL);
while (ret == CHAR_RET(WEOF) || ret == -1) {
- if (!ci->num2 && m == ci->mark) {
- /* don't change ci->mark when not moving */
+ if (!num2 && m == mark) {
+ /* don't change mark when not moving */
m = mark_dup(m);
pre_move(m);
}
- if (ci->num) {
+ if (num) {
if (m->ref.docnum >= mpi->nparts)
break;
n = m->ref.docnum + 1;
ret = -1;
else
ret = home_call(mpi->parts[m->ref.docnum].pane,
- "doc:char", ci->focus,
- ci->num2 ? (ci->num ? 1 : -1) : 0,
- m1, ci->str,
- ci->num2 ? 0 : (ci->num ? 1 : -1),
- NULL, ci->str2,
- 0,0, ci->comm2);
+ "doc:char", home,
+ num2 ? (num ? 1 : -1) : 0,
+ m1, str,
+ num2 ? 0 : (num ? 1 : -1));
}
- if (ci->num2) {
- mp_normalize(mpi, ci->mark, vis);
- post_move(ci->mark);
+ if (num2) {
+ mp_normalize(mpi, mark, vis);
+ post_move(mark);
}
- if (m != ci->mark)
+ if (m != mark)
mark_free(m);
mp_check_consistent(mpi);
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&mp_step, "", ci->home, forward, m, ci->str, 1);
+ ret = mp_step(ci->home, m, forward, 1, ci->str);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&mp_step, "", ci->home, ci->num2 > 0, m, ci->str, 0);
+ return mp_step(ci->home, m, ci->num2 > 0, 0, ci->str);
}
DEF_CMD(mp_step_part)
mp_map = key_alloc();
key_add_chain(mp_map, doc_default_cmd);
key_add(mp_map, "doc:set-ref", &mp_set_ref);
- key_add(mp_map, "doc:step", &mp_step);
key_add(mp_map, "doc:char", &mp_char);
key_add(mp_map, "doc:content", &mp_content);
key_add(mp_map, "doc:get-attr", &mp_attr);
return ret;
}
-DEF_CMD(text_step)
+static int text_step(struct pane *home safe, struct mark *mark safe,
+ int num, int num2)
{
- struct doc *d = ci->home->data;
- struct mark *m = ci->mark;
- bool forward = ci->num;
- bool move = ci->num2;
+ struct doc *d = home->data;
+ struct mark *m = mark;
+ bool forward = num;
+ bool move = num2;
struct text *t = container_of(d, struct text, doc);
struct doc_ref r;
wint_t ret;
- if (!m)
- return Enoarg;
-
- ASSERT(m->owner == ci->home);
+ ASSERT(m->owner == home);
r = m->ref;
if (forward)
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&text_step, "", ci->home, forward, m, NULL, 1);
+ ret = text_step(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&text_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return text_step(ci->home, m, ci->num2 > 0, 0);
}
-DEF_CMD(text_step_bytes)
+static int text_step_bytes(struct pane *home safe, struct mark *mark safe,
+ int num, int num2)
{
- struct doc *d = ci->home->data;
- struct mark *m = ci->mark;
- bool forward = ci->num;
- bool move = ci->num2;
+ struct doc *d = home->data;
+ struct mark *m = mark;
+ bool forward = num;
+ bool move = num2;
struct text *t = container_of(d, struct text, doc);
struct doc_ref r;
wint_t ret;
if (!m)
return Enoarg;
- ASSERT(m->owner == ci->home);
+ ASSERT(m->owner == home);
r = m->ref;
if (forward)
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&text_step_bytes, "", ci->home, forward, m, NULL, 1);
+ ret = text_step_bytes(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&text_step_bytes, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return text_step_bytes(ci->home, m, ci->num2 > 0, 0);
}
static bool _text_ref_same(struct text *t safe, struct doc_ref *r1 safe,
key_add(text_map, "doc:set-attr", &text_set_attr);
key_add(text_map, "doc:get-attr", &text_doc_get_attr);
key_add(text_map, "doc:replace", &text_replace);
- key_add(text_map, "doc:step", &text_step);
key_add(text_map, "doc:char", &text_char);
- key_add(text_map, "doc:step-bytes", &text_step_bytes);
key_add(text_map, "doc:byte", &text_byte);
key_add(text_map, "doc:modified", &text_modified);
key_add(text_map, "doc:set:readonly", &text_readonly);
b64_map = key_alloc();
- key_add(b64_map, "doc:step", &base64_step);
key_add(b64_map, "doc:char", &base64_char);
- key_add(b64_map, "doc:step-bytes", &base64_step);
key_add(b64_map, "doc:byte", &base64_char);
key_add(b64_map, "doc:content", &base64_content);
key_add(b64_map, "Close", &b64_close);
static struct map *charset_map safe;
DEF_LOOKUP_CMD(charset_handle, charset_map);
-DEF_CMD(charset_step)
+static int charset_step(struct pane *home safe, struct mark *mark safe,
+ int num, int num2)
{
wint_t ret;
- wchar_t *tbl = ci->home->data;
+ wchar_t *tbl = home->data;
- ret = home_call(ci->home->parent, "doc:char", ci->focus,
- ci->num2 ? (ci->num ? 1 : -1) : 0,
- ci->mark, ci->str,
- ci->num2 ? 0 : (ci->num ? 1 : -1),
- ci->mark2, ci->str2);
+ ret = home_call(home->parent, "doc:char", home,
+ num2 ? (num ? 1 : -1) : 0,
+ mark, NULL,
+ num2 ? 0 : (num ? 1 : -1));
if (ret <= 0 || ret == CHAR_RET(WEOF))
return ret;
return CHAR_RET(tbl[ret & 0xff]);
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&charset_step, "", ci->home, forward, m, NULL, 1);
+ ret = charset_step(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&charset_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return charset_step(ci->home, m, ci->num2 > 0, 0);
}
struct win1251cb {
{
charset_map = key_alloc();
- key_add(charset_map, "doc:step", &charset_step);
key_add(charset_map, "doc:char", &charset_char);
key_add(charset_map, "doc:content", &charset_content);
0,0, ci->comm2);
}
-DEF_CMD(crop_step)
+static int crop_step(struct pane *home safe, struct mark *mark safe,
+ int num, int num2)
{
- struct pane *p = ci->home->parent;
- struct crop_data *cd = ci->home->data;
+ struct pane *p = home->parent;
+ struct crop_data *cd = home->data;
int ret;
- if (!ci->mark && !ci->mark2)
- return Enoarg;
-
/* Always force marks to be in range */
- crop(ci->mark, cd);
- crop(ci->mark2, cd);
+ crop(mark, cd);
- ret = home_call(p, "doc:char", ci->focus,
- ci->num2 ? (ci->num ? 1 : -1) : 0,
- ci->mark, ci->str,
- ci->num2 ? 0 : (ci->num ? 1 : -1),
- ci->mark2, ci->str2, 0,0, ci->comm2);
- if (crop(ci->mark, cd) || crop(ci->mark2, cd))
+ ret = home_call(p, "doc:char", home,
+ num2 ? (num ? 1 : -1) : 0,
+ mark, NULL,
+ num2 ? 0 : (num ? 1 : -1));
+ if (crop(mark, cd))
ret = CHAR_RET(WEOF);
- if (ci->num2 == 0 && ci->mark) {
- if (ci->num) {
- if (mark_same(ci->mark, cd->end))
+ if (num2 == 0) {
+ if (num) {
+ if (mark_same(mark, cd->end))
ret = CHAR_RET(WEOF);
} else {
- if (mark_same(ci->mark, cd->start))
+ if (mark_same(mark, cd->start))
ret = CHAR_RET(WEOF);
}
}
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&crop_step, "", ci->home, forward, m, NULL, 1);
+ ret = crop_step(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&crop_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return crop_step(ci->home, m, ci->num2 > 0, 0);
}
DEF_CMD(crop_clip)
key_add(crop_map, "Close", &crop_close);
key_add(crop_map, "Free", &edlib_do_free);
key_add(crop_map, "doc:write_file", &crop_write);
- key_add(crop_map, "doc:step", &crop_step);
key_add(crop_map, "doc:char", &crop_char);
key_add(crop_map, "doc:content", &crop_content);
key_add(crop_map, "Notify:clip", &crop_clip);
return -1;
}
-DEF_CMD(qp_step)
+static int qp_step(struct pane *home safe, struct mark *mark safe,
+ int num, int num2)
{
- int forward = ci->num;
- int move = ci->num2;
- struct pane *p = ci->home->parent;
+ int forward = num;
+ int move = num2;
+ struct pane *p = home->parent;
wint_t ch, c2, c3;
- struct mark *m = ci->mark;
+ struct mark *m = mark;
if (!m)
return Enoarg;
else
ch = doc_following(p, m);
if (ch != '=' && ch != ' ' && ch != '\t' && ch != '\r') {
- if (m != ci->mark) {
+ if (m != mark) {
if (move)
- mark_to_mark(ci->mark, m);
+ mark_to_mark(mark, m);
mark_free(m);
}
goto normalize;
/* assume CR-LF - skip an extra char */
if (move)
doc_next(p, m);
- if (m != ci->mark) {
+ if (m != mark) {
if (move)
- mark_to_mark(ci->mark, m);
+ mark_to_mark(mark, m);
mark_free(m);
}
ch = '\n';
goto normalize;
}
- if (m == ci->mark)
+ if (m == mark)
m = mark_dup(m);
if (!move)
doc_next(p, m);
if (hex(c2) >= 0 && hex(c3) >= 0) {
ch = hex(c2)*16 + hex(c3);
if (move)
- mark_to_mark(ci->mark, m);
+ mark_to_mark(mark, m);
}
mark_free(m);
goto normalize;
}
/* Whitespace, ignore if at eol */
if (move)
- mark_to_mark(ci->mark, m);
+ mark_to_mark(mark, m);
while ((c2 = doc_next(p, m)) == ' ' || c2 == '\t')
;
if (c2 == '\r')
if (!move)
return CHAR_RET(ch);
normalize_more:
- m = ci->mark;
+ m = mark;
/* If next is "=\n" we need to skip over it. */
if (doc_following(p, m) != '=')
return CHAR_RET(ch);
- m = mark_dup(ci->mark);
+ m = mark_dup(mark);
doc_next(p, m);
while ((c2 = doc_next(p, m)) == ' ' ||
c2 == '\t' || c2 == '\r')
mark_free(m);
return CHAR_RET(ch);
}
- mark_to_mark(ci->mark, m);
+ mark_to_mark(mark, m);
mark_free(m);
goto normalize_more;
} else {
else
ch = doc_prior(p, m);
if (ch == '\n') {
- if (m == ci->mark)
+ if (m == mark)
m = mark_dup(m);
if (!move)
doc_prev(p, m);
goto retry;
}
if (move)
- mark_to_mark(ci->mark, m);
+ mark_to_mark(mark, m);
mark_free(m);
return CHAR_RET('\n');
}
if (hex(ch) < 0) {
- if (m != ci->mark) {
+ if (m != mark) {
if (move)
- mark_to_mark(ci->mark, m);
+ mark_to_mark(mark, m);
mark_free(m);
}
return CHAR_RET(ch);
}
- if (m == ci->mark)
+ if (m == mark)
m = mark_dup(m);
else if (move)
- mark_to_mark(ci->mark, m);
+ mark_to_mark(mark, m);
if (!move)
doc_prev(p, m);
/* =HH */
ch = hex(c2)*16 + hex(c3);
if (move)
- mark_to_mark(ci->mark, m);
+ mark_to_mark(mark, m);
mark_free(m);
return CHAR_RET(ch);
}
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&qp_step, "", ci->home, forward, m, NULL, 1);
+ ret = qp_step(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&qp_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return qp_step(ci->home, m, ci->num2 > 0, 0);
}
struct qpcb {
qp_map = key_alloc();
- key_add(qp_map, "doc:step", &qp_step);
key_add(qp_map, "doc:char", &qp_char);
- key_add(qp_map, "doc:step-bytes", &qp_step);
key_add(qp_map, "doc:byte", &qp_char);
key_add(qp_map, "doc:content", &qp_content);
static struct map *utf8_map safe;
DEF_LOOKUP_CMD(utf8_handle, utf8_map);
-DEF_CMD(utf8_step)
+static int utf8_step(struct pane *home safe, struct mark *mark safe,
+ int num, int num2)
{
- int dir = ci->num ? 1 : -1;
- int move = ci->num2;
- struct pane *p = ci->home->parent;
+ int dir = num ? 1 : -1;
+ int move = num2;
+ struct pane *p = home->parent;
wint_t ch;
- struct mark *m = ci->mark;
+ struct mark *m = mark;
char buf[10];
const char *b;
int i;
wint_t ret;
- if (!m)
- return Enoarg;
-
if (move)
ch = doc_move(p, m, dir);
else
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&utf8_step, "", ci->home, forward, m, NULL, 1);
+ ret = utf8_step(ci->home, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num && (ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&utf8_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return utf8_step(ci->home, m, ci->num2 > 0, 0);
}
struct utf8cb {
utf8_map = key_alloc();
- key_add(utf8_map, "doc:step", &utf8_step);
key_add(utf8_map, "doc:char", &utf8_char);
key_add(utf8_map, "doc:content", &utf8_content);
return edlib.Einval
ret = edlib.Einval
while steps and ret != edlib.WEOF and (not end or mark == end):
- ret = self.handle_doc_step(key, focus, mark, forward, 1)
+ ret = self.handle_doc_step(key, mark, forward, 1)
steps -= forward * 2 - 1
if end:
return 1 + (num - steps if forward else steps - num)
if num and (num2 < 0) == (num > 0):
return ret
# want the next character
- return self.handle_doc_step(key, focus, mark, 1 if num2 > 0 else 0, 0)
+ return self.handle_doc_step(key, mark, 1 if num2 > 0 else 0, 0)
- def handle_doc_step(self, key, focus, mark, num, num2, **a):
- "handle:doc:step"
+ def handle_doc_step(self, key, mark, num, num2):
# if in a marker, only allow a space and newline to be seen
if not mark:
return edlib.Enoarg
return ' '
else:
# backward
- return self.parent.call("doc:char", focus, mark,
+ return self.parent.call("doc:char", mark,
-1 if num2 else 0, 0 if num2 else -1)
else:
# at end of marker
if num > 0:
- return self.parent.call("doc:char", focus, mark,
+ return self.parent.call("doc:char", mark,
1 if num2 else 0, 0 if num2 else 1)
else:
- return self.parent.call("doc:char", focus, mark,
+ return self.parent.call("doc:char", mark,
-1 if num2 else 0, 0 if num2 else -1)
if not m or not m['compose-type']:
# not in a marker
if num > 0:
- return self.parent.call("doc:char", focus, mark,
+ return self.parent.call("doc:char", mark,
1 if num2 else 0, 0 if num2 else 1)
else:
- return self.parent.call("doc:char", focus, mark,
+ return self.parent.call("doc:char", mark,
-1 if num2 else 0, 0 if num2 else -1)
# should be just before newline
# want the next character
return self.handle_step(key, mark, 1 if num2 > 0 else 0, 0)
- def handle_step(self, key, mark, num, num2, **a):
- "handle:doc:step"
+ def handle_step(self, key, mark, num, num2):
forward = num
move = num2
ret = edlib.WEOF
# want the next character
return self.handle_step(key, mark, 1 if num2 > 0 else 0, 0)
- def handle_step(self, key, mark, num, num2, **a):
- "handle:doc:step"
+ def handle_step(self, key, mark, num, num2):
forward = num
move = num2
return self.step(mark, forward, move)
# want the next character
return self.handle_step(key, focus, mark, 1 if num2 > 0 else 0, 0)
- def handle_step(self, key, focus, mark, num, num2, **a):
- "handle:doc:step"
+ def handle_step(self, key, focus, mark, num, num2):
forward = num
move = num2
if self.whole_thread:
mark_step(m, 1);
}
-DEF_CMD(format_step)
+static int format_step(struct pane *home safe, struct pane *focus safe,
+ struct mark *mark safe,
+ int num, int num2)
{
- struct rf_data *rd = ci->home->data;
+ struct rf_data *rd = home->data;
struct rf_field *rf;
- struct mark *m = ci->mark;
- int forward = ci->num;
- int move = ci->num2;
+ struct mark *m = mark;
+ int forward = num;
+ int move = num2;
int f, o;
int margin;
int fsize;
char *val = NULL;
int index;
- if (!m)
- return Enoarg;
-
- set_format(ci->focus, rd);
+ set_format(focus, rd);
if (!forward) {
- index = normalize(ci->home, m, -1);
+ index = normalize(home, m, -1);
if (index < 0) {
- if (doc_prior(ci->home->parent, m) == WEOF)
+ if (doc_prior(home->parent, m) == WEOF)
return CHAR_RET(WEOF);
if (move)
- prev_line(ci->home, m);
+ prev_line(home, m);
return CHAR_RET('\n');
}
} else {
if (m->ref.p == NULL)
return CHAR_RET(WEOF);
- index = normalize(ci->home, m, 0);
+ index = normalize(home, m, 0);
if (index < 0)
/* Should be impossible */
return CHAR_RET(WEOF);
if (f >= rd->nfields) {
if (move)
- next_line(ci->home, m);
+ next_line(home, m);
return CHAR_RET('\n');
}
rf = &rd->fields[f];
- fsize = field_size(ci->home, m, f, &val);
+ fsize = field_size(home, m, f, &val);
if (val)
len = strlen(val);
if (move && forward) {
mark_step(m, forward);
- index = normalize(ci->home, m, 1);
+ index = normalize(home, m, 1);
if (index < 0) {
- next_line(ci->home, m);
+ next_line(home, m);
return CHAR_RET('\n');
}
m->ref.i = index;
/* Can never cross 'end' */
return Einval;
while (steps && ret != CHAR_RET(WEOF) && (!end || mark_same(m, end))) {
- ret = comm_call(&format_step, "", ci->home, forward, m, NULL, 1);
+ ret = format_step(ci->home, ci->focus, m, forward, 1);
steps -= forward*2 - 1;
}
if (end)
if (ci->num &&(ci->num2 < 0) == forward)
return ret;
/* Want the 'next' char */
- return comm_call(&format_step, "", ci->home, ci->num2 > 0, m, NULL, 0);
+ return format_step(ci->home, ci->focus, m, ci->num2 > 0, 0);
}
DEF_CMD(format_attr)
rf2_map = key_alloc();
- key_add(rf2_map, "doc:step", &format_step);
key_add(rf2_map, "doc:char", &format_char);
key_add(rf2_map, "doc:get-attr", &format_attr);
key_add(rf2_map, "map-attr", &format_map);
return 1;
}
-DEF_CMD(hex_step)
-{
- struct he_data *he = ci->home->data;
-
- if (he->bytes)
- return home_call(ci->home->parent, "doc:step-bytes", ci->focus,
- ci->num, ci->mark, ci->str,
- ci->num2, ci->mark2, ci->str2);
- else
- return home_call(ci->home->parent, "doc:char", ci->focus,
- ci->num2 ? (ci->num ? 1 : -1) : 0,
- ci->mark, ci->str,
- ci->num2 ? 0 : (ci->num ? 1 : -1),
- ci->mark2, ci->str2);
-}
-
DEF_CMD(hex_char)
{
struct he_data *he = ci->home->data;
he_map = key_alloc();
key_add(he_map, "doc:EOL", &render_hex_eol);
- key_add(he_map, "doc:step", &hex_step);
key_add(he_map, "doc:char", &hex_char);
key_add(he_map, "doc:render-line-prev", &render_line_prev);