]> git.armaanb.net Git - st.git/blobdiff - st.c
Pull term references out of xdrawcursor
[st.git] / st.c
diff --git a/st.c b/st.c
index 01791a57d25e05261d31878e566355260b3263a8..4bf637887cbb40392afbf06ae28c074d1349391d 100644 (file)
--- a/st.c
+++ b/st.c
@@ -166,6 +166,8 @@ static int32_t tdefcolor(int *, int *, int);
 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);
 
@@ -2526,6 +2528,42 @@ resettitle(void)
        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)
 {