JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Make nyancat(1) work. Important release feature!
[st.git] / st.c
diff --git a/st.c b/st.c
index bf3993a..75c6cea 100644 (file)
--- a/st.c
+++ b/st.c
@@ -77,6 +77,7 @@ enum glyph_attribute {
        ATTR_BOLD      = 4,
        ATTR_GFX       = 8,
        ATTR_ITALIC    = 16,
+       ATTR_BLINK     = 32,
 };
 
 enum cursor_movement {
@@ -619,6 +620,7 @@ void selclear(XEvent *e) {
                return;
        sel.bx = -1;
        tsetdirt(sel.b.y, sel.e.y);
+       draw();
 }
 
 void
@@ -799,9 +801,15 @@ ttynew(void) {
                close(s);
                cmdfd = m;
                signal(SIGCHLD, sigchld);
-               if(opt_io && !(fileio = fopen(opt_io, "w"))) {
-                       fprintf(stderr, "Error opening %s:%s\n",
-                               opt_io, strerror(errno));
+               if(opt_io) {
+                       if(!strcmp(opt_io, "-")) {
+                               fileio = stdout;
+                       } else {
+                               if(!(fileio = fopen(opt_io, "w"))) {
+                                       fprintf(stderr, "Error opening %s:%s\n",
+                                               opt_io, strerror(errno));
+                               }
+                       }
                }
        }
 }
@@ -1125,7 +1133,8 @@ tsetattr(int *attr, int l) {
        for(i = 0; i < l; i++) {
                switch(attr[i]) {
                case 0:
-                       term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE | ATTR_BOLD);
+                       term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE | ATTR_BOLD \
+                                       | ATTR_ITALIC | ATTR_BLINK);
                        term.c.attr.fg = DefaultFG;
                        term.c.attr.bg = DefaultBG;
                        break;
@@ -1138,6 +1147,9 @@ tsetattr(int *attr, int l) {
                case 4:
                        term.c.attr.mode |= ATTR_UNDERLINE;
                        break;
+               case 5:
+                       term.c.attr.mode |= ATTR_BLINK;
+                       break;
                case 7:
                        term.c.attr.mode |= ATTR_REVERSE;
                        break;
@@ -1150,6 +1162,9 @@ tsetattr(int *attr, int l) {
                case 24:
                        term.c.attr.mode &= ~ATTR_UNDERLINE;
                        break;
+               case 25:
+                       term.c.attr.mode &= ~ATTR_BLINK;
+                       break;
                case 27:
                        term.c.attr.mode &= ~ATTR_REVERSE;
                        break;
@@ -1189,7 +1204,7 @@ tsetattr(int *attr, int l) {
                        else if(BETWEEN(attr[i], 90, 97))
                                term.c.attr.fg = attr[i] - 90 + 8;
                        else if(BETWEEN(attr[i], 100, 107))
-                               term.c.attr.fg = attr[i] - 100 + 8;
+                               term.c.attr.bg = attr[i] - 100 + 8;
                        else
                                fprintf(stderr, "erresc(default): gfx attr %d unknown\n", attr[i]), csidump();
                        break;
@@ -1501,6 +1516,9 @@ strhandle(void) {
                        break;
                }
                break;
+       case 'k': /* old title set compatibility */
+               XStoreName(xw.dpy, xw.win, strescseq.buf);
+               break;
        case 'P': /* DSC -- Device Control String */
        case '_': /* APC -- Application Program Command */
        case '^': /* PM -- Privacy Message */
@@ -1563,8 +1581,10 @@ void
 tputc(char *c) {
        char ascii = *c;
 
-       if(fileio)
+       if(fileio) {
                putc(ascii, fileio);
+               fflush(fileio);
+       }
 
        if(term.esc & ESC_START) {
                if(term.esc & ESC_CSI) {
@@ -1614,6 +1634,7 @@ tputc(char *c) {
                        case '_': /* APC -- Application Program Command */
                        case '^': /* PM -- Privacy Message */
                        case ']': /* OSC -- Operating System Command */
+                       case 'k': /* old title set compatibility */
                                strreset();
                                strescseq.type = ascii;
                                term.esc |= ESC_STR;
@@ -1923,6 +1944,17 @@ xinit(void) {
                die("Can't open display\n");
        xw.scr = XDefaultScreen(xw.dpy);
 
+       /* font */
+       initfonts(FONT, BOLDFONT, ITALICFONT);
+
+       /* XXX: Assuming same size for bold font */
+       xw.cw = dc.font.rbearing - dc.font.lbearing;
+       xw.ch = dc.font.ascent + dc.font.descent;
+
+       /* colors */
+       xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
+       xloadcols();
+
        /* adjust fixed window geometry */
        if(xw.isfixed) {
                sw = DisplayWidth(xw.dpy, xw.scr);
@@ -1942,24 +1974,12 @@ xinit(void) {
                xw.fy = 0;
        }
 
-       /* font */
-       initfonts(FONT, BOLDFONT, ITALICFONT);
-
-       /* XXX: Assuming same size for bold font */
-       xw.cw = dc.font.rbearing - dc.font.lbearing;
-       xw.ch = dc.font.ascent + dc.font.descent;
-
-       /* colors */
-       xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
-       xloadcols();
-
        attrs.background_pixel = dc.col[DefaultBG];
        attrs.border_pixel = dc.col[DefaultBG];
        attrs.bit_gravity = NorthWestGravity;
        attrs.event_mask = FocusChangeMask | KeyPressMask
                | ExposureMask | VisibilityChangeMask | StructureNotifyMask
-               | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask
-               | EnterWindowMask | LeaveWindowMask;
+               | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
        attrs.colormap = xw.cmap;
 
        parent = opt_embed ? strtol(opt_embed, NULL, 0) : XRootWindow(xw.dpy, xw.scr);
@@ -2045,7 +2065,6 @@ void
 xcopy() {
        XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}};
        XdbeSwapBuffers(xw.dpy, swpinfo, 1);
-
 }
 
 void