* registrar: group by hostname or group env var in registrar
* registrar: should remove invalid windows from registry when detected
* tide: gap buffer does not handle UTF-8 currently
-* pick can return null if mouse clicked on empty row
## BACKLOG
#include <X11/Xft/Xft.h>
typedef struct XConf {
- Bool running;
+ Bool running, error;
int fd, screen, width, height;
Window root;
Display* display;
};
int x11_init(XConf* x);
+void x11_clear_error(void);
+XErrorEvent* x11_error_get(void);
+
void x11_mkwin(XConf* x, int width, int height, int evmask);
void x11_mkdialog(XConf* x, int width, int height, int evmask);
void x11_event_loop(XConf* x, void (*redraw)(XConf* x));
#include <sys/types.h>
#include <sys/wait.h>
+static Bool Has_Error = False;
+static XErrorEvent Error = {0};
+
+static int onerror(Display* disp, XErrorEvent* ev) {
+ (void)disp;
+ Has_Error = True, Error = *ev;
+ return 0;
+}
+
int x11_init(XConf* x) {
signal(SIGPIPE, SIG_IGN); // Ignore the SIGPIPE signal
setlocale(LC_CTYPE, "");
x->screen = DefaultScreen(x->display);
x->depth = DefaultDepth(x->display, x->screen);
x->running = True;
+ XSetErrorHandler(onerror);
return 0;
}
+void x11_clear_error(void) {
+ Has_Error = False;
+ memset(&Error, 0, sizeof(Error));
+}
+
+XErrorEvent* x11_error_get(void) {
+ return (Has_Error ? &Error : NULL);
+}
+
void x11_mkwin(XConf* x, int width, int height, int evmask) {
/* create the main window */
x->width = width, x->height = height;
int starty = x->font->height + 4;
e->xbutton.y = (e->xbutton.y < starty ? starty : e->xbutton.y - starty);
ChoiceIdx = Offset + (e->xbutton.y / x->font->height);
+ if (ChoiceIdx >= vec_size(&Choices))
+ ChoiceIdx = vec_size(&Choices)-1;
} else if (e->xbutton.button == Button4) {
if (Offset > 0) Offset--;
} else if (e->xbutton.button == Button5) {
#include "config.h"
/* predeclare some things */
-void exec(char* cmd, char* arg);
+static void exec(char* cmd, char* arg);
void cut(char* arg);
void paste(char* arg);
job_start(execcmd, input, len, (op != '<' ? curr : edit));
}
-static void cmd_execwitharg(char* cmd, char* arg) {
- cmd = (arg ? strmcat(cmd, " '", arg, "'", 0) : strmcat(cmd));
- cmd_exec(cmd);
- free(cmd);
-}
-
-void exec(char* cmd, char* arg) {
+static void exec(char* cmd, char* arg) {
/* skip leading space */
for (; *cmd && isspace(*cmd); cmd++);
if (!*cmd) return;
}
static void pick_symbol(char* symbol) {
- cmd_execwitharg(CMD_GOTO_TAG, symbol);
+ exec(CMD_GOTO_TAG, symbol);
}
static void pick_ctag(char* arg) {
(void)arg;
View* view = win_view(FOCUSED);
view_selectobj(view, risword);
- cmd_execwitharg(CMD_COMPLETE, view_getstr(view));
+ exec(CMD_COMPLETE, view_getstr(view));
}
static void fcomplete(char* arg) {
(void)arg;
View* view = win_view(FOCUSED);
view_selectobj(view, risfile);
- cmd_execwitharg(CMD_FCOMPLETE, view_getstr(view));
+ exec(CMD_FCOMPLETE, view_getstr(view));
}
static void jump_to(char* arg) {