From: Michael D. Lowis Date: Sat, 3 Dec 2016 01:42:26 +0000 (-0500) Subject: implemented goto ctag function X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=9b8f41da28326237b4fa7dd26bd8d9179817a752;p=projs%2Ftide.git implemented goto ctag function --- diff --git a/TODO.md b/TODO.md index c15d465..396c7fc 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,7 @@ # Implementation Tweaks and Bug Fixes + +* disable autoindent when pasting text +* update getstr to select context when selection is null * 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 diff --git a/inc/edit.h b/inc/edit.h index d7b6597..aef9150 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -158,6 +158,7 @@ void view_append(View* view, char* str); char* view_getstr(View* view, Sel* sel); void view_scroll(View* view, int move); void view_scrollpage(View* view, int move); +void view_setln(View* view, size_t line); /* Command Executions *****************************************************************************/ diff --git a/libedit/view.c b/libedit/view.c index b3e918d..90d5f5a 100644 --- a/libedit/view.c +++ b/libedit/view.c @@ -509,3 +509,9 @@ void view_scrollpage(View* view, int move) { move = (move < 0 ? -1 : 1) * view->nrows; view_scroll(view, move); } + +void view_setln(View* view, size_t line) { + view->selection.end = buf_setln(&(view->buffer), line); + view->selection.beg = view->selection.end; + view->sync_needed = true; +} diff --git a/xedit.c b/xedit.c index 95d8c6f..2184152 100644 --- a/xedit.c +++ b/xedit.c @@ -49,6 +49,7 @@ static void search(void); static void execute(void); static void find(char* arg); static void open_file(void); +static void goto_ctag(void); // Tag/Cmd Execution static Tag* tag_lookup(char* cmd); @@ -146,7 +147,7 @@ static KeyBinding Bindings[] = { { ModCtrl, 'd', execute }, { ModCtrl, 'o', open_file }, //{ ModCtrl, 'p', find_ctag }, - //{ ModCtrl, 'g', goto_ctag }, + { ModCtrl, 'g', goto_ctag }, }; /* External Commands @@ -160,6 +161,7 @@ static char* PasteCmd[] = { "xsel", "-bo", NULL }; #endif static char* ShellCmd[] = { "/bin/sh", "-c", NULL, NULL }; static char* PickFileCmd[] = { "xfilepick", ".", NULL }; +static char* PickTagCmd[] = { "xtagpick", "tags", NULL, NULL }; static char* OpenCmd[] = { "xedit", NULL, NULL }; static char* SedCmd[] = { "sed", "-e", NULL, NULL }; @@ -511,6 +513,25 @@ static void open_file(void) { free(file); } +static void goto_ctag(void) { + char* str = view_getstr(currview(), NULL); + if (str) { + PickTagCmd[2] = str; + char* pick = cmdread(PickTagCmd, NULL); + if (pick) { + Buf* buf = getbuf(EDIT); + if (0 == strncmp(buf->path, pick, strlen(buf->path))) { + view_setln(getview(EDIT), strtoul(strrchr(pick, ':')+1, NULL, 0)); + Focused = EDIT; + } else { + OpenCmd[1] = pick; + cmdrun(OpenCmd, NULL); + } + } + } + free(str); +} + /* Tag/Cmd Execution *****************************************************************************/ static Tag* tag_lookup(char* cmd) { diff --git a/xtagpick b/xtagpick index 6fb656a..15c4d06 100755 --- a/xtagpick +++ b/xtagpick @@ -7,7 +7,7 @@ if [ "" == "$TAG" ] || [ "" == "$TAGFILE" ]; then exit 1 fi -awk -vTAG="$TAG" ' +awk -v TAG="$TAG" ' BEGIN { FS = "[\t]+" } ($1 == TAG) { matchstr = $3