From: NeilBrown Date: Thu, 26 Nov 2015 03:58:06 +0000 (+1100) Subject: Move final doc default actions from 'view' to 'doc'. X-Git-Tag: lca2016~201 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=da9c9ff274fb711b233e90fe6cd26cdf42a257ca;p=edlib.git Move final doc default actions from 'view' to 'doc'. Signed-off-by: NeilBrown --- diff --git a/core-doc.c b/core-doc.c index 2aa318ed..84084d8d 100644 --- a/core-doc.c +++ b/core-doc.c @@ -273,6 +273,57 @@ DEF_CMD(doc_file) return 1; } +DEF_CMD(doc_line) +{ + struct doc *d = ci->home->data; + wint_t ch = 1; + int rpt = RPT_NUM(ci); + + while (rpt > 0 && ch != WEOF) { + while ((ch = mark_next(d, ci->mark)) != WEOF && + ch != '\n') + ; + rpt -= 1; + } + while (rpt < 0 && ch != WEOF) { + while ((ch = mark_prev(d, ci->mark)) != WEOF && + ch != '\n') + ; + rpt += 1; + } + return 1; +} + +DEF_CMD(doc_page) +{ + struct doc *d = ci->home->data; + wint_t ch = 1; + int rpt = RPT_NUM(ci); + + rpt *= ci->home->h-2; + while (rpt > 0 && ch != WEOF) { + while ((ch = mark_next(d, ci->mark)) != WEOF && + ch != '\n') + ; + rpt -= 1; + } + while (rpt < 0 && ch != WEOF) { + while ((ch = mark_prev(d, ci->mark)) != WEOF && + ch != '\n') + ; + rpt += 1; + } + return 1; +} + +DEF_CMD(doc_do_replace) +{ + bool first_change = (ci->extra == 0); + + doc_replace(ci->home, ci->mark, ci->str, &first_change); + return 1; +} + static struct map *doc_default_cmd; static void init_doc_defaults(void) @@ -284,6 +335,9 @@ static void init_doc_defaults(void) key_add(doc_default_cmd, "Move-WORD", &doc_WORD); key_add(doc_default_cmd, "Move-EOL", &doc_eol); key_add(doc_default_cmd, "Move-File", &doc_file); + key_add(doc_default_cmd, "Move-Line", &doc_line); + key_add(doc_default_cmd, "Move-View-Large", &doc_page); + key_add(doc_default_cmd, "Replace", &doc_do_replace); } DEF_CMD(doc_handle) diff --git a/lib-view.c b/lib-view.c index a5c5418a..b0974705 100644 --- a/lib-view.c +++ b/lib-view.c @@ -246,57 +246,6 @@ DEF_CMD(view_attach) return ci->focus != NULL; } -DEF_CMD(view_line) -{ - struct point *pt = *ci->pointp; - wint_t ch = 1; - int rpt = RPT_NUM(ci); - - while (rpt > 0 && ch != WEOF) { - while ((ch = mark_next(pt->doc, ci->mark)) != WEOF && - ch != '\n') - ; - rpt -= 1; - } - while (rpt < 0 && ch != WEOF) { - while ((ch = mark_prev(pt->doc, ci->mark)) != WEOF && - ch != '\n') - ; - rpt += 1; - } - return 1; -} - -DEF_CMD(view_page) -{ - struct point *pt = *ci->pointp; - wint_t ch = 1; - int rpt = RPT_NUM(ci); - - rpt *= ci->home->h-2; - while (rpt > 0 && ch != WEOF) { - while ((ch = mark_next(pt->doc, ci->mark)) != WEOF && - ch != '\n') - ; - rpt -= 1; - } - while (rpt < 0 && ch != WEOF) { - while ((ch = mark_prev(pt->doc, ci->mark)) != WEOF && - ch != '\n') - ; - rpt += 1; - } - return 1; -} - -DEF_CMD(view_replace) -{ - bool first_change = (ci->extra == 0); - - doc_replace(ci->focus, ci->mark, ci->str, &first_change); - return 1; -} - DEF_CMD(view_click) { struct pane *p = ci->home; @@ -336,11 +285,6 @@ void edlib_init(struct editor *ed) { view_map = key_alloc(); - key_add(view_map, "Move-Line", &view_line); - key_add(view_map, "Move-View-Large", &view_page); - - key_add(view_map, "Replace", &view_replace); - key_add(view_map, "Click-1", &view_click); key_add(view_map, "Press-1", &view_click);