CURSOR_SAVE, CURSOR_LOAD };
enum { CURSOR_DEFAULT = 0, CURSOR_HIDE = 1, CURSOR_WRAPNEXT = 2 };
enum { GLYPH_SET=1, GLYPH_DIRTY=2 };
CURSOR_SAVE, CURSOR_LOAD };
enum { CURSOR_DEFAULT = 0, CURSOR_HIDE = 1, CURSOR_WRAPNEXT = 2 };
enum { GLYPH_SET=1, GLYPH_DIRTY=2 };
-enum { MODE_WRAP=1, MODE_INSERT=2, MODE_APPKEYPAD=4 };
+enum { MODE_WRAP=1, MODE_INSERT=2, MODE_APPKEYPAD=4, MODE_ALTSCREEN=8 };
enum { ESC_START=1, ESC_CSI=2, ESC_OSC=4, ESC_TITLE=8, ESC_ALTCHARSET=16 };
enum { SCREEN_UPDATE, SCREEN_REDRAW };
enum { ESC_START=1, ESC_CSI=2, ESC_OSC=4, ESC_TITLE=8, ESC_ALTCHARSET=16 };
enum { SCREEN_UPDATE, SCREEN_REDRAW };
static void tsetattr(int*, int);
static void tsetchar(char);
static void tsetscroll(int, int);
static void tsetattr(int*, int);
static void tsetchar(char);
static void tsetscroll(int, int);
static void ttynew(void);
static void ttyread(void);
static void ttyresize(int, int);
static void ttywrite(const char *, size_t);
static void ttynew(void);
static void ttyread(void);
static void ttyresize(int, int);
static void ttywrite(const char *, size_t);
static void xdraws(char *, Glyph, int, int, int);
static void xhints(void);
static void xclear(int, int, int, int);
static void xdraws(char *, Glyph, int, int, int);
static void xhints(void);
static void xclear(int, int, int, int);
static void expose(XEvent *);
static char* kmap(KeySym);
static void kpress(XEvent *);
static void resize(XEvent *);
static void expose(XEvent *);
static char* kmap(KeySym);
static void kpress(XEvent *);
static void resize(XEvent *);
-void
-xbell(void) {
- XSetForeground(xw.dis, dc.gc, dc.col[BellCol]);
- XFillRectangle(xw.dis, xw.win, dc.gc, BORDER, BORDER, xw.bufw, xw.bufh);
- XFlush(xw.dis);
- usleep(BellTime);
- draw(SCREEN_REDRAW);
-}
-
/* set screen size */
term.row = row, term.col = col;
term.line = malloc(term.row * sizeof(Line));
/* set screen size */
term.row = row, term.col = col;
term.line = malloc(term.row * sizeof(Line));
- case 1048: /* XXX: no alt. screen to erase/save */
+ case 1047:
+ if(IS_SET(MODE_ALTSCREEN)) {
+ tclearregion(0, 0, term.col-1, term.row-1);
+ tswapscreen();
+ }
+ break;
+ case 1048:
+ tcursor(CURSOR_LOAD);
+ break;
- tclearregion(0, 0, term.col-1, term.row-1);
+ if(IS_SET(MODE_ALTSCREEN)) {
+ tclearregion(0, 0, term.col-1, term.row-1);
+ tswapscreen();
+ }
- case 1048:
- case 1049: /* XXX: no alt. screen to erase/save */
+ case 1047:
+ if(IS_SET(MODE_ALTSCREEN))
+ tclearregion(0, 0, term.col-1, term.row-1);
+ else
+ tswapscreen();
+ break;
+ case 1048:
- tclearregion(0, 0, term.col-1, term.row-1);
+ break;
+ case 1049:
+ tcursor(CURSOR_SAVE);
+ if(IS_SET(MODE_ALTSCREEN))
+ tclearregion(0, 0, term.col-1, term.row-1);
+ else
+ tswapscreen();
/* resize to new height */
term.line = realloc(term.line, row * sizeof(Line));
/* resize to new height */
term.line = realloc(term.line, row * sizeof(Line));
/* resize each row to new width, zero-pad if needed */
for(i = 0; i < minrow; i++) {
term.line[i] = realloc(term.line[i], col * sizeof(Glyph));
/* resize each row to new width, zero-pad if needed */
for(i = 0; i < minrow; i++) {
term.line[i] = realloc(term.line[i], col * sizeof(Glyph));
/* update terminal size */
term.col = col, term.row = row;
/* update terminal size */
term.col = col, term.row = row;
static int oldx = 0;
static int oldy = 0;
Glyph g = {' ', ATTR_NULL, DefaultBG, DefaultCS, 0};
static int oldx = 0;
static int oldy = 0;
Glyph g = {' ', ATTR_NULL, DefaultBG, DefaultCS, 0};
xclear(oldx, oldy, oldx, oldy);
/* draw the new one */
xclear(oldx, oldy, oldx, oldy);
/* draw the new one */
xdraws(&g.c, g, term.c.x, term.c.y, 1);
oldx = term.c.x, oldy = term.c.y;
}
xdraws(&g.c, g, term.c.x, term.c.y, 1);
oldx = term.c.x, oldy = term.c.y;
}
if(term.line[y][x].state & GLYPH_SET)
xdrawc(x, y, term.line[y][x]);
if(term.line[y][x].state & GLYPH_SET)
xdrawc(x, y, term.line[y][x]);
XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER);
XFlush(xw.dis);
}
XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER);
XFlush(xw.dis);
}
if(i > 0)
xdraws(buf, base, ox, y, i);
}
if(i > 0)
xdraws(buf, base, ox, y, i);
}
XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER);
XFlush(xw.dis);
}
XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER);
XFlush(xw.dis);
}
+void
+xseturgency(int add) {
+ XWMHints *h = XGetWMHints(xw.dis, xw.win);
+ h->flags = add ? (h->flags | XUrgencyHint) : (h->flags & ~XUrgencyHint);
+ XSetWMHints(xw.dis, xw.win, h);
+ XFree(h);
+}
+
+void
+focus(XEvent *ev) {
+ if((xw.hasfocus = ev->type == FocusIn))
+ xseturgency(0);
+ draw(SCREEN_UPDATE);
+}
+
XResizeWindow(xw.dis, xw.win, xw.w, xw.h); /* XXX: fix resize bug in wmii (?) */
XResizeWindow(xw.dis, xw.win, xw.w, xw.h); /* XXX: fix resize bug in wmii (?) */