Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ssh://suckless.org/gitrepos/st
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
9f9c161
..
69b2491
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-314,6
+314,7
@@
static void clippaste(const Arg *);
static void numlock(const Arg *);
static void selpaste(const Arg *);
static void xzoom(const Arg *);
static void numlock(const Arg *);
static void selpaste(const Arg *);
static void xzoom(const Arg *);
+static void printsel(const Arg *);
static void printscreen(const Arg *) ;
static void toggleprinter(const Arg *);
static void printscreen(const Arg *) ;
static void toggleprinter(const Arg *);
@@
-359,6
+360,7
@@
static void strreset(void);
static int tattrset(int);
static void tprinter(char *s, size_t len);
static int tattrset(int);
static void tprinter(char *s, size_t len);
+static void tdumpsel(void);
static void tdumpline(int);
static void tdump(void);
static void tclearregion(int, int, int, int);
static void tdumpline(int);
static void tdump(void);
static void tclearregion(int, int, int, int);
@@
-435,6
+437,7
@@
static void selrequest(XEvent *);
static void selinit(void);
static void selsort(void);
static inline bool selected(int, int);
static void selinit(void);
static void selsort(void);
static inline bool selected(int, int);
+static char *getsel(void);
static void selcopy(void);
static void selscroll(int, int);
static void selsnap(int, int *, int *, int);
static void selcopy(void);
static void selscroll(int, int);
static void selsnap(int, int *, int *, int);
@@
-955,8
+958,8
@@
bpress(XEvent *e) {
}
}
}
}
-void
-
selcopy
(void) {
+char *
+
getsel
(void) {
char *str, *ptr;
int x, y, bufsize, size, i, ex;
Glyph *gp, *last;
char *str, *ptr;
int x, y, bufsize, size, i, ex;
Glyph *gp, *last;
@@
-1015,7
+1018,12
@@
selcopy(void) {
}
*ptr = 0;
}
}
*ptr = 0;
}
- xsetsel(str);
+ return str;
+}
+
+void
+selcopy(void) {
+ xsetsel(getsel());
}
void
}
void
@@
-1994,6
+2002,9
@@
csihandle(void) {
case 1:
tdumpline(term.c.y);
break;
case 1:
tdumpline(term.c.y);
break;
+ case 2:
+ tdumpsel();
+ break;
case 4:
term.mode &= ~MODE_PRINT;
break;
case 4:
term.mode &= ~MODE_PRINT;
break;
@@
-2294,6
+2305,21
@@
printscreen(const Arg *arg) {
tdump();
}
tdump();
}
+void
+printsel(const Arg *arg) {
+ tdumpsel();
+}
+
+void
+tdumpsel(void)
+{
+ char *ptr;
+
+ ptr = getsel();
+ tprinter(ptr, strlen(ptr));
+ free(ptr);
+}
+
void
tdumpline(int n) {
Glyph *bp, *end;
void
tdumpline(int n) {
Glyph *bp, *end;
@@
-2861,7
+2887,8
@@
xhints(void) {
sizeh->min_height = sizeh->max_height = xw.fh;
}
sizeh->min_height = sizeh->max_height = xw.fh;
}
- XSetWMProperties(xw.dpy, xw.win, NULL, NULL, NULL, 0, sizeh, &wm, &class);
+ XSetWMProperties(xw.dpy, xw.win, NULL, NULL, NULL, 0, sizeh, &wm,
+ &class);
XFree(sizeh);
}
XFree(sizeh);
}
@@
-3150,6
+3177,7
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
if(base.fg == defaultfg)
base.fg = defaultunderline;
}
if(base.fg == defaultfg)
base.fg = defaultunderline;
}
+
if(IS_TRUECOL(base.fg)) {
colfg.alpha = 0xffff;
colfg.red = TRUERED(base.fg);
if(IS_TRUECOL(base.fg)) {
colfg.alpha = 0xffff;
colfg.red = TRUERED(base.fg);
@@
-3172,8
+3200,6
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
bg = &dc.col[base.bg];
}
bg = &dc.col[base.bg];
}
-
-
if(base.mode & ATTR_BOLD) {
if(BETWEEN(base.fg, 0, 7)) {
/* basic system colors */
if(base.mode & ATTR_BOLD) {
if(BETWEEN(base.fg, 0, 7)) {
/* basic system colors */
@@
-3203,7
+3229,8
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
colfg.green = ~fg->color.green;
colfg.blue = ~fg->color.blue;
colfg.alpha = fg->color.alpha;
colfg.green = ~fg->color.green;
colfg.blue = ~fg->color.blue;
colfg.alpha = fg->color.alpha;
- XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &revfg);
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg,
+ &revfg);
fg = &revfg;
}
fg = &revfg;
}
@@
-3214,7
+3241,8
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
colbg.green = ~bg->color.green;
colbg.blue = ~bg->color.blue;
colbg.alpha = bg->color.alpha;
colbg.green = ~bg->color.green;
colbg.blue = ~bg->color.blue;
colbg.alpha = bg->color.alpha;
- XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &revbg);
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg,
+ &revbg);
bg = &revbg;
}
}
bg = &revbg;
}
}
@@
-3294,7
+3322,7
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
u8fblen += u8cblen;
}
if(doesexist) {
u8fblen += u8cblen;
}
if(doesexist) {
- if
(oneatatime)
+ if(oneatatime)
continue;
break;
}
continue;
break;
}
@@
-3317,6
+3345,8
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
* Nothing was found in the cache. Now use
* some dozen of Fontconfig calls to get the
* font for one single character.
* Nothing was found in the cache. Now use
* some dozen of Fontconfig calls to get the
* font for one single character.
+ *
+ * Xft and fontconfig are design failures.
*/
fcpattern = FcPatternDuplicate(font->pattern);
fccharset = FcCharSetCreate();
*/
fcpattern = FcPatternDuplicate(font->pattern);
fccharset = FcCharSetCreate();
@@
-3360,6
+3390,12
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
xp += xw.cw * wcwidth(u8char);
}
xp += xw.cw * wcwidth(u8char);
}
+ /*
+ * This is how the loop above actually should be. Why does the
+ * application have to care about font details?
+ *
+ * I have to repeat: Xft and Fontconfig are design failures.
+ */
/*
XftDrawStringUtf8(xw.draw, fg, font->set, winx,
winy + font->ascent, (FcChar8 *)s, bytelen);
/*
XftDrawStringUtf8(xw.draw, fg, font->set, winx,
winy + font->ascent, (FcChar8 *)s, bytelen);