whitespace.
This commit is contained in:
parent
babf4db52b
commit
8eaed2cdda
66
st.c
66
st.c
|
@ -398,7 +398,7 @@ selected(int x, int y) {
|
||||||
|
|
||||||
void
|
void
|
||||||
getbuttoninfo(XEvent *e, int *b, int *x, int *y) {
|
getbuttoninfo(XEvent *e, int *b, int *x, int *y) {
|
||||||
if(b)
|
if(b)
|
||||||
*b = e->xbutton.button;
|
*b = e->xbutton.button;
|
||||||
|
|
||||||
*x = (e->xbutton.x - BORDER)/xw.cw;
|
*x = (e->xbutton.x - BORDER)/xw.cw;
|
||||||
|
@ -543,17 +543,17 @@ brelease(XEvent *e) {
|
||||||
} else if(TIMEDIFFERENCE(now, sel.tclick1) <= DOUBLECLICK_TIMEOUT) {
|
} else if(TIMEDIFFERENCE(now, sel.tclick1) <= DOUBLECLICK_TIMEOUT) {
|
||||||
/* double click to select word */
|
/* double click to select word */
|
||||||
sel.bx = sel.ex;
|
sel.bx = sel.ex;
|
||||||
while(term.line[sel.ey][sel.bx-1].state & GLYPH_SET &&
|
while(term.line[sel.ey][sel.bx-1].state & GLYPH_SET &&
|
||||||
term.line[sel.ey][sel.bx-1].c[0] != ' ') sel.bx--;
|
term.line[sel.ey][sel.bx-1].c[0] != ' ') sel.bx--;
|
||||||
sel.b.x = sel.bx;
|
sel.b.x = sel.bx;
|
||||||
while(term.line[sel.ey][sel.ex+1].state & GLYPH_SET &&
|
while(term.line[sel.ey][sel.ex+1].state & GLYPH_SET &&
|
||||||
term.line[sel.ey][sel.ex+1].c[0] != ' ') sel.ex++;
|
term.line[sel.ey][sel.ex+1].c[0] != ' ') sel.ex++;
|
||||||
sel.e.x = sel.ex;
|
sel.e.x = sel.ex;
|
||||||
sel.b.y = sel.e.y = sel.ey;
|
sel.b.y = sel.e.y = sel.ey;
|
||||||
selcopy();
|
selcopy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(b == 1)
|
} else if(b == 1)
|
||||||
selcopy();
|
selcopy();
|
||||||
memcpy(&sel.tclick2, &sel.tclick1, sizeof(struct timeval));
|
memcpy(&sel.tclick2, &sel.tclick1, sizeof(struct timeval));
|
||||||
gettimeofday(&sel.tclick1, NULL);
|
gettimeofday(&sel.tclick1, NULL);
|
||||||
|
@ -563,7 +563,7 @@ brelease(XEvent *e) {
|
||||||
void
|
void
|
||||||
bmotion(XEvent *e) {
|
bmotion(XEvent *e) {
|
||||||
if(sel.mode) {
|
if(sel.mode) {
|
||||||
int oldey = sel.ey,
|
int oldey = sel.ey,
|
||||||
oldex = sel.ex;
|
oldex = sel.ex;
|
||||||
getbuttoninfo(e, NULL, &sel.ex, &sel.ey);
|
getbuttoninfo(e, NULL, &sel.ex, &sel.ey);
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ execsh(void) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sigchld(int a) {
|
sigchld(int a) {
|
||||||
int stat = 0;
|
int stat = 0;
|
||||||
if(waitpid(pid, &stat, 0) < 0)
|
if(waitpid(pid, &stat, 0) < 0)
|
||||||
|
@ -650,7 +650,7 @@ dump(char c) {
|
||||||
void
|
void
|
||||||
ttyread(void) {
|
ttyread(void) {
|
||||||
static char buf[BUFSIZ];
|
static char buf[BUFSIZ];
|
||||||
static int buflen = 0;
|
static int buflen = 0;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char s[UTF_SIZ];
|
char s[UTF_SIZ];
|
||||||
int charsize; /* size of utf8 char in bytes */
|
int charsize; /* size of utf8 char in bytes */
|
||||||
|
@ -706,8 +706,8 @@ tcursor(int mode) {
|
||||||
void
|
void
|
||||||
treset(void) {
|
treset(void) {
|
||||||
term.c = (TCursor){{
|
term.c = (TCursor){{
|
||||||
.mode = ATTR_NULL,
|
.mode = ATTR_NULL,
|
||||||
.fg = DefaultFG,
|
.fg = DefaultFG,
|
||||||
.bg = DefaultBG
|
.bg = DefaultBG
|
||||||
}, .x = 0, .y = 0, .state = CURSOR_DEFAULT};
|
}, .x = 0, .y = 0, .state = CURSOR_DEFAULT};
|
||||||
|
|
||||||
|
@ -762,9 +762,9 @@ tscrollup(int orig, int n) {
|
||||||
|
|
||||||
tclearregion(0, orig, term.col-1, orig+n-1);
|
tclearregion(0, orig, term.col-1, orig+n-1);
|
||||||
|
|
||||||
for(i = orig; i <= term.bot-n; i++) {
|
for(i = orig; i <= term.bot-n; i++) {
|
||||||
temp = term.line[i];
|
temp = term.line[i];
|
||||||
term.line[i] = term.line[i+n];
|
term.line[i] = term.line[i+n];
|
||||||
term.line[i+n] = temp;
|
term.line[i+n] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -894,22 +894,22 @@ tsetattr(int *attr, int l) {
|
||||||
term.c.attr.bg = DefaultBG;
|
term.c.attr.bg = DefaultBG;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
term.c.attr.mode |= ATTR_BOLD;
|
term.c.attr.mode |= ATTR_BOLD;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
term.c.attr.mode |= ATTR_UNDERLINE;
|
term.c.attr.mode |= ATTR_UNDERLINE;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
term.c.attr.mode |= ATTR_REVERSE;
|
term.c.attr.mode |= ATTR_REVERSE;
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 22:
|
||||||
term.c.attr.mode &= ~ATTR_BOLD;
|
term.c.attr.mode &= ~ATTR_BOLD;
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
term.c.attr.mode &= ~ATTR_UNDERLINE;
|
term.c.attr.mode &= ~ATTR_UNDERLINE;
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
term.c.attr.mode &= ~ATTR_REVERSE;
|
term.c.attr.mode &= ~ATTR_REVERSE;
|
||||||
break;
|
break;
|
||||||
case 38:
|
case 38:
|
||||||
if(i + 2 < l && attr[i + 1] == 5) {
|
if(i + 2 < l && attr[i + 1] == 5) {
|
||||||
|
@ -920,7 +920,7 @@ tsetattr(int *attr, int l) {
|
||||||
fprintf(stderr, "erresc: bad fgcolor %d\n", attr[i]);
|
fprintf(stderr, "erresc: bad fgcolor %d\n", attr[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(stderr, "erresc: gfx attr %d unknown\n", attr[i]);
|
fprintf(stderr, "erresc: gfx attr %d unknown\n", attr[i]);
|
||||||
break;
|
break;
|
||||||
case 39:
|
case 39:
|
||||||
term.c.attr.fg = DefaultFG;
|
term.c.attr.fg = DefaultFG;
|
||||||
|
@ -934,7 +934,7 @@ tsetattr(int *attr, int l) {
|
||||||
fprintf(stderr, "erresc: bad bgcolor %d\n", attr[i]);
|
fprintf(stderr, "erresc: bad bgcolor %d\n", attr[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(stderr, "erresc: gfx attr %d unknown\n", attr[i]);
|
fprintf(stderr, "erresc: gfx attr %d unknown\n", attr[i]);
|
||||||
break;
|
break;
|
||||||
case 49:
|
case 49:
|
||||||
term.c.attr.bg = DefaultBG;
|
term.c.attr.bg = DefaultBG;
|
||||||
|
@ -948,7 +948,7 @@ tsetattr(int *attr, int l) {
|
||||||
term.c.attr.fg = attr[i] - 90 + 8;
|
term.c.attr.fg = attr[i] - 90 + 8;
|
||||||
else if(BETWEEN(attr[i], 100, 107))
|
else if(BETWEEN(attr[i], 100, 107))
|
||||||
term.c.attr.fg = attr[i] - 100 + 8;
|
term.c.attr.fg = attr[i] - 100 + 8;
|
||||||
else
|
else
|
||||||
fprintf(stderr, "erresc: gfx attr %d unknown\n", attr[i]), csidump();
|
fprintf(stderr, "erresc: gfx attr %d unknown\n", attr[i]), csidump();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -968,7 +968,7 @@ tsetscroll(int t, int b) {
|
||||||
b = temp;
|
b = temp;
|
||||||
}
|
}
|
||||||
term.top = t;
|
term.top = t;
|
||||||
term.bot = b;
|
term.bot = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1193,7 +1193,7 @@ csihandle(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
csidump(void) {
|
csidump(void) {
|
||||||
int i;
|
int i;
|
||||||
printf("ESC [ %s", escseq.priv ? "? " : "");
|
printf("ESC [ %s", escseq.priv ? "? " : "");
|
||||||
if(escseq.narg)
|
if(escseq.narg)
|
||||||
|
@ -1226,7 +1226,7 @@ tputc(char *c) {
|
||||||
csiparse(), csihandle();
|
csiparse(), csihandle();
|
||||||
}
|
}
|
||||||
/* TODO: handle other OSC */
|
/* TODO: handle other OSC */
|
||||||
} else if(term.esc & ESC_OSC) {
|
} else if(term.esc & ESC_OSC) {
|
||||||
if(ascii == ';') {
|
if(ascii == ';') {
|
||||||
term.titlelen = 0;
|
term.titlelen = 0;
|
||||||
term.esc = ESC_START | ESC_TITLE;
|
term.esc = ESC_START | ESC_TITLE;
|
||||||
|
@ -1550,7 +1550,7 @@ xinit(void) {
|
||||||
initfonts(FONT, BOLDFONT);
|
initfonts(FONT, BOLDFONT);
|
||||||
|
|
||||||
/* XXX: Assuming same size for bold font */
|
/* XXX: Assuming same size for bold font */
|
||||||
xw.cw = dc.font.rbearing - dc.font.lbearing;
|
xw.cw = dc.font.rbearing - dc.font.lbearing;
|
||||||
xw.ch = dc.font.ascent + dc.font.descent;
|
xw.ch = dc.font.ascent + dc.font.descent;
|
||||||
|
|
||||||
/* colors */
|
/* colors */
|
||||||
|
@ -1582,8 +1582,8 @@ xinit(void) {
|
||||||
|
|
||||||
/* input methods */
|
/* input methods */
|
||||||
xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL);
|
xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL);
|
||||||
xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
|
xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
|
||||||
| XIMStatusNothing, XNClientWindow, xw.win,
|
| XIMStatusNothing, XNClientWindow, xw.win,
|
||||||
XNFocusWindow, xw.win, NULL);
|
XNFocusWindow, xw.win, NULL);
|
||||||
/* gc */
|
/* gc */
|
||||||
dc.gc = XCreateGC(xw.dpy, xw.win, 0, NULL);
|
dc.gc = XCreateGC(xw.dpy, xw.win, 0, NULL);
|
||||||
|
@ -1591,7 +1591,7 @@ xinit(void) {
|
||||||
/* white cursor, black outline */
|
/* white cursor, black outline */
|
||||||
cursor = XCreateFontCursor(xw.dpy, XC_xterm);
|
cursor = XCreateFontCursor(xw.dpy, XC_xterm);
|
||||||
XDefineCursor(xw.dpy, xw.win, cursor);
|
XDefineCursor(xw.dpy, xw.win, cursor);
|
||||||
XRecolorCursor(xw.dpy, cursor,
|
XRecolorCursor(xw.dpy, cursor,
|
||||||
&(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff},
|
&(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff},
|
||||||
&(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000});
|
&(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000});
|
||||||
|
|
||||||
|
@ -1626,7 +1626,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
XmbDrawImageString(xw.dpy, xw.buf, base.mode & ATTR_BOLD ? dc.bfont.set : dc.font.set,
|
XmbDrawImageString(xw.dpy, xw.buf, base.mode & ATTR_BOLD ? dc.bfont.set : dc.font.set,
|
||||||
dc.gc, winx, winy, s, bytelen);
|
dc.gc, winx, winy, s, bytelen);
|
||||||
|
|
||||||
if(base.mode & ATTR_UNDERLINE)
|
if(base.mode & ATTR_UNDERLINE)
|
||||||
XDrawLine(xw.dpy, xw.buf, dc.gc, winx, winy+1, winx+width-1, winy+1);
|
XDrawLine(xw.dpy, xw.buf, dc.gc, winx, winy+1, winx+width-1, winy+1);
|
||||||
|
@ -1660,7 +1660,7 @@ xdrawcursor(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
draw() {
|
draw() {
|
||||||
drawregion(0, 0, term.col, term.row);
|
drawregion(0, 0, term.col, term.row);
|
||||||
}
|
}
|
||||||
|
@ -1846,7 +1846,7 @@ run(void) {
|
||||||
}
|
}
|
||||||
if(FD_ISSET(cmdfd, &rfd)) {
|
if(FD_ISSET(cmdfd, &rfd)) {
|
||||||
ttyread();
|
ttyread();
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
while(XPending(xw.dpy)) {
|
while(XPending(xw.dpy)) {
|
||||||
XNextEvent(xw.dpy, &ev);
|
XNextEvent(xw.dpy, &ev);
|
||||||
|
|
Loading…
Reference in New Issue