static void xresize(int, int);
static void expose(XEvent *);
static void xresize(int, int);
static void expose(XEvent *);
static void brelease(XEvent *);
static void bpress(XEvent *);
static void bmotion(XEvent *);
static void brelease(XEvent *);
static void bpress(XEvent *);
static void bmotion(XEvent *);
-static void selection_notify(XEvent *);
-static void selection_request(XEvent *);
+static void selnotify(XEvent *);
+static void selrequest(XEvent *);
+
+static void selinit(void);
+static inline int selected(int, int);
+static void selcopy(void);
+static void selpaste(void);
static int stou(char *, long *);
static int utos(long *, char *);
static int stou(char *, long *);
static int utos(long *, char *);
[MotionNotify] = bmotion,
[ButtonPress] = bpress,
[ButtonRelease] = brelease,
[MotionNotify] = bmotion,
[ButtonPress] = bpress,
[ButtonRelease] = brelease,
- [SelectionNotify] = selection_notify,
- [SelectionRequest] = selection_request,
+ [SelectionNotify] = selnotify,
+ [SelectionRequest] = selrequest,
-/*
- * use this if your buffer is less than UTF_SIZ, it returns 1 if you can decode UTF-8
- * otherwise return 0
- */
-static int
-canstou(char *s, int b)
-{
- unsigned char c;
+/* use this if your buffer is less than UTF_SIZ, it returns 1 if you can decode
+ UTF-8 otherwise return 0 */
+static int canstou(char *s, int b) {
+ unsigned char c = *s;
- return NULL;
- sz = (term.col+1) * (sel.e.y-sel.b.y+1) * UTF_SIZ;
- ptr = str = malloc(sz);
- for(y = 0; y < term.row; y++) {
- for(x = 0; x < term.col; x++)
- if(term.line[y][x].state & GLYPH_SET && (ls = selected(x, y))) {
- sl = slen(term.line[y][x].c);
- memcpy(ptr, term.line[y][x].c, sl);
- ptr += sl;
- }
- if(ls)
- *ptr = '\n', ptr++;
+ str = NULL;
+ else {
+ sz = (term.col+1) * (sel.e.y-sel.b.y+1) * UTF_SIZ;
+ ptr = str = malloc(sz);
+ for(y = 0; y < term.row; y++) {
+ for(x = 0; x < term.col; x++)
+ if(term.line[y][x].state & GLYPH_SET && (ls = selected(x, y))) {
+ sl = slen(term.line[y][x].c);
+ memcpy(ptr, term.line[y][x].c, sl);
+ ptr += sl;
+ }
+ if(ls)
+ *ptr = '\n', ptr++;
+ }
+ *ptr = 0;
XConvertSelection(xw.dis, XA_PRIMARY, XA_STRING, XA_PRIMARY, xw.win, CurrentTime);
}
XConvertSelection(xw.dis, XA_PRIMARY, XA_STRING, XA_PRIMARY, xw.win, CurrentTime);
}
static void bmotion(XEvent *e) {
if (sel.mode) {
getbuttoninfo(e, NULL, &sel.ex, &sel.ey);
static void bmotion(XEvent *e) {
if (sel.mode) {
getbuttoninfo(e, NULL, &sel.ex, &sel.ey);
XWMHints wm = {.flags = InputHint, .input = 1};
XSizeHints size = {
.flags = PSize | PResizeInc | PBaseSize,
XWMHints wm = {.flags = InputHint, .input = 1};
XSizeHints size = {
.flags = PSize | PResizeInc | PBaseSize,