X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=75c3dd1039f9bdfe9d5051d4f8514c236c600ccf;hb=20e0da7f14cc5f30863e0b8014fa223fbaff1e30;hp=ce32cc0d3fe645ae1d19098e6b1a72d3d12febd0;hpb=30683c70ab62fd37b5921cf72077b9aef2cb842e;p=st.git diff --git a/st.c b/st.c index ce32cc0..75c3dd1 100644 --- a/st.c +++ b/st.c @@ -3,24 +3,17 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include -#include -#include #include #include -#include -#include #include -#include #include #include "st.h" @@ -36,6 +29,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 +89,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 +206,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); @@ -1671,7 +1693,6 @@ csihandle(void) tputtab(csiescseq.arg[0]); break; case 'J': /* ED -- Clear screen */ - selclear(); switch (csiescseq.arg[0]) { case 0: /* below */ tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);