aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2018-02-24 16:32:20 -0600
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:56:26 -0600
commite0215d53770a9b6bc6e5d7b9a603ecd34dbd7100 (patch)
treeb696b3fa2c69270a198c3bcc1e0a289b12b3538c
parent30683c70ab62fd37b5921cf72077b9aef2cb842e (diff)
downloadst-patched-e0215d53770a9b6bc6e5d7b9a603ecd34dbd7100.tar.bz2
st-patched-e0215d53770a9b6bc6e5d7b9a603ecd34dbd7100.tar.xz
st-patched-e0215d53770a9b6bc6e5d7b9a603ecd34dbd7100.zip
Reduce visibility wherever possible
When possible, declare functions/variables static and move struct definitions out of headers. In order to allow utf8decode to become internal, use codepoint for DECSCUSR extension directly. Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
-rw-r--r--st.c31
-rw-r--r--st.h40
-rw-r--r--win.h1
-rw-r--r--x.c15
4 files changed, 43 insertions, 44 deletions
diff --git a/st.c b/st.c
index ce32cc0..f46aab6 100644
--- a/st.c
+++ b/st.c
@@ -36,6 +36,7 @@
36 36
37/* Arbitrary sizes */ 37/* Arbitrary sizes */
38#define UTF_INVALID 0xFFFD 38#define UTF_INVALID 0xFFFD
39#define UTF_SIZ 4
39#define ESC_BUF_SIZ (128*UTF_SIZ) 40#define ESC_BUF_SIZ (128*UTF_SIZ)
40#define ESC_ARG_SIZ 16 41#define ESC_ARG_SIZ 16
41#define STR_BUF_SIZ ESC_BUF_SIZ 42#define STR_BUF_SIZ ESC_BUF_SIZ
@@ -95,6 +96,31 @@ enum escape_state {
95 ESC_DCS =128, 96 ESC_DCS =128,
96}; 97};
97 98
99typedef struct {
100 Glyph attr; /* current char attributes */
101 int x;
102 int y;
103 char state;
104} TCursor;
105
106typedef struct {
107 int mode;
108 int type;
109 int snap;
110 /*
111 * Selection variables:
112 * nb – normalized coordinates of the beginning of the selection
113 * ne – normalized coordinates of the end of the selection
114 * ob – original coordinates of the beginning of the selection
115 * oe – original coordinates of the end of the selection
116 */
117 struct {
118 int x, y;
119 } nb, ne, ob, oe;
120
121 int alt;
122} Selection;
123
98/* Internal representation of the screen */ 124/* Internal representation of the screen */
99typedef struct { 125typedef struct {
100 int row; /* nb row */ 126 int row; /* nb row */
@@ -187,15 +213,18 @@ static void tstrsequence(uchar);
187 213
188static void drawregion(int, int, int, int); 214static void drawregion(int, int, int, int);
189 215
216static void selnormalize(void);
190static void selscroll(int, int); 217static void selscroll(int, int);
191static void selsnap(int *, int *, int); 218static void selsnap(int *, int *, int);
192 219
220static size_t utf8decode(const char *, Rune *, size_t);
193static Rune utf8decodebyte(char, size_t *); 221static Rune utf8decodebyte(char, size_t *);
194static char utf8encodebyte(Rune, size_t); 222static char utf8encodebyte(Rune, size_t);
195static char *utf8strchr(char *s, Rune u); 223static char *utf8strchr(char *, Rune);
196static size_t utf8validate(Rune *, size_t); 224static size_t utf8validate(Rune *, size_t);
197 225
198static char *base64dec(const char *); 226static char *base64dec(const char *);
227static char base64dec_getc(const char **);
199 228
200static ssize_t xwrite(int, const char *, size_t); 229static ssize_t xwrite(int, const char *, size_t);
201 230
diff --git a/st.h b/st.h
index 0a7472b..1015fc6 100644
--- a/st.h
+++ b/st.h
@@ -1,8 +1,5 @@
1/* See LICENSE for license details. */ 1/* See LICENSE for license details. */
2 2
3/* Arbitrary sizes */
4#define UTF_SIZ 4
5
6/* macros */ 3/* macros */
7#define MIN(a, b) ((a) < (b) ? (a) : (b)) 4#define MIN(a, b) ((a) < (b) ? (a) : (b))
8#define MAX(a, b) ((a) < (b) ? (b) : (a)) 5#define MAX(a, b) ((a) < (b) ? (b) : (a))
@@ -69,41 +66,6 @@ typedef struct {
69 66
70typedef Glyph *Line; 67typedef Glyph *Line;
71 68
72typedef struct {
73 Glyph attr; /* current char attributes */
74 int x;
75 int y;
76 char state;
77} TCursor;
78
79/* Purely graphic info */
80typedef struct {
81 int tw, th; /* tty width and height */
82 int w, h; /* window width and height */
83 int ch; /* char height */
84 int cw; /* char width */
85 int mode; /* window state/mode flags */
86 int cursor; /* cursor style */
87} TermWindow;
88
89typedef struct {
90 int mode;
91 int type;
92 int snap;
93 /*
94 * Selection variables:
95 * nb – normalized coordinates of the beginning of the selection
96 * ne – normalized coordinates of the end of the selection
97 * ob – original coordinates of the beginning of the selection
98 * oe – original coordinates of the end of the selection
99 */
100 struct {
101 int x, y;
102 } nb, ne, ob, oe;
103
104 int alt;
105} Selection;
106
107typedef union { 69typedef union {
108 int i; 70 int i;
109 uint ui; 71 uint ui;
@@ -137,11 +99,9 @@ void selclear(void);
137void selinit(void); 99void selinit(void);
138void selstart(int, int, int); 100void selstart(int, int, int);
139void selextend(int, int, int, int); 101void selextend(int, int, int, int);
140void selnormalize(void);
141int selected(int, int); 102int selected(int, int);
142char *getsel(void); 103char *getsel(void);
143 104
144size_t utf8decode(const char *, Rune *, size_t);
145size_t utf8encode(Rune, char *); 105size_t utf8encode(Rune, char *);
146 106
147void *xmalloc(size_t); 107void *xmalloc(size_t);
diff --git a/win.h b/win.h
index 7a866fd..31f327d 100644
--- a/win.h
+++ b/win.h
@@ -27,7 +27,6 @@ void xbell(void);
27void xclipcopy(void); 27void xclipcopy(void);
28void xdrawcursor(int, int, Glyph, int, int, Glyph); 28void xdrawcursor(int, int, Glyph, int, int, Glyph);
29void xdrawline(Line, int, int, int); 29void xdrawline(Line, int, int, int);
30void xhints(void);
31void xfinishdraw(void); 30void xfinishdraw(void);
32void xloadcols(void); 31void xloadcols(void);
33int xsetcolorname(int, const char *); 32int xsetcolorname(int, const char *);
diff --git a/x.c b/x.c
index 970d6dd..f7b0528 100644
--- a/x.c
+++ b/x.c
@@ -76,6 +76,15 @@ typedef XftGlyphFontSpec GlyphFontSpec;
76 76
77/* Purely graphic info */ 77/* Purely graphic info */
78typedef struct { 78typedef struct {
79 int tw, th; /* tty width and height */
80 int w, h; /* window width and height */
81 int ch; /* char height */
82 int cw; /* char width */
83 int mode; /* window state/mode flags */
84 int cursor; /* cursor style */
85} TermWindow;
86
87typedef struct {
79 Display *dpy; 88 Display *dpy;
80 Colormap cmap; 89 Colormap cmap;
81 Window win; 90 Window win;
@@ -133,6 +142,8 @@ static int xgeommasktogravity(int);
133static void xinit(int, int); 142static void xinit(int, int);
134static void cresize(int, int); 143static void cresize(int, int);
135static void xresize(int, int); 144static void xresize(int, int);
145static void xhints(void);
146static int xloadcolor(int, const char *, Color *);
136static int xloadfont(Font *, FcPattern *); 147static int xloadfont(Font *, FcPattern *);
137static void xloadfonts(char *, double); 148static void xloadfonts(char *, double);
138static void xunloadfont(Font *); 149static void xunloadfont(Font *);
@@ -1430,8 +1441,8 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
1430 /* draw the new one */ 1441 /* draw the new one */
1431 if (IS_SET(MODE_FOCUSED)) { 1442 if (IS_SET(MODE_FOCUSED)) {
1432 switch (win.cursor) { 1443 switch (win.cursor) {
1433 case 7: /* st extension: snowman */ 1444 case 7: /* st extension: snowman (U+2603) */
1434 utf8decode("☃", &g.u, UTF_SIZ); 1445 g.u = 0x2603;
1435 case 0: /* Blinking Block */ 1446 case 0: /* Blinking Block */
1436 case 1: /* Blinking Block (Default) */ 1447 case 1: /* Blinking Block (Default) */
1437 case 2: /* Steady Block */ 1448 case 2: /* Steady Block */