Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Call XdbeQueryExtension before of calling any Xdbe function
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
19d0a86
..
b013bca
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-240,7
+240,7
@@
typedef struct {
short lbearing;
short rbearing;
XFontSet set;
short lbearing;
short rbearing;
XFontSet set;
- } font, bfont, ifont;
+ } font, bfont, ifont
, ibfont
;
} DC;
static void die(const char*, ...);
} DC;
static void die(const char*, ...);
@@
-296,6
+296,7
@@
static void xcopy(void);
static void xdrawcursor(void);
static void xinit(void);
static void xloadcols(void);
static void xdrawcursor(void);
static void xinit(void);
static void xloadcols(void);
+static void xresettitle(void);
static void xseturgency(int);
static void xsetsel(char*);
static void xresize(int, int);
static void xseturgency(int);
static void xsetsel(char*);
static void xresize(int, int);
@@
-773,6
+774,13
@@
execsh(void) {
unsetenv("LINES");
unsetenv("TERMCAP");
unsetenv("LINES");
unsetenv("TERMCAP");
+ signal(SIGCHLD, SIG_DFL);
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGINT, SIG_DFL);
+ signal(SIGQUIT, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGALRM, SIG_DFL);
+
DEFAULT(envshell, SHELL);
putenv("TERM="TNAME);
args = opt_cmd ? opt_cmd : (char*[]){envshell, "-i", NULL};
DEFAULT(envshell, SHELL);
putenv("TERM="TNAME);
args = opt_cmd ? opt_cmd : (char*[]){envshell, "-i", NULL};
@@
-1171,6
+1179,7
@@
tsetattr(int *attr, int l) {
case 7:
term.c.attr.mode |= ATTR_REVERSE;
break;
case 7:
term.c.attr.mode |= ATTR_REVERSE;
break;
+ case 21:
case 22:
term.c.attr.mode &= ~ATTR_BOLD;
break;
case 22:
term.c.attr.mode &= ~ATTR_BOLD;
break;
@@
-1683,6
+1692,7
@@
tputc(char *c) {
case 'c': /* RIS -- Reset to inital state */
treset();
term.esc = 0;
case 'c': /* RIS -- Reset to inital state */
treset();
term.esc = 0;
+ xresettitle();
break;
case '=': /* DECPAM -- Application keypad */
term.mode |= MODE_APPKEYPAD;
break;
case '=': /* DECPAM -- Application keypad */
term.mode |= MODE_APPKEYPAD;
@@
-1713,6
+1723,8
@@
tputc(char *c) {
if(sel.bx != -1 && BETWEEN(term.c.y, sel.by, sel.ey))
sel.bx = -1;
switch(ascii) {
if(sel.bx != -1 && BETWEEN(term.c.y, sel.by, sel.ey))
sel.bx = -1;
switch(ascii) {
+ case '\0': /* padding character, do nothing */
+ break;
case '\t':
tputtab(1);
break;
case '\t':
tputtab(1);
break;
@@
-1933,13
+1945,15
@@
xgetfontinfo(XFontSet set, int *ascent, int *descent, short *lbearing, short *rb
}
void
}
void
-initfonts(char *fontstr, char *bfontstr, char *ifontstr) {
+initfonts(char *fontstr, char *bfontstr, char *ifontstr
, char *ibfontstr
) {
if((dc.font.set = xinitfont(fontstr)) == NULL)
die("Can't load font %s\n", fontstr);
if((dc.bfont.set = xinitfont(bfontstr)) == NULL)
die("Can't load bfont %s\n", bfontstr);
if((dc.ifont.set = xinitfont(ifontstr)) == NULL)
die("Can't load ifont %s\n", ifontstr);
if((dc.font.set = xinitfont(fontstr)) == NULL)
die("Can't load font %s\n", fontstr);
if((dc.bfont.set = xinitfont(bfontstr)) == NULL)
die("Can't load bfont %s\n", bfontstr);
if((dc.ifont.set = xinitfont(ifontstr)) == NULL)
die("Can't load ifont %s\n", ifontstr);
+ if((dc.ibfont.set = xinitfont(ibfontstr)) == NULL)
+ die("Can't load ibfont %s\n", ibfontstr);
xgetfontinfo(dc.font.set, &dc.font.ascent, &dc.font.descent,
&dc.font.lbearing, &dc.font.rbearing);
xgetfontinfo(dc.font.set, &dc.font.ascent, &dc.font.descent,
&dc.font.lbearing, &dc.font.rbearing);
@@
-1947,6
+1961,8
@@
initfonts(char *fontstr, char *bfontstr, char *ifontstr) {
&dc.bfont.lbearing, &dc.bfont.rbearing);
xgetfontinfo(dc.ifont.set, &dc.ifont.ascent, &dc.ifont.descent,
&dc.ifont.lbearing, &dc.ifont.rbearing);
&dc.bfont.lbearing, &dc.bfont.rbearing);
xgetfontinfo(dc.ifont.set, &dc.ifont.ascent, &dc.ifont.descent,
&dc.ifont.lbearing, &dc.ifont.rbearing);
+ xgetfontinfo(dc.ibfont.set, &dc.ibfont.ascent, &dc.ibfont.descent,
+ &dc.ibfont.lbearing, &dc.ibfont.rbearing);
}
void
}
void
@@
-1954,14
+1970,14
@@
xinit(void) {
XSetWindowAttributes attrs;
Cursor cursor;
Window parent;
XSetWindowAttributes attrs;
Cursor cursor;
Window parent;
- int sw, sh;
+ int sw, sh
, major, minor
;
if(!(xw.dpy = XOpenDisplay(NULL)))
die("Can't open display\n");
xw.scr = XDefaultScreen(xw.dpy);
/* font */
if(!(xw.dpy = XOpenDisplay(NULL)))
die("Can't open display\n");
xw.scr = XDefaultScreen(xw.dpy);
/* font */
- initfonts(FONT, BOLDFONT, ITALICFONT);
+ initfonts(FONT, BOLDFONT, ITALICFONT
, ITALICBOLDFONT
);
/* XXX: Assuming same size for bold font */
xw.cw = dc.font.rbearing - dc.font.lbearing;
/* XXX: Assuming same size for bold font */
xw.cw = dc.font.rbearing - dc.font.lbearing;
@@
-2005,9
+2021,10
@@
xinit(void) {
CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask
| CWColormap,
&attrs);
CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask
| CWColormap,
&attrs);
+ if(!XdbeQueryExtension(xw.dpy, &major, &minor))
+ die("Xdbe extension is not present\n");
xw.buf = XdbeAllocateBackBufferName(xw.dpy, xw.win, XdbeCopied);
xw.buf = XdbeAllocateBackBufferName(xw.dpy, xw.win, XdbeCopied);
-
/* input methods */
xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL);
xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
/* input methods */
xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL);
xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
@@
-2025,7
+2042,7
@@
xinit(void) {
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
-
XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st"
);
+
xresettitle(
);
XMapWindow(xw.dpy, xw.win);
xhints();
XSync(xw.dpy, 0);
XMapWindow(xw.dpy, xw.win);
xhints();
XSync(xw.dpy, 0);
@@
-2056,6
+2073,8
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
if(base.mode & ATTR_ITALIC)
fontset = dc.ifont.set;
if(base.mode & ATTR_ITALIC)
fontset = dc.ifont.set;
+ if(base.mode & (ATTR_ITALIC|ATTR_ITALIC))
+ fontset = dc.ibfont.set;
XSetBackground(xw.dpy, dc.gc, dc.col[bg]);
XSetForeground(xw.dpy, dc.gc, dc.col[fg]);
XSetBackground(xw.dpy, dc.gc, dc.col[bg]);
XSetForeground(xw.dpy, dc.gc, dc.col[fg]);
@@
-2121,6
+2140,11
@@
xdrawcursor(void) {
xcopy();
}
xcopy();
}
+void
+xresettitle(void) {
+ XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st");
+}
+
void
redraw(void) {
struct timespec tv = {0, REDRAW_TIMEOUT * 1000};
void
redraw(void) {
struct timespec tv = {0, REDRAW_TIMEOUT * 1000};