Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added paste primary (Shift+Ins default) and clipboard (Ctrl+v default) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0955f641b880483636bcffdfdda4a311 |
User & Date: | jmcclure 2020-03-25 23:27:16 |
Context
2020-03-25
| ||
23:42 | Added some emacs-style keys check-in: 7348de7b2c user: jmcclure tags: trunk | |
23:27 | Added paste primary (Shift+Ins default) and clipboard (Ctrl+v default) check-in: 0955f641b8 user: jmcclure tags: trunk | |
23:26 | Added dependency comments to scripts check-in: 105c7b9165 user: jmcclure tags: trunk | |
Changes
Changes to interrobang.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* Copyright 2020 Jesse McClure <code@jessemcclure.org> * See LICENSE for details */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <ctype.h> #include <sys/types.h> #include <sys/wait.h> #include <X11/Xlib.h> #include <X11/keysym.h> #include <X11/Xft/Xft.h> #define MAX 1024 #define ENV_CHAR "iBangChar" #define ENV_BANG "iBangBang" #define ENV_ARGS "iBangArgs" | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* Copyright 2020 Jesse McClure <code@jessemcclure.org> * See LICENSE for details */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <ctype.h> #include <sys/types.h> #include <sys/wait.h> #include <X11/Xlib.h> #include <X11/keysym.h> #include <X11/Xatom.h> #include <X11/Xft/Xft.h> #define MAX 1024 #define ENV_CHAR "iBangChar" #define ENV_BANG "iBangBang" #define ENV_ARGS "iBangArgs" |
︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 | static int scr, fh, h, pos = 0, running = 1; static Window root, win; static GC gc; static XftFont *xfont; static XftDraw *xdraw; static XftColor xcol; static char line[MAX]; /* INITIALIZATION FUNCTIONS: IN ORDER OF CALL */ static int dirsInit(int argc, const char *argv[]) { const char *var; if ((var=getenv("XDG_DATA_HOME"))) { | > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | static int scr, fh, h, pos = 0, running = 1; static Window root, win; static GC gc; static XftFont *xfont; static XftDraw *xdraw; static XftColor xcol; static char line[MAX]; static Atom XA_CLIPBOARD; /* INITIALIZATION FUNCTIONS: IN ORDER OF CALL */ static int dirsInit(int argc, const char *argv[]) { const char *var; if ((var=getenv("XDG_DATA_HOME"))) { |
︙ | ︙ | |||
84 85 86 87 88 89 90 91 92 93 94 95 96 97 | static int xlibInit(int argc, const char *argv[]) { int i; dpy = XOpenDisplay(0x0); scr = DefaultScreen(dpy); root = RootWindow(dpy, scr); w = (w ? w : DisplayWidth(dpy,scr) - bpx * 2); for (i = 0; i < 1000; i++) { if (XGrabKeyboard(dpy,root,True,GrabModeAsync,GrabModeAsync, CurrentTime) == GrabSuccess) break; usleep(1000); } if (i == 1000) { fprintf(stderr, "Unable to grab keyboard\n"); | > | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | static int xlibInit(int argc, const char *argv[]) { int i; dpy = XOpenDisplay(0x0); scr = DefaultScreen(dpy); root = RootWindow(dpy, scr); w = (w ? w : DisplayWidth(dpy,scr) - bpx * 2); XA_CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); for (i = 0; i < 1000; i++) { if (XGrabKeyboard(dpy,root,True,GrabModeAsync,GrabModeAsync, CurrentTime) == GrabSuccess) break; usleep(1000); } if (i == 1000) { fprintf(stderr, "Unable to grab keyboard\n"); |
︙ | ︙ | |||
198 199 200 201 202 203 204 | while (!XNextEvent(dpy, &ev) && running) { if (XFilterEvent(&ev,win) || ev.type != KeyPress) continue; key = NoSymbol; XLookupString(&ev.xkey, txt, sizeof txt, &key, NULL); len = strlen(txt); if (!keymapCheck(ev.xkey.state, key) && !iscntrl(*txt)) | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | while (!XNextEvent(dpy, &ev) && running) { if (XFilterEvent(&ev,win) || ev.type != KeyPress) continue; key = NoSymbol; XLookupString(&ev.xkey, txt, sizeof txt, &key, NULL); len = strlen(txt); if (!keymapCheck(ev.xkey.state, key) && !iscntrl(*txt)) insertText(txt, len); redraw(); } return 0; } static int cleanup() { XftFontClose(dpy, xfont); |
︙ | ︙ | |||
312 313 314 315 316 317 318 | void move(const Arg *arg) { pos += arg->i; if (pos < 0) pos = 0; else if (pos > strlen(line)) pos = strlen(line); } void paste(const Arg *arg) { | > > > > | > > > > > > > > > > > > | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | void move(const Arg *arg) { pos += arg->i; if (pos < 0) pos = 0; else if (pos > strlen(line)) pos = strlen(line); } void paste(const Arg *arg) { XEvent e; int fmt, res; unsigned long len, rem; unsigned char *s = NULL, *p; Atom xa, type; xa = arg->i ? XA_CLIPBOARD : XA_PRIMARY; Window sel = XGetSelectionOwner(dpy, xa); if (!sel) return; XConvertSelection(dpy, xa, XA_STRING, None, sel, CurrentTime); XFlush(dpy); XMaskEvent(dpy, SelectionNotify, &e); XGetWindowProperty(dpy, sel, XA_STRING, 0, 256, False, AnyPropertyType, &type, &fmt, &len, &rem, &s); if (s) { if ( (p=strchr(s,'\n')) ) *p = '\0'; insertText(s, strlen(s)); XFree(s); } } void quit(const Arg *arg) { running = 0; } void run(const Arg *arg) { complete_run_helper(arg, getenv(ENV_RUN), 1); } |