From 88d8293fb4ba150a5f19d58d133b5db93d9dcfa5 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 24 Feb 2018 14:53:23 -0600 Subject: Move win-agnostic parts of draw/drawregion to st.c Introduces three functions to encapsulate X-specific behavior: * xdrawline: draws a portion of a single line (used by drawregion) * xbegindraw: called to prepare for drawing (will be useful for e.g. Wayland) and returns true if drawing should happen * xfinishdraw: called to finish drawing (used by draw) Signed-off-by: Devin J. Pohly --- st.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'st.c') diff --git a/st.c b/st.c index 01791a5..504239e 100644 --- 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,29 @@ 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) +{ + if (!xstartdraw()) + return; + drawregion(0, 0, term.col, term.row); + xdrawcursor(); + xfinishdraw(); +} + void redraw(void) { -- cgit v1.2.1