ESC_DCS =128,
};
+/* Internal representation of the screen */
+typedef struct {
+ int row; /* nb row */
+ int col; /* nb col */
+ Line *line; /* screen */
+ Line *alt; /* alternate screen */
+ int *dirty; /* dirtyness of lines */
+ TCursor c; /* cursor */
+ int ocx; /* old cursor col */
+ int ocy; /* old cursor row */
+ int top; /* top scroll limit */
+ int bot; /* bottom scroll limit */
+ int mode; /* terminal mode flags */
+ int esc; /* escape state flags */
+ char trantbl[4]; /* charset table translation */
+ int charset; /* current charset */
+ int icharset; /* selected charset for sequence */
+ int *tabs;
+} Term;
+
/* CSI Escape sequence structs */
/* ESC '[' [[ [<priv>] <arg> [;]] <mode> [<mode>]] */
typedef struct {
static void tdeftran(char);
static void tstrsequence(uchar);
+static void drawregion(int, int, int, int);
+
static void selscroll(int, int);
static void selsnap(int *, int *, int);
static ssize_t xwrite(int, const char *, size_t);
/* Globals */
-Term term;
int cmdfd;
pid_t pid;
int oldbutton = 3; /* button event on startup: 3 = release */
+static Term term;
static Selection sel;
static CSIEscape csiescseq;
static STREscape strescseq;
xsettitle(NULL);
}
+void
+drawregion(int x1, int y1, int x2, int y2)
+{
+ int y;
+ for (y = y1; y < y2; y++) {
+ if (!term.dirty[y])
+ continue;
+
+ term.dirty[y] = 0;
+ xdrawline(term.line[y], x1, y, x2);
+ }
+}
+
+void
+draw(void)
+{
+ int cx = term.c.x;
+
+ if (!xstartdraw())
+ return;
+
+ /* adjust cursor position */
+ LIMIT(term.ocx, 0, term.col-1);
+ LIMIT(term.ocy, 0, term.row-1);
+ if (term.line[term.ocy][term.ocx].mode & ATTR_WDUMMY)
+ term.ocx--;
+ if (term.line[term.c.y][cx].mode & ATTR_WDUMMY)
+ cx--;
+
+ drawregion(0, 0, term.col, term.row);
+ xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
+ term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
+ term.ocx = cx, term.ocy = term.c.y;
+ xfinishdraw();
+}
+
void
redraw(void)
{