Move font/fontspec variables into x.c and XWindow
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>dev
parent
626b0ae40c
commit
a09138afa5
11
st.c
11
st.c
|
@ -28,9 +28,6 @@
|
||||||
#include <X11/cursorfont.h>
|
#include <X11/cursorfont.h>
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
#define Glyph Glyph_
|
|
||||||
#define Font Font_
|
|
||||||
|
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
|
|
||||||
|
@ -196,7 +193,6 @@ static size_t utf8validate(Rune *, size_t);
|
||||||
static char *base64dec(const char *);
|
static char *base64dec(const char *);
|
||||||
|
|
||||||
static ssize_t xwrite(int, const char *, size_t);
|
static ssize_t xwrite(int, const char *, size_t);
|
||||||
static void *xrealloc(void *, size_t);
|
|
||||||
|
|
||||||
/* Globals */
|
/* Globals */
|
||||||
TermWindow win;
|
TermWindow win;
|
||||||
|
@ -218,10 +214,6 @@ static CSIEscape csiescseq;
|
||||||
static STREscape strescseq;
|
static STREscape strescseq;
|
||||||
static int iofd = 1;
|
static int iofd = 1;
|
||||||
|
|
||||||
char *usedfont = NULL;
|
|
||||||
double usedfontsize = 0;
|
|
||||||
double defaultfontsize = 0;
|
|
||||||
|
|
||||||
static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||||
static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||||
static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||||
|
@ -2516,9 +2508,6 @@ tresize(int col, int row)
|
||||||
free(term.alt[i]);
|
free(term.alt[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* resize to new width */
|
|
||||||
term.specbuf = xrealloc(term.specbuf, col * sizeof(GlyphFontSpec));
|
|
||||||
|
|
||||||
/* resize to new height */
|
/* resize to new height */
|
||||||
term.line = xrealloc(term.line, row * sizeof(Line));
|
term.line = xrealloc(term.line, row * sizeof(Line));
|
||||||
term.alt = xrealloc(term.alt, row * sizeof(Line));
|
term.alt = xrealloc(term.alt, row * sizeof(Line));
|
||||||
|
|
8
st.h
8
st.h
|
@ -92,6 +92,7 @@ typedef unsigned short ushort;
|
||||||
|
|
||||||
typedef uint_least32_t Rune;
|
typedef uint_least32_t Rune;
|
||||||
|
|
||||||
|
#define Glyph Glyph_
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Rune u; /* character code */
|
Rune u; /* character code */
|
||||||
ushort mode; /* attribute flags */
|
ushort mode; /* attribute flags */
|
||||||
|
@ -100,7 +101,6 @@ typedef struct {
|
||||||
} Glyph;
|
} Glyph;
|
||||||
|
|
||||||
typedef Glyph *Line;
|
typedef Glyph *Line;
|
||||||
typedef XftGlyphFontSpec GlyphFontSpec;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Glyph attr; /* current char attributes */
|
Glyph attr; /* current char attributes */
|
||||||
|
@ -116,7 +116,6 @@ typedef struct {
|
||||||
Line *line; /* screen */
|
Line *line; /* screen */
|
||||||
Line *alt; /* alternate screen */
|
Line *alt; /* alternate screen */
|
||||||
int *dirty; /* dirtyness of lines */
|
int *dirty; /* dirtyness of lines */
|
||||||
GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
|
|
||||||
TCursor c; /* cursor */
|
TCursor c; /* cursor */
|
||||||
int top; /* top scroll limit */
|
int top; /* top scroll limit */
|
||||||
int bot; /* bottom scroll limit */
|
int bot; /* bottom scroll limit */
|
||||||
|
@ -213,6 +212,7 @@ size_t utf8decode(char *, Rune *, size_t);
|
||||||
size_t utf8encode(Rune, char *);
|
size_t utf8encode(Rune, char *);
|
||||||
|
|
||||||
void *xmalloc(size_t);
|
void *xmalloc(size_t);
|
||||||
|
void *xrealloc(void *, size_t);
|
||||||
char *xstrdup(char *);
|
char *xstrdup(char *);
|
||||||
|
|
||||||
/* Globals */
|
/* Globals */
|
||||||
|
@ -231,10 +231,6 @@ extern char *opt_name;
|
||||||
extern char *opt_title;
|
extern char *opt_title;
|
||||||
extern int oldbutton;
|
extern int oldbutton;
|
||||||
|
|
||||||
extern char *usedfont;
|
|
||||||
extern double usedfontsize;
|
|
||||||
extern double defaultfontsize;
|
|
||||||
|
|
||||||
/* config.h globals */
|
/* config.h globals */
|
||||||
extern char font[];
|
extern char font[];
|
||||||
extern int borderpx;
|
extern int borderpx;
|
||||||
|
|
18
x.c
18
x.c
|
@ -17,10 +17,6 @@
|
||||||
|
|
||||||
static char *argv0;
|
static char *argv0;
|
||||||
#include "arg.h"
|
#include "arg.h"
|
||||||
|
|
||||||
#define Glyph Glyph_
|
|
||||||
#define Font Font_
|
|
||||||
|
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
|
|
||||||
|
@ -35,6 +31,7 @@ static char *argv0;
|
||||||
|
|
||||||
typedef XftDraw *Draw;
|
typedef XftDraw *Draw;
|
||||||
typedef XftColor Color;
|
typedef XftColor Color;
|
||||||
|
typedef XftGlyphFontSpec GlyphFontSpec;
|
||||||
|
|
||||||
/* Purely graphic info */
|
/* Purely graphic info */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -42,6 +39,7 @@ typedef struct {
|
||||||
Colormap cmap;
|
Colormap cmap;
|
||||||
Window win;
|
Window win;
|
||||||
Drawable buf;
|
Drawable buf;
|
||||||
|
GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
|
||||||
Atom xembed, wmdeletewin, netwmname, netwmpid;
|
Atom xembed, wmdeletewin, netwmname, netwmpid;
|
||||||
XIM xim;
|
XIM xim;
|
||||||
XIC xic;
|
XIC xic;
|
||||||
|
@ -59,6 +57,7 @@ typedef struct {
|
||||||
} XSelection;
|
} XSelection;
|
||||||
|
|
||||||
/* Font structure */
|
/* Font structure */
|
||||||
|
#define Font Font_
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int height;
|
int height;
|
||||||
int width;
|
int width;
|
||||||
|
@ -166,6 +165,9 @@ typedef struct {
|
||||||
/* Fontcache is an array now. A new font will be appended to the array. */
|
/* Fontcache is an array now. A new font will be appended to the array. */
|
||||||
static Fontcache frc[16];
|
static Fontcache frc[16];
|
||||||
static int frclen = 0;
|
static int frclen = 0;
|
||||||
|
static char *usedfont = NULL;
|
||||||
|
static double usedfontsize = 0;
|
||||||
|
static double defaultfontsize = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
zoom(const Arg *arg)
|
zoom(const Arg *arg)
|
||||||
|
@ -605,6 +607,9 @@ xresize(int col, int row)
|
||||||
DefaultDepth(xw.dpy, xw.scr));
|
DefaultDepth(xw.dpy, xw.scr));
|
||||||
XftDrawChange(xw.draw, xw.buf);
|
XftDrawChange(xw.draw, xw.buf);
|
||||||
xclear(0, 0, win.w, win.h);
|
xclear(0, 0, win.w, win.h);
|
||||||
|
|
||||||
|
/* resize to new width */
|
||||||
|
xw.specbuf = xrealloc(xw.specbuf, col * sizeof(GlyphFontSpec));
|
||||||
}
|
}
|
||||||
|
|
||||||
ushort
|
ushort
|
||||||
|
@ -965,6 +970,9 @@ xinit(void)
|
||||||
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
|
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
|
||||||
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
|
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
|
||||||
|
|
||||||
|
/* font spec buffer */
|
||||||
|
xw.specbuf = xmalloc(term.col * sizeof(GlyphFontSpec));
|
||||||
|
|
||||||
/* Xft rendering context */
|
/* Xft rendering context */
|
||||||
xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
|
xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
|
||||||
|
|
||||||
|
@ -1456,7 +1464,7 @@ drawregion(int x1, int y1, int x2, int y2)
|
||||||
|
|
||||||
term.dirty[y] = 0;
|
term.dirty[y] = 0;
|
||||||
|
|
||||||
specs = term.specbuf;
|
specs = xw.specbuf;
|
||||||
numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y);
|
numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y);
|
||||||
|
|
||||||
i = ox = 0;
|
i = ox = 0;
|
||||||
|
|
Loading…
Reference in New Issue