X-Git-Url: https://git.danieliu.xyz/?p=st.git;a=blobdiff_plain;f=st.c;h=f46aab61c0329a11c652bbb574f9a71525dfc994;hp=ce32cc0d3fe645ae1d19098e6b1a72d3d12febd0;hb=e0215d53770a9b6bc6e5d7b9a603ecd34dbd7100;hpb=30683c70ab62fd37b5921cf72077b9aef2cb842e diff --git a/st.c b/st.c index ce32cc0..f46aab6 100644 --- a/st.c +++ b/st.c @@ -36,6 +36,7 @@ /* Arbitrary sizes */ #define UTF_INVALID 0xFFFD +#define UTF_SIZ 4 #define ESC_BUF_SIZ (128*UTF_SIZ) #define ESC_ARG_SIZ 16 #define STR_BUF_SIZ ESC_BUF_SIZ @@ -95,6 +96,31 @@ enum escape_state { 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 */ typedef struct { int row; /* nb row */ @@ -187,15 +213,18 @@ static void tstrsequence(uchar); static void drawregion(int, int, int, int); +static void selnormalize(void); static void selscroll(int, int); static void selsnap(int *, int *, int); +static size_t utf8decode(const char *, Rune *, size_t); static Rune utf8decodebyte(char, 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 char *base64dec(const char *); +static char base64dec_getc(const char **); static ssize_t xwrite(int, const char *, size_t);