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
*****************************************************************************/
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);
{ ModCtrl, 'd', execute },
{ ModCtrl, 'o', open_file },
//{ ModCtrl, 'p', find_ctag },
- //{ ModCtrl, 'g', goto_ctag },
+ { ModCtrl, 'g', goto_ctag },
};
/* External Commands
#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 };
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) {