From: Michael D. Lowis Date: Wed, 4 Apr 2018 17:17:10 +0000 (-0400) Subject: removed selection arg from view api X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=5b62a3b844ba4566691badc3d5884fdd22f64c96;p=projs%2Ftide.git removed selection arg from view api --- diff --git a/inc/edit.h b/inc/edit.h index ea0a088..f24bbc9 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -132,7 +132,7 @@ void view_eof(View* view, bool extsel); void view_undo(View* view); void view_redo(View* view); void view_putstr(View* view, char* str); -char* view_getstr(View* view, Sel* sel); +char* view_getstr(View* view); char* view_getcmd(View* view); char* view_getword(View* view); char* view_getctx(View* view); diff --git a/lib/view.c b/lib/view.c index 31f36bf..12bfef3 100644 --- a/lib/view.c +++ b/lib/view.c @@ -139,12 +139,13 @@ char* view_fetch(View* view, size_t row, size_t col, bool (*isword)(Rune)) { char* str = NULL; size_t off = getoffset(view, row, col); if (off != SIZE_MAX) { - Sel sel = { .beg = off, .end = off }; - if (buf_insel(&(view->buffer), NULL, off)) - sel = *(getsel(view)); - else - buf_selword(&(view->buffer), isword, &sel); - str = view_getstr(view, &sel); + /* str = buf_fetchat(buf, isword, off) */ +// Sel sel = { .beg = off, .end = off }; +// if (buf_insel(&(view->buffer), NULL, off)) +// sel = *(getsel(view)); +// else +// buf_selword(&(view->buffer), isword, &sel); +// str = view_getstr(view, &sel); } return str; } @@ -220,14 +221,14 @@ void view_putstr(View* view, char* str) { buf_puts(&(view->buffer), str, NULL); } -char* view_getstr(View* view, Sel* range) { - return buf_gets(&(view->buffer), (range ? range : getsel(view))); +char* view_getstr(View* view) { + return buf_gets(&(view->buffer), NULL); } char* view_getcmd(View* view) { if (!view_selsize(view)) buf_selctx(&(view->buffer), riscmd, NULL); - return view_getstr(view, NULL); + return view_getstr(view); } void view_selctx(View* view) { @@ -237,7 +238,7 @@ void view_selctx(View* view) { char* view_getctx(View* view) { view_selctx(view); - return view_getstr(view, NULL); + return view_getstr(view); } void view_scroll(View* view, int move) { diff --git a/tide.c b/tide.c index 4ef2433..539ad07 100644 --- a/tide.c +++ b/tide.c @@ -69,7 +69,7 @@ void cut(char* arg) { if (!view_selsize(view)) select_line(arg); /* now perform the cut */ - char* str = view_getstr(view, NULL); + char* str = view_getstr(view); x11_sel_set(CLIPBOARD, str); if (str && *str) delete(arg); } @@ -82,7 +82,7 @@ static void copy(char* arg) { /* select the current line if no selection */ if (!view_selsize(win_view(FOCUSED))) select_line(arg); - char* str = view_getstr(win_view(FOCUSED), NULL); + char* str = view_getstr(win_view(FOCUSED)); x11_sel_set(CLIPBOARD, str); } @@ -218,8 +218,8 @@ static Tag* tag_lookup(char* cmd) { static void tag_exec(Tag* tag, char* arg) { /* if we didnt get an arg, find one in the selection */ - if (!arg) arg = view_getstr(win_view(TAGS), NULL); - if (!arg) arg = view_getstr(win_view(EDIT), NULL); + if (!arg) arg = view_getstr(win_view(TAGS)); + if (!arg) arg = view_getstr(win_view(EDIT)); /* execute the tag handler */ tag->action(arg); free(arg); @@ -236,7 +236,7 @@ static void cmd_exec(char* cmd) { /* get the selection that the command will operate on */ if (op && op != '<' && op != '!' && 0 == view_selsize(win_view(EDIT))) view_selectall(win_view(EDIT)); - char* input = view_getstr(win_view(EDIT), NULL); + char* input = view_getstr(win_view(EDIT)); size_t len = (input ? strlen(input) : 0); View *tags = win_view(TAGS), *edit = win_view(EDIT), *curr = win_view(FOCUSED); @@ -340,7 +340,7 @@ static void pick_ctag(char* arg) { static void complete(char* arg) { View* view = win_view(FOCUSED); view_selectobj(view, risword); - cmd_execwitharg(CMD_COMPLETE, view_getstr(view, NULL)); + cmd_execwitharg(CMD_COMPLETE, view_getstr(view)); } static void jump_to(char* arg) {