X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=e288902032a743cb160611d6ff7909d464bc559d;hb=e8c13ebe8001a7870a70b698d8b8fa80b7c90fd3;hp=deddb0d2c2e76faa9c4538a1f98b941fa0b1dd3d;hpb=d2f157c7418e2762316e5471f819ec1e5c49e93c;p=st.git diff --git a/st.c b/st.c index deddb0d..e288902 100644 --- a/st.c +++ b/st.c @@ -20,8 +20,6 @@ #include #include -#define TNAME "st-256color" - /* Arbitrary sizes */ #define ESC_TITLE_SIZ 256 #define ESC_BUF_SIZ 256 @@ -107,8 +105,6 @@ typedef struct { char s[ESC_BUF_SIZ]; } Key; -#include "config.h" - /* Drawing Context */ typedef struct { unsigned long col[256]; @@ -117,6 +113,8 @@ typedef struct { GC gc; } DC; +#include "config.h" + static void die(const char *errstr, ...); static void draw(int); static void execsh(void); @@ -138,6 +136,7 @@ static void tinsertblankline(int); static void tmoveto(int, int); static void tnew(int, int); static void tnewline(void); +static void tputtab(void); static void tputc(char); static void tputs(char*, int); static void treset(void); @@ -154,6 +153,9 @@ static void ttyread(void); static void ttyresize(int, int); static void ttywrite(const char *, size_t); +static void xbell(void); +static void xdraws(char *, Glyph, int, int, int); +static void xhints(void); static void xclear(int, int, int, int); static void xcursor(int); static void xinit(void); @@ -245,7 +247,7 @@ ttynew(void) { if((m = posix_openpt(O_RDWR | O_NOCTTY)) < 0) die("openpt failed: %s\n", SERRNO); if(grantpt(m) < 0) - die("grandpt failed: %s\n", SERRNO); + die("grantpt failed: %s\n", SERRNO); if(unlockpt(m) < 0) die("unlockpt failed: %s\n", SERRNO); if(!(pts = ptsname(m))) @@ -263,7 +265,9 @@ ttynew(void) { dup2(s, STDOUT_FILENO); dup2(s, STDERR_FILENO); if(ioctl(s, TIOCSCTTY, NULL) < 0) - die("ioctl TTIOCSTTY failed: %s\n", SERRNO); + die("ioctl TIOCSCTTY failed: %s\n", SERRNO); + close(s); + close(m); execsh(); break; default: @@ -445,11 +449,6 @@ tmovecursor(int dir) { break; case CURSOR_LEFT: xf--; - if(term.mode & MODE_WRAP && xf < 0) { - xf = term.col-1, yf--; - if(yf < term.top) - yf = term.top, xf = 0; - } break; case CURSOR_RIGHT: xf++; @@ -499,21 +498,21 @@ tdeletechar(int n) { return; } memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], size * sizeof(Glyph)); - tclearregion(term.col-size, term.c.y, term.col-1, term.c.y); + tclearregion(term.col-n, term.c.y, term.col-1, term.c.y); } void tinsertblank(int n) { int src = term.c.x; int dst = src + n; - int size = term.col - n - src; + int size = term.col - dst; if(dst >= term.col) { tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); return; } memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], size * sizeof(Glyph)); - tclearregion(src, term.c.y, dst, term.c.y); + tclearregion(src, term.c.y, dst - 1, term.c.y); } void @@ -864,12 +863,7 @@ csireset(void) { void tputtab(void) { int space = TAB - term.c.x % TAB; - - if(term.c.x + space >= term.col) - space--; - - for(; space > 0; space--) - tmovecursor(CURSOR_RIGHT); + tmoveto(term.c.x + space, term.c.y); } void @@ -1175,7 +1169,7 @@ xcursor(int mode) { if(term.line[term.c.y][term.c.x].state & GLYPH_SET) g.c = term.line[term.c.y][term.c.x].c; - + /* remove the old cursor */ if(term.line[oldy][oldx].state & GLYPH_SET) xdraws(&term.line[oldy][oldx].c, term.line[oldy][oldx], oldx, oldy, 1);