From b8ce7d3b161bc8012fe35f0544faa526bbb837c2 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 2 Dec 2016 21:07:48 -0500 Subject: [PATCH] goto ctag now selects based on context of nothing is selected --- TODO.md | 3 +-- inc/edit.h | 1 + libedit/view.c | 9 +++++++++ xedit.c | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 396c7fc..000eb3f 100644 --- a/TODO.md +++ b/TODO.md @@ -2,6 +2,7 @@ * disable autoindent when pasting text * update getstr to select context when selection is null +* center find results and jumped to line on screen * Use select to check for error strings in exec.c * Should not be able to undo initial tag line text insertion * Disallow scrolling past end of buffer @@ -16,8 +17,6 @@ # Internals and Miscellaneous * Calculate line numbers and keep up to date while editing -* Implement ctags lookup and regeneration -* Implement cscope lookup and regeneration # Auxillary Programs diff --git a/inc/edit.h b/inc/edit.h index aef9150..0ffca4f 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -156,6 +156,7 @@ void view_redo(View* view); void view_putstr(View* view, char* str); void view_append(View* view, char* str); char* view_getstr(View* view, Sel* sel); +char* view_getctx(View* view); void view_scroll(View* view, int move); void view_scrollpage(View* view, int move); void view_setln(View* view, size_t line); diff --git a/libedit/view.c b/libedit/view.c index 90d5f5a..814de2b 100644 --- a/libedit/view.c +++ b/libedit/view.c @@ -156,6 +156,7 @@ void view_init(View* view, char* file) { if (file) { view->selection.end = buf_load(&(view->buffer), file); view->selection.beg = view->selection.end; + view->sync_needed = true; } } @@ -494,6 +495,14 @@ char* view_getstr(View* view, Sel* range) { return str; } +char* view_getctx(View* view) { + if (0 == num_selected(view->selection)) { + selcontext(view, &(view->selection)); + view->selection.end++; + } + return view_getstr(view, NULL); +} + void view_scroll(View* view, int move) { int dir = (move < 0 ? -1 : 1); move *= dir; diff --git a/xedit.c b/xedit.c index 2184152..048051e 100644 --- a/xedit.c +++ b/xedit.c @@ -514,7 +514,7 @@ static void open_file(void) { } static void goto_ctag(void) { - char* str = view_getstr(currview(), NULL); + char* str = view_getctx(currview()); if (str) { PickTagCmd[2] = str; char* pick = cmdread(PickTagCmd, NULL); -- 2.52.0