mirror of
https://github.com/LukeSmithxyz/st.git
synced 2024-11-22 07:15:59 +01:00
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>
This commit is contained in:
parent
30683c70ab
commit
e0215d5377
4 changed files with 43 additions and 44 deletions
31
st.c
31
st.c
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
/* Arbitrary sizes */
|
/* Arbitrary sizes */
|
||||||
#define UTF_INVALID 0xFFFD
|
#define UTF_INVALID 0xFFFD
|
||||||
|
#define UTF_SIZ 4
|
||||||
#define ESC_BUF_SIZ (128*UTF_SIZ)
|
#define ESC_BUF_SIZ (128*UTF_SIZ)
|
||||||
#define ESC_ARG_SIZ 16
|
#define ESC_ARG_SIZ 16
|
||||||
#define STR_BUF_SIZ ESC_BUF_SIZ
|
#define STR_BUF_SIZ ESC_BUF_SIZ
|
||||||
|
@ -95,6 +96,31 @@ enum escape_state {
|
||||||
ESC_DCS =128,
|
ESC_DCS =128,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Glyph attr; /* current char attributes */
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
char state;
|
||||||
|
} TCursor;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int mode;
|
||||||
|
int type;
|
||||||
|
int snap;
|
||||||
|
/*
|
||||||
|
* Selection variables:
|
||||||
|
* nb – normalized coordinates of the beginning of the selection
|
||||||
|
* ne – normalized coordinates of the end of the selection
|
||||||
|
* ob – original coordinates of the beginning of the selection
|
||||||
|
* oe – original coordinates of the end of the selection
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
int x, y;
|
||||||
|
} nb, ne, ob, oe;
|
||||||
|
|
||||||
|
int alt;
|
||||||
|
} Selection;
|
||||||
|
|
||||||
/* Internal representation of the screen */
|
/* Internal representation of the screen */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int row; /* nb row */
|
int row; /* nb row */
|
||||||
|
@ -187,15 +213,18 @@ static void tstrsequence(uchar);
|
||||||
|
|
||||||
static void drawregion(int, int, int, int);
|
static void drawregion(int, int, int, int);
|
||||||
|
|
||||||
|
static void selnormalize(void);
|
||||||
static void selscroll(int, int);
|
static void selscroll(int, int);
|
||||||
static void selsnap(int *, int *, int);
|
static void selsnap(int *, int *, int);
|
||||||
|
|
||||||
|
static size_t utf8decode(const char *, Rune *, size_t);
|
||||||
static Rune utf8decodebyte(char, size_t *);
|
static Rune utf8decodebyte(char, size_t *);
|
||||||
static char utf8encodebyte(Rune, size_t);
|
static char utf8encodebyte(Rune, size_t);
|
||||||
static char *utf8strchr(char *s, Rune u);
|
static char *utf8strchr(char *, Rune);
|
||||||
static size_t utf8validate(Rune *, size_t);
|
static size_t utf8validate(Rune *, size_t);
|
||||||
|
|
||||||
static char *base64dec(const char *);
|
static char *base64dec(const char *);
|
||||||
|
static char base64dec_getc(const char **);
|
||||||
|
|
||||||
static ssize_t xwrite(int, const char *, size_t);
|
static ssize_t xwrite(int, const char *, size_t);
|
||||||
|
|
||||||
|
|
40
st.h
40
st.h
|
@ -1,8 +1,5 @@
|
||||||
/* See LICENSE for license details. */
|
/* See LICENSE for license details. */
|
||||||
|
|
||||||
/* Arbitrary sizes */
|
|
||||||
#define UTF_SIZ 4
|
|
||||||
|
|
||||||
/* macros */
|
/* macros */
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
#define MAX(a, b) ((a) < (b) ? (b) : (a))
|
#define MAX(a, b) ((a) < (b) ? (b) : (a))
|
||||||
|
@ -69,41 +66,6 @@ typedef struct {
|
||||||
|
|
||||||
typedef Glyph *Line;
|
typedef Glyph *Line;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Glyph attr; /* current char attributes */
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
char state;
|
|
||||||
} TCursor;
|
|
||||||
|
|
||||||
/* Purely graphic info */
|
|
||||||
typedef struct {
|
|
||||||
int tw, th; /* tty width and height */
|
|
||||||
int w, h; /* window width and height */
|
|
||||||
int ch; /* char height */
|
|
||||||
int cw; /* char width */
|
|
||||||
int mode; /* window state/mode flags */
|
|
||||||
int cursor; /* cursor style */
|
|
||||||
} TermWindow;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int mode;
|
|
||||||
int type;
|
|
||||||
int snap;
|
|
||||||
/*
|
|
||||||
* Selection variables:
|
|
||||||
* nb – normalized coordinates of the beginning of the selection
|
|
||||||
* ne – normalized coordinates of the end of the selection
|
|
||||||
* ob – original coordinates of the beginning of the selection
|
|
||||||
* oe – original coordinates of the end of the selection
|
|
||||||
*/
|
|
||||||
struct {
|
|
||||||
int x, y;
|
|
||||||
} nb, ne, ob, oe;
|
|
||||||
|
|
||||||
int alt;
|
|
||||||
} Selection;
|
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
int i;
|
int i;
|
||||||
uint ui;
|
uint ui;
|
||||||
|
@ -137,11 +99,9 @@ void selclear(void);
|
||||||
void selinit(void);
|
void selinit(void);
|
||||||
void selstart(int, int, int);
|
void selstart(int, int, int);
|
||||||
void selextend(int, int, int, int);
|
void selextend(int, int, int, int);
|
||||||
void selnormalize(void);
|
|
||||||
int selected(int, int);
|
int selected(int, int);
|
||||||
char *getsel(void);
|
char *getsel(void);
|
||||||
|
|
||||||
size_t utf8decode(const char *, Rune *, size_t);
|
|
||||||
size_t utf8encode(Rune, char *);
|
size_t utf8encode(Rune, char *);
|
||||||
|
|
||||||
void *xmalloc(size_t);
|
void *xmalloc(size_t);
|
||||||
|
|
1
win.h
1
win.h
|
@ -27,7 +27,6 @@ void xbell(void);
|
||||||
void xclipcopy(void);
|
void xclipcopy(void);
|
||||||
void xdrawcursor(int, int, Glyph, int, int, Glyph);
|
void xdrawcursor(int, int, Glyph, int, int, Glyph);
|
||||||
void xdrawline(Line, int, int, int);
|
void xdrawline(Line, int, int, int);
|
||||||
void xhints(void);
|
|
||||||
void xfinishdraw(void);
|
void xfinishdraw(void);
|
||||||
void xloadcols(void);
|
void xloadcols(void);
|
||||||
int xsetcolorname(int, const char *);
|
int xsetcolorname(int, const char *);
|
||||||
|
|
15
x.c
15
x.c
|
@ -75,6 +75,15 @@ typedef XftColor Color;
|
||||||
typedef XftGlyphFontSpec GlyphFontSpec;
|
typedef XftGlyphFontSpec GlyphFontSpec;
|
||||||
|
|
||||||
/* Purely graphic info */
|
/* Purely graphic info */
|
||||||
|
typedef struct {
|
||||||
|
int tw, th; /* tty width and height */
|
||||||
|
int w, h; /* window width and height */
|
||||||
|
int ch; /* char height */
|
||||||
|
int cw; /* char width */
|
||||||
|
int mode; /* window state/mode flags */
|
||||||
|
int cursor; /* cursor style */
|
||||||
|
} TermWindow;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
Colormap cmap;
|
Colormap cmap;
|
||||||
|
@ -133,6 +142,8 @@ static int xgeommasktogravity(int);
|
||||||
static void xinit(int, int);
|
static void xinit(int, int);
|
||||||
static void cresize(int, int);
|
static void cresize(int, int);
|
||||||
static void xresize(int, int);
|
static void xresize(int, int);
|
||||||
|
static void xhints(void);
|
||||||
|
static int xloadcolor(int, const char *, Color *);
|
||||||
static int xloadfont(Font *, FcPattern *);
|
static int xloadfont(Font *, FcPattern *);
|
||||||
static void xloadfonts(char *, double);
|
static void xloadfonts(char *, double);
|
||||||
static void xunloadfont(Font *);
|
static void xunloadfont(Font *);
|
||||||
|
@ -1430,8 +1441,8 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
|
||||||
/* draw the new one */
|
/* draw the new one */
|
||||||
if (IS_SET(MODE_FOCUSED)) {
|
if (IS_SET(MODE_FOCUSED)) {
|
||||||
switch (win.cursor) {
|
switch (win.cursor) {
|
||||||
case 7: /* st extension: snowman */
|
case 7: /* st extension: snowman (U+2603) */
|
||||||
utf8decode("☃", &g.u, UTF_SIZ);
|
g.u = 0x2603;
|
||||||
case 0: /* Blinking Block */
|
case 0: /* Blinking Block */
|
||||||
case 1: /* Blinking Block (Default) */
|
case 1: /* Blinking Block (Default) */
|
||||||
case 2: /* Steady Block */
|
case 2: /* Steady Block */
|
||||||
|
|
Loading…
Reference in a new issue