void (*set_focus)(bool focus);
void (*mouse_drag)(int state, int x, int y);
void (*mouse_btn)(int state, bool pressed, int x, int y);
+ void (*cmd_received)(char* cmd);
} XConfig;
typedef void* XFont;
static void onmousebtn(int btn, bool pressed, int x, int y);
static void onwheelup(WinRegion id, bool pressed, size_t row, size_t col);
static void onwheeldn(WinRegion id, bool pressed, size_t row, size_t col);
+static void oncommand(char* cmd);
static bool update_focus(void);
static void draw_line_num(bool current, size_t x, size_t y, size_t gcols, size_t num);
static void draw_glyphs(size_t x, size_t y, UGlyph* glyphs, size_t rlen, size_t ncols);
.set_focus = onfocus,
.mouse_drag = onmousedrag,
.mouse_btn = onmousebtn,
+ .cmd_received = oncommand
};
static WinRegion Focused = EDIT;
static Region Regions[NREGIONS] = {0};
view_scroll(win_view(id), +(config_get_int(ScrollLines)));
}
+static void oncommand(char* cmd) {
+ size_t line = strtoul(cmd, NULL, 0);
+ if (line) {
+ View* view = win_view(EDIT);
+ win_setregion(EDIT);
+ view_setln(view, line);
+ view_eol(view, false);
+ view_selctx(view);
+ }
+}
+
static bool update_focus(void) {
static int prev_x = 0, prev_y = 0;
int ptr_x, ptr_y;
| ButtonMotionMask
| KeyPressMask
| FocusChangeMask
+ | PropertyChangeMask
);
/* set input methods */
/* Tide Server Communication and Property Handling
*****************************************************************************/
static void propnotify(XEvent* evnt) {
+ XPropertyEvent* ev = (XPropertyEvent*)evnt;
+ if (ev->atom == XInternAtom(X.display, "TIDE_COMM", False))
+ Config->cmd_received(x11_prop_get("TIDE_COMM"));
}
void x11_prop_set(char* name, char* val) {
print "grep -Hn", matchstr, $2, "| cut -d: -f1,2"
}
' "$TAGFILE" | /bin/sh | pick)
- [ "" != "$file" ] && tide "$file"
+ [ "" != "$file" ] && tctl "$file"
}
export PICKTITLE="Pick CTag ($PWD)"
long mask = SubstructureRedirectMask | SubstructureNotifyMask;
XSendEvent(X.display, X.root, False, mask, &ev);
XMapRaised(X.display, w);
+ if (addr && *addr)
+ prop_set(w, "TIDE_COMM", XA_STRING, 8, addr, strlen(addr));
XFlush(X.display);
}
if (!rpath) rpath = path;
*abspath = rpath, *addr = faddr;
}
-
{ ISSET, "EDITOR", NULL },
{ MATCHES, "data", "^([^:]+):([0-9]+)" },
{ ISFILE, "$1", NULL },
- { LAUNCH, "$EDITOR $0", NULL },
+ { LAUNCH, "tctl $0", NULL },
{ COMPLETE, NULL, NULL }
},
(Rule[]){ // If it's an existing text file, open it with editor