static void execute(void);
static void find(char* arg);
static void open_file(void);
+static void pick_ctag(void);
static void goto_ctag(void);
// Tag/Cmd Execution
{ ModCtrl, 'f', search },
{ ModCtrl, 'd', execute },
{ ModCtrl, 'o', open_file },
- //{ ModCtrl, 'p', pick_ctag },
+ { ModCtrl, 'p', pick_ctag },
{ ModCtrl, 'g', goto_ctag },
};
free(file);
}
-static void goto_ctag(void) {
- char* str = view_getctx(currview());
- if (str) {
- size_t line = strtoul(str, NULL, 0);
- if (line) {
- view_setln(getview(EDIT), line);
+static void pick_symbol(char* symbol) {
+ PickTagCmd[2] = symbol;
+ char* pick = cmdread(PickTagCmd, NULL);
+ if (pick) {
+ Buf* buf = getbuf(EDIT);
+ if (buf->path && 0 == strncmp(buf->path, pick, strlen(buf->path))) {
+ view_setln(getview(EDIT), strtoul(strrchr(pick, ':')+1, NULL, 0));
Focused = EDIT;
} else {
- 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);
- }
+ if (!buf->path && !buf->modified) {
+ view_init(getview(EDIT), pick);
+ } else {
+ OpenCmd[1] = chomp(pick);
+ cmdrun(OpenCmd, NULL);
}
}
}
+}
+
+static void pick_ctag(void) {
+ pick_symbol(NULL);
+}
+
+static void goto_ctag(void) {
+ char* str = view_getctx(currview());
+ if (str) {
+ pick_symbol(str);
+ }
free(str);
}