xterm-16.patch.txt

XFree86 3.1.2Ea - xterm patch #16 - 1996/6/25 - T.Dickey
 
Adam Tla/lka <atlka@pg.gda.pl> told me a couple of weeks ago that I'd missed
some of the background coloring in xterm.  I investigated, and found that while
I'd picked up on the clear-to-bottom and clear-to-end-of-line operations, I'd
overlooked the insert/delete lines.  Just so I wouldn't overlook any more of
these, I updated a copy of vttest to test ISO colors and bce (background color
erase).  This patch introduces a new function, ClearCurBackground, whose calls
replace the direct XClearArea calls that I'd overlooked.
 
(There's also a few compiler warnings fixed, etc ;-)
 
--------------------------------------------------------------------------------
 button.c   |    2 -
 charproc.c |   14 +++----
 misc.c     |    2 -
 util.c     |  114 +++++++++++++++++++++++++++++------------------------------
 xterm.h    |    1 
 5 files changed, 66 insertions, 67 deletions
--------------------------------------------------------------------------------
Index: button.c
--- xterm/button.c      Mon Jun 10 13:03:46 1996
+++ xterm-16/button.c   Tue Jun 25 17:25:54 1996
@@ -108,6 +108,7 @@
 static int replyToEmacs;
 
 static Boolean ConvertSelection PROTO_XT_CVT_SELECT_ARGS;
+static SelectUnit EvalSelectUnit PROTO((Time buttonDownTime, SelectUnit defaultUnit));
 static char *SaveText PROTO((TScreen *screen, int row, int scol, int ecol, char *lp, int *eol));
 static int LastTextCol PROTO((int row));
 static int Length PROTO((TScreen *screen, int row, int scol, int ecol));
@@ -122,7 +123,6 @@
 static void SelectSet PROTO((Widget w, XEvent *event, String *params, Cardinal num_params));
 static void SelectionDone PROTO((Widget w, Atom *selection, Atom *target));
 static void SelectionReceived PROTO_XT_SEL_CB_ARGS;
-static void SetSelectUnit PROTO((Time buttonDownTime, SelectUnit defaultUnit));
 static void StartSelect PROTO((int startrow, int startcol));
 static void TrackDown PROTO((XButtonEvent *event));
 static void _GetSelection PROTO((Widget w, Time ev_time, String *params, Cardinal num_params));
Index: charproc.c
--- xterm/charproc.c    Mon Jun 10 13:03:46 1996
+++ xterm-16/charproc.c Tue Jun 25 17:56:54 1996
@@ -2408,13 +2408,11 @@
 {
     register int rows = screen->max_row + 1;
     char *save [MAX_PTRS * MAX_ROWS];
+    Size_t len = MAX_PTRS * sizeof(char *) * rows;
 
-    memmove( (char *)save, (char *)screen->buf,
-         MAX_PTRS * sizeof(char *) * rows);
-    memmove( (char *)screen->buf, (char *)screen->altbuf, 
-         MAX_PTRS * sizeof(char *) * rows);
-    memmove( (char *)screen->altbuf, (char *)save,
-         MAX_PTRS * sizeof(char *) * rows);
+    memmove( (char *)save,           (char *)screen->buf,    len);
+    memmove( (char *)screen->buf,    (char *)screen->altbuf, len);
+    memmove( (char *)screen->altbuf, (char *)save,           len);
 }
 
 void
@@ -2897,7 +2895,7 @@
        for(ns=s=tmp; ns && *s;) {
            while (*s && isspace(*s)) s++;
            if (!*s) break;
-           if ((ns = end = index(s, ',')) == 0)
+           if ((ns = end = strchr(s, ',')) == 0)
                end = s + strlen(s);
            while (isspace(*end)) end--;
            *end = '\0';
@@ -2932,7 +2930,7 @@
     for(s = tmp; s && !found;) {
        while (*s && isspace(*s)) s++;
        if (!*s) break;
-       if ((ns = end = index(s, ',')) != 0)
+       if ((ns = end = strchr(s, ',')) != 0)
            ns++;
        else
            end = s + strlen(s);
Index: misc.c
--- xterm/misc.c        Sun Mar 17 13:33:40 1996
+++ xterm-16/misc.c     Tue Jun 25 17:56:50 1996
@@ -974,7 +974,7 @@
            if (names[0]==';')
                 thisName=      NULL;
            else thisName=      names;
-           names=      index(names,';');
+           names = strchr(names,';');
            if (names!=NULL) {
                *names= '\0';
                names++;
Index: util.c
--- xterm/util.c        Mon May  6 14:30:48 1996
+++ xterm-16/util.c     Tue Jun 25 17:25:38 1996
@@ -117,16 +117,13 @@
        screen->scroll_amt = 0;
        screen->refresh_amt = 0;
        if(refreshheight > 0) {
-               XClearArea (
-                   screen->display,
-                   TextWindow(screen),
-                   (int) screen->border + screen->scrollbar,
+               ClearCurBackground(screen,
                    (int) refreshtop * FontHeight(screen) + screen->border,
-                   (unsigned) Width(screen),
+                   (int) screen->border + screen->scrollbar,
                    (unsigned) refreshheight * FontHeight(screen),
-                   FALSE);
+                   (unsigned) Width(screen));
                ScrnRefresh(screen, refreshtop, 0, refreshheight,
-                screen->max_col + 1, False);
+                   screen->max_col + 1, False);
        }
 }
 
@@ -239,14 +236,11 @@
        }
        scrolling_copy_area(screen, scrolltop+amount, scrollheight, amount);
        if(refreshheight > 0) {
-               XClearArea (
-                  screen->display,
-                  TextWindow(screen),
-                  (int) screen->border + screen->scrollbar,
-                  (int) refreshtop * FontHeight(screen) + screen->border,
-                  (unsigned) Width(screen),
-                  (unsigned) refreshheight * FontHeight(screen),
-                  FALSE);
+               ClearCurBackground(screen,
+                   (int) refreshtop * FontHeight(screen) + screen->border,
+                   (int) screen->border + screen->scrollbar,
+                   (unsigned) refreshheight * FontHeight(screen),
+                   (unsigned) Width(screen));
                if(refreshheight > shift)
                        refreshheight = shift;
        }
@@ -319,15 +313,13 @@
            screen->scrolls++;
        }
        scrolling_copy_area(screen, scrolltop-amount, scrollheight, -amount);
-       if(refreshheight > 0)
-               XClearArea (
-                   screen->display,
-                   TextWindow(screen),
-                   (int) screen->border + screen->scrollbar,
+       if(refreshheight > 0) {
+               ClearCurBackground(screen,
                    (int) refreshtop * FontHeight(screen) + screen->border,
-                   (unsigned) Width(screen),
+                   (int) screen->border + screen->scrollbar,
                    (unsigned) refreshheight * FontHeight(screen),
-                   FALSE);
+                   (unsigned) Width(screen));
+       }
     }
        ScrnInsertLine (screen->buf, screen->bot_marg, screen->top_marg,
                        amount, screen->max_col + 1);
@@ -381,15 +373,13 @@
        if((i = screen->cur_row + refreshheight - 1 - bot) > 0)
                refreshheight -= i;
        vertical_copy_area(screen, scrolltop-n, scrollheight, -n);
-       if(refreshheight > 0)
-               XClearArea (
-                   screen->display,
-                   TextWindow(screen),
-                   (int) screen->border + screen->scrollbar,
+       if(refreshheight > 0) {
+               ClearCurBackground(screen,
                    (int) refreshtop * FontHeight(screen) + screen->border,
-                   (unsigned) Width(screen),
+                   (int) screen->border + screen->scrollbar,
                    (unsigned) refreshheight * FontHeight(screen),
-                   FALSE);
+                   (unsigned) Width(screen));
+       }
     }
        /* adjust screen->buf */
        ScrnInsertLine(screen->buf, screen->bot_marg, screen->cur_row, n,
@@ -459,15 +449,13 @@
                }
        }
        vertical_copy_area(screen, scrolltop+n, scrollheight, n);
-       if(refreshheight > 0)
-               XClearArea (
-                   screen->display,
-                   TextWindow(screen),
-                   (int) screen->border + screen->scrollbar,
+       if(refreshheight > 0) {
+               ClearCurBackground(screen,
                    (int) refreshtop * FontHeight(screen) + screen->border,
-                   (unsigned) Width(screen),
+                   (int) screen->border + screen->scrollbar,
                    (unsigned) refreshheight * FontHeight(screen),
-                   FALSE);
+                   (unsigned) Width(screen));
+       }
     }
        /* adjust screen->buf */
        if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0)
@@ -583,12 +571,11 @@
                if((height = screen->cur_row + top) > screen->max_row)
                        height = screen->max_row;
                if((height -= top) > 0) {
-                       useCurBackground(TRUE);
-                       XClearArea(screen->display, TextWindow(screen),
-                        screen->border + screen->scrollbar, top *
-                        FontHeight(screen) + screen->border,
-                        Width(screen), height * FontHeight(screen), FALSE);
-                       useCurBackground(FALSE);
+                       ClearCurBackground(screen,
+                           top * FontHeight(screen) + screen->border,
+                           screen->border + screen->scrollbar,
+                           height * FontHeight(screen),
+                           Width(screen));
                }
 
                if(screen->cur_row - screen->topline <= screen->max_row)
@@ -611,13 +598,11 @@
                if(screen->scroll_amt)
                        FlushScroll(screen);
                if(++top <= screen->max_row) {
-                       useCurBackground(TRUE);
-                       XClearArea(screen->display, TextWindow(screen),
-                        screen->border + screen->scrollbar, top *
-                        FontHeight(screen) + screen->border,
-                        Width(screen), (screen->max_row - top + 1) *
-                        FontHeight(screen), FALSE);
-                       useCurBackground(FALSE);
+                       ClearCurBackground(screen,
+                           top * FontHeight(screen) + screen->border,
+                           screen->border + screen->scrollbar,
+                           (screen->max_row - top + 1) * FontHeight(screen),
+                           Width(screen));
                }
        }
        ClearBufRows(screen, screen->cur_row + 1, screen->max_row);
@@ -742,13 +727,11 @@
        if((top = -screen->topline) <= screen->max_row) {
                if(screen->scroll_amt)
                        FlushScroll(screen);
-               useCurBackground(TRUE);
-               XClearArea(screen->display, TextWindow(screen),
-                        screen->border + screen->scrollbar, 
-                        top * FontHeight(screen) + screen->border,     
-                        Width(screen), (screen->max_row - top + 1) *
-                        FontHeight(screen), FALSE);
-               useCurBackground(FALSE);
+               ClearCurBackground(screen,
+                   top * FontHeight(screen) + screen->border,  
+                   screen->border + screen->scrollbar, 
+                   (screen->max_row - top + 1) * FontHeight(screen),
+                   Width(screen));
        }
        ClearBufRows (screen, 0, screen->max_row);
 }
@@ -1257,11 +1240,28 @@
  * in the current SGR background. Otherwise, reset to the window's default
  * background.
  */
-void useCurBackground(Bool flag)
+void useCurBackground(flag)
+       Bool flag;
 {
        TScreen *screen = &term->screen;
        int color = flag ? term->cur_background : -1;
        Pixel   bg = getXtermBackground(term->flags, color);
 
        XSetWindowBackground(screen->display, TextWindow(screen), bg);
+}
+
+/*
+ * Using the "current" SGR background, clear a rectangle.
+ */
+void ClearCurBackground(screen, top,left, height,width)
+       register TScreen *screen;
+       int top;
+       int left;
+       unsigned height;
+       unsigned width;
+{
+       useCurBackground(TRUE);
+       XClearArea (screen->display, TextWindow(screen),
+               left, top, width, height, FALSE);
+       useCurBackground(FALSE);
 }
Index: xterm.h
--- xterm/xterm.h       Mon May  6 14:30:48 1996
+++ xterm-16/xterm.h    Tue Jun 25 17:26:16 1996
@@ -174,6 +174,7 @@
 extern void ChangeColors PROTO((XtermWidget tw, ScrnColors *pNew));
 extern void ClearAbove PROTO((TScreen *screen));
 extern void ClearBelow PROTO((TScreen *screen));
+extern void ClearCurBackground PROTO((TScreen *screen, int top, int left, unsigned height, unsigned width));
 extern void ClearLeft PROTO((TScreen *screen));
 extern void ClearLine PROTO((TScreen *screen));
 extern void ClearRight PROTO((TScreen *screen));