aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2017-10-10 12:17:25 -0500
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:53:24 -0600
commita09138afa57adb4b76dba8ca72dc7ee2642a5c8d (patch)
tree4d5db9a65174fa159b3bd7be8b67a7d445ed6f2c
parent626b0ae40c71b6c1e02ece79bf033432647381a6 (diff)
downloadst-patched-a09138afa57adb4b76dba8ca72dc7ee2642a5c8d.tar.bz2
st-patched-a09138afa57adb4b76dba8ca72dc7ee2642a5c8d.tar.xz
st-patched-a09138afa57adb4b76dba8ca72dc7ee2642a5c8d.zip
Move font/fontspec variables into x.c and XWindow
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
-rw-r--r--st.c11
-rw-r--r--st.h8
-rw-r--r--x.c18
3 files changed, 15 insertions, 22 deletions
diff --git a/st.c b/st.c
index df43fac..540b487 100644
--- a/st.c
+++ b/st.c
@@ -28,9 +28,6 @@
28#include <X11/cursorfont.h> 28#include <X11/cursorfont.h>
29#include <X11/Xft/Xft.h> 29#include <X11/Xft/Xft.h>
30 30
31#define Glyph Glyph_
32#define Font Font_
33
34#include "st.h" 31#include "st.h"
35#include "win.h" 32#include "win.h"
36 33
@@ -196,7 +193,6 @@ static size_t utf8validate(Rune *, size_t);
196static char *base64dec(const char *); 193static char *base64dec(const char *);
197 194
198static ssize_t xwrite(int, const char *, size_t); 195static ssize_t xwrite(int, const char *, size_t);
199static void *xrealloc(void *, size_t);
200 196
201/* Globals */ 197/* Globals */
202TermWindow win; 198TermWindow win;
@@ -218,10 +214,6 @@ static CSIEscape csiescseq;
218static STREscape strescseq; 214static STREscape strescseq;
219static int iofd = 1; 215static int iofd = 1;
220 216
221char *usedfont = NULL;
222double usedfontsize = 0;
223double defaultfontsize = 0;
224
225static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; 217static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
226static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; 218static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
227static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000}; 219static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
@@ -2516,9 +2508,6 @@ tresize(int col, int row)
2516 free(term.alt[i]); 2508 free(term.alt[i]);
2517 } 2509 }
2518 2510
2519 /* resize to new width */
2520 term.specbuf = xrealloc(term.specbuf, col * sizeof(GlyphFontSpec));
2521
2522 /* resize to new height */ 2511 /* resize to new height */
2523 term.line = xrealloc(term.line, row * sizeof(Line)); 2512 term.line = xrealloc(term.line, row * sizeof(Line));
2524 term.alt = xrealloc(term.alt, row * sizeof(Line)); 2513 term.alt = xrealloc(term.alt, row * sizeof(Line));
diff --git a/st.h b/st.h
index ad94351..2199c13 100644
--- a/st.h
+++ b/st.h
@@ -92,6 +92,7 @@ typedef unsigned short ushort;
92 92
93typedef uint_least32_t Rune; 93typedef uint_least32_t Rune;
94 94
95#define Glyph Glyph_
95typedef struct { 96typedef struct {
96 Rune u; /* character code */ 97 Rune u; /* character code */
97 ushort mode; /* attribute flags */ 98 ushort mode; /* attribute flags */
@@ -100,7 +101,6 @@ typedef struct {
100} Glyph; 101} Glyph;
101 102
102typedef Glyph *Line; 103typedef Glyph *Line;
103typedef XftGlyphFontSpec GlyphFontSpec;
104 104
105typedef struct { 105typedef struct {
106 Glyph attr; /* current char attributes */ 106 Glyph attr; /* current char attributes */
@@ -116,7 +116,6 @@ typedef struct {
116 Line *line; /* screen */ 116 Line *line; /* screen */
117 Line *alt; /* alternate screen */ 117 Line *alt; /* alternate screen */
118 int *dirty; /* dirtyness of lines */ 118 int *dirty; /* dirtyness of lines */
119 GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
120 TCursor c; /* cursor */ 119 TCursor c; /* cursor */
121 int top; /* top scroll limit */ 120 int top; /* top scroll limit */
122 int bot; /* bottom scroll limit */ 121 int bot; /* bottom scroll limit */
@@ -213,6 +212,7 @@ size_t utf8decode(char *, Rune *, size_t);
213size_t utf8encode(Rune, char *); 212size_t utf8encode(Rune, char *);
214 213
215void *xmalloc(size_t); 214void *xmalloc(size_t);
215void *xrealloc(void *, size_t);
216char *xstrdup(char *); 216char *xstrdup(char *);
217 217
218/* Globals */ 218/* Globals */
@@ -231,10 +231,6 @@ extern char *opt_name;
231extern char *opt_title; 231extern char *opt_title;
232extern int oldbutton; 232extern int oldbutton;
233 233
234extern char *usedfont;
235extern double usedfontsize;
236extern double defaultfontsize;
237
238/* config.h globals */ 234/* config.h globals */
239extern char font[]; 235extern char font[];
240extern int borderpx; 236extern int borderpx;
diff --git a/x.c b/x.c
index 5b3c97b..186e408 100644
--- a/x.c
+++ b/x.c
@@ -17,10 +17,6 @@
17 17
18static char *argv0; 18static char *argv0;
19#include "arg.h" 19#include "arg.h"
20
21#define Glyph Glyph_
22#define Font Font_
23
24#include "st.h" 20#include "st.h"
25#include "win.h" 21#include "win.h"
26 22
@@ -35,6 +31,7 @@ static char *argv0;
35 31
36typedef XftDraw *Draw; 32typedef XftDraw *Draw;
37typedef XftColor Color; 33typedef XftColor Color;
34typedef XftGlyphFontSpec GlyphFontSpec;
38 35
39/* Purely graphic info */ 36/* Purely graphic info */
40typedef struct { 37typedef struct {
@@ -42,6 +39,7 @@ typedef struct {
42 Colormap cmap; 39 Colormap cmap;
43 Window win; 40 Window win;
44 Drawable buf; 41 Drawable buf;
42 GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
45 Atom xembed, wmdeletewin, netwmname, netwmpid; 43 Atom xembed, wmdeletewin, netwmname, netwmpid;
46 XIM xim; 44 XIM xim;
47 XIC xic; 45 XIC xic;
@@ -59,6 +57,7 @@ typedef struct {
59} XSelection; 57} XSelection;
60 58
61/* Font structure */ 59/* Font structure */
60#define Font Font_
62typedef struct { 61typedef struct {
63 int height; 62 int height;
64 int width; 63 int width;
@@ -166,6 +165,9 @@ typedef struct {
166/* Fontcache is an array now. A new font will be appended to the array. */ 165/* Fontcache is an array now. A new font will be appended to the array. */
167static Fontcache frc[16]; 166static Fontcache frc[16];
168static int frclen = 0; 167static int frclen = 0;
168static char *usedfont = NULL;
169static double usedfontsize = 0;
170static double defaultfontsize = 0;
169 171
170void 172void
171zoom(const Arg *arg) 173zoom(const Arg *arg)
@@ -605,6 +607,9 @@ xresize(int col, int row)
605 DefaultDepth(xw.dpy, xw.scr)); 607 DefaultDepth(xw.dpy, xw.scr));
606 XftDrawChange(xw.draw, xw.buf); 608 XftDrawChange(xw.draw, xw.buf);
607 xclear(0, 0, win.w, win.h); 609 xclear(0, 0, win.w, win.h);
610
611 /* resize to new width */
612 xw.specbuf = xrealloc(xw.specbuf, col * sizeof(GlyphFontSpec));
608} 613}
609 614
610ushort 615ushort
@@ -965,6 +970,9 @@ xinit(void)
965 XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); 970 XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
966 XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); 971 XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
967 972
973 /* font spec buffer */
974 xw.specbuf = xmalloc(term.col * sizeof(GlyphFontSpec));
975
968 /* Xft rendering context */ 976 /* Xft rendering context */
969 xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); 977 xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
970 978
@@ -1456,7 +1464,7 @@ drawregion(int x1, int y1, int x2, int y2)
1456 1464
1457 term.dirty[y] = 0; 1465 term.dirty[y] = 0;
1458 1466
1459 specs = term.specbuf; 1467 specs = xw.specbuf;
1460 numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y); 1468 numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y);
1461 1469
1462 i = ox = 0; 1470 i = ox = 0;