static void sigchld(int);
static void run(void);
-static inline int parse_int(char *);
static void csidump(void);
static void csihandle(void);
static void csiparse(void);
void
bmotion(XEvent *e) {
- int oldey, oldex;
+ int oldey, oldex, oldsby, oldsey;
if(IS_SET(MODE_MOUSE)) {
mousereport(e);
oldey = sel.ey;
oldex = sel.ex;
+ oldsby = sel.b.y;
+ oldsey = sel.e.y;
getbuttoninfo(e);
if(oldey != sel.ey || oldex != sel.ex) {
- tsetdirt(sel.b.y, sel.e.y);
+ tsetdirt(MIN(sel.b.y, oldsby), MAX(sel.e.y, oldsey));
}
}
memset(&csiescseq, 0, sizeof(csiescseq));
}
-inline int
-parse_int(char *s) {
- int x = 0;
- char c;
- while(isdigit(c = *s)) {
- if((INT_MAX - c + '0') / 10 >= x) {
- x = x * 10 + c - '0';
- } else
- return -1;
- s++;
- }
- if(*s != '\0')
- return -1;
- return x;
-}
-
void
strhandle(void) {
char *p = NULL;
- int i, j;
- int narg;
+ int i, j, narg;
+ XTextProperty prop;
- /*
- * TODO: make this being useful in case of color palette change.
- */
strparse();
narg = strescseq.narg;
switch(strescseq.type) {
case ']': /* OSC -- Operating System Command */
- switch(i = parse_int(strescseq.args[0])) {
+ switch(i = atoi(strescseq.args[0])) {
case 0:
case 1:
case 2:
- /*
- * TODO: Handle special chars in string, like umlauts.
- */
- if(narg > 1)
- XStoreName(xw.dpy, xw.win, strescseq.args[2]);
+ if(narg > 1) {
+ p += 2;
+ Xutf8TextListToTextProperty(xw.dpy, &p, 1,
+ XUTF8StringStyle, &prop);
+ XSetWMName(xw.dpy, xw.win, &prop);
+ }
break;
case 4: /* color set */
if(narg < 3)
p = strescseq.args[2];
/* fall through */
case 104: /* color reset, here p = NULL */
- j = (narg > 1) ? parse_int(strescseq.args[1]) : -1;
- if (!xsetcolorname(j, p))
+ j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
+ if (!xsetcolorname(j, p)) {
fprintf(stderr, "erresc: invalid color %s\n", p);
- else {
+ } else {
redraw(0); /* TODO if defaultbg color is changed, borders are dirty */
}
break;
}
break;
case 'k': /* old title set compatibility */
- XStoreName(xw.dpy, xw.win, strescseq.buf);
+ p += 1;
+ Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
+ &prop);
+ XSetWMName(xw.dpy, xw.win, &prop);
break;
case 'P': /* DSC -- Device Control String */
case '_': /* APC -- Application Program Command */