xterm - 1996/1/7 - patch #4 - T.Dickey
When setting up for this phase, I saw that you'd corrected the bug that I found
in ClearLeft. I decided to make this series of patches anyway, since
readability never hurt (and there's the potential for finding another bug while
reviewing this set).
button.c:
+ use SCRN_BUF_xxxxS macros - n/c
charproc.c:
+ use SCRN_BUF_xxxxS macros - n/c
ptyx.h:
+ added four macros: SCRN_BUF_CHARS, SCRN_BUF_ATTRS,
SCRN_BUF_FORES, SCRN_BUF_BACKS to represent the four
arrays that are derived from screen->buf.
screen.c:
+ use SCRN_BUF_xxxxS macros - n/c
util.c:
+ use SCRN_BUF_xxxxS macros - n/c
--------------------------------------------------------------------------------
button.c | 8 ++++----
charproc.c | 4 ++--
ptyx.h | 5 ++++-
screen.c | 12 ++++++------
util.c | 26 +++++++++++++-------------
5 files changed, 29 insertions, 26 deletions
--------------------------------------------------------------------------------
Index: button.c
--- xterm-original/button.c Sat Jan 6 19:50:22 1996
+++ xterm-patched/button.c Sun Jan 7 16:26:54 1996
@@ -829,7 +829,7 @@
register Char *ch;
for ( i = screen->max_col,
- ch = screen->buf[4 * (row + screen->topline) + 1] + i ;
+ ch = SCRN_BUF_ATTRS(screen, (row + screen->topline)) + i ;
i >= 0 && !(*ch & CHARDRAWN) ;
ch--, i--)
;
@@ -968,7 +968,7 @@
startSCol = 0;
startSRow++;
} else {
- ptr = screen->buf[4*(startSRow+screen->topline)]
+ ptr = SCRN_BUF_CHARS(screen, startSRow+screen->topline)
+ startSCol;
class = charClass[*ptr];
do {
@@ -983,7 +983,7 @@
endSRow++;
} else {
length = LastTextCol(endSRow);
- ptr = screen->buf[4*(endSRow+screen->topline)]
+ ptr = SCRN_BUF_CHARS(screen, endSRow+screen->topline)
+ endSCol;
class = charClass[*ptr];
do {
@@ -1408,7 +1408,7 @@
int *eol;
{
register int i = 0;
- register Char *ch = screen->buf[4 * (row + screen->topline)];
+ register Char *ch = SCRN_BUF_CHARS(screen, row + screen->topline);
Char attr;
register int c;
Index: charproc.c
--- xterm-original/charproc.c Sun Jan 7 13:27:46 1996
+++ xterm-patched/charproc.c Sun Jan 7 16:35:40 1996
@@ -1198,9 +1198,9 @@
if(screen->cursor_state)
HideCursor();
for(row = screen->max_row ; row >= 0 ; row--) {
- bzero(screen->buf[4 * row + 1],
+ bzero(SCRN_BUF_ATTRS(screen, row),
col = screen->max_col + 1);
- for(cp = (unsigned char *)screen->buf[4 * row] ; col > 0 ; col--)
+ for(cp = SCRN_BUF_CHARS(screen, row) ; col > 0 ; col--)
*cp++ = (unsigned char) 'E';
}
ScrnRefresh(screen, 0, 0, screen->max_row + 1,
Index: ptyx.h
--- xterm-original/ptyx.h Sun Jan 7 13:42:17 1996
+++ xterm-patched/ptyx.h Sun Jan 7 16:20:17 1996
@@ -261,7 +261,10 @@
#define COLOR_BD 16
#define COLOR_UL 17
-
+#define SCRN_BUF_CHARS(screen, row) (screen->buf[4 * (row) + 0])
+#define SCRN_BUF_ATTRS(screen, row) (screen->buf[4 * (row) + 1])
+#define SCRN_BUF_FORES(screen, row) (screen->buf[4 * (row) + 2])
+#define SCRN_BUF_BACKS(screen, row) (screen->buf[4 * (row) + 3])
typedef struct {
/* These parameters apply to both windows */
Index: screen.c
--- xterm-original/screen.c Sun Jan 7 13:42:22 1996
+++ xterm-patched/screen.c Sun Jan 7 16:33:06 1996
@@ -388,10 +388,10 @@
if (lastind < 0 || lastind > max)
continue;
- chars = screen->buf [4 * (lastind + topline)];
- attrs = screen->buf [4 * (lastind + topline) + 1];
- fgs = screen->buf [4 * (lastind + topline) + 2];
- bgs = screen->buf [4 * (lastind + topline) + 3];
+ chars = SCRN_BUF_CHARS(screen, lastind + topline);
+ attrs = SCRN_BUF_ATTRS(screen, lastind + topline);
+ fgs = SCRN_BUF_FORES(screen, lastind + topline);
+ bgs = SCRN_BUF_BACKS(screen, lastind + topline);
if (row < screen->startHRow || row > screen->endHRow ||
(row == screen->startHRow && maxcol < screen->startHCol) ||
@@ -724,7 +724,7 @@
length = avail;
if (length <= 0)
return;
- attrs = screen->buf[4 * row + 1] + col;
+ attrs = SCRN_BUF_ATTRS(screen, row) + col;
value &= mask; /* make sure we only change the bits allowed by mask*/
while(length-- > 0) {
*attrs &= ~mask; /* clear the bits */
@@ -755,7 +755,7 @@
if (length <= 0)
return 0;
ret = length;
- attrs = screen->buf[4 * row + 1] + col;
+ attrs = SCRN_BUF_ATTRS(screen, row) + col;
while(length-- > 0) {
*str++ = *attrs++;
}
Index: util.c
--- xterm-original/util.c Sun Jan 7 13:09:38 1996
+++ xterm-patched/util.c Sun Jan 7 16:38:55 1996
@@ -635,16 +635,16 @@
FontHeight(screen));
}
}
- bzero(screen->buf [4 * screen->cur_row] + screen->cur_col,
+ bzero(SCRN_BUF_CHARS(screen, screen->cur_row) + screen->cur_col,
(screen->max_col - screen->cur_col + 1));
- bzero(screen->buf [4 * screen->cur_row + 1] + screen->cur_col,
+ bzero(SCRN_BUF_ATTRS(screen, screen->cur_row) + screen->cur_col,
(screen->max_col - screen->cur_col + 1));
- bzero(screen->buf [4 * screen->cur_row + 2] + screen->cur_col,
+ bzero(SCRN_BUF_FORES(screen, screen->cur_row) + screen->cur_col,
(screen->max_col - screen->cur_col + 1));
- bzero(screen->buf [4 * screen->cur_row + 3] + screen->cur_col,
+ bzero(SCRN_BUF_BACKS(screen, screen->cur_row) + screen->cur_col,
(screen->max_col - screen->cur_col + 1));
/* with the right part cleared, we can't be wrapping */
- screen->buf [4 * screen->cur_row + 1] [0] &= ~LINEWRAPPED;
+ SCRN_BUF_ATTRS(screen, screen->cur_row) [0] &= ~LINEWRAPPED;
}
/*
@@ -673,16 +673,16 @@
}
}
- for ( i=0, cp=screen->buf[4 * screen->cur_row];
+ for ( i=0, cp=SCRN_BUF_CHARS(screen, screen->cur_row);
i < screen->cur_col + 1;
i++, cp++)
*cp = ' ';
- for ( i=0, cp=screen->buf[4 * screen->cur_row + 1];
+ for ( i=0, cp=SCRN_BUF_ATTRS(screen, screen->cur_row);
i < screen->cur_col + 1;
i++, cp++)
*cp = CHARDRAWN;
- bzero (screen->buf [4 * screen->cur_row + 2], (screen->cur_col + 1));
- bzero (screen->buf [4 * screen->cur_row + 3], (screen->cur_col + 1));
+ bzero (SCRN_BUF_FORES(screen, screen->cur_row), (screen->cur_col + 1));
+ bzero (SCRN_BUF_BACKS(screen, screen->cur_row), (screen->cur_col + 1));
}
@@ -707,10 +707,10 @@
Width(screen), FontHeight(screen));
}
}
- bzero (screen->buf [4 * screen->cur_row], (screen->max_col + 1));
- bzero (screen->buf [4 * screen->cur_row + 1], (screen->max_col + 1));
- bzero (screen->buf [4 * screen->cur_row + 2], (screen->max_col + 1));
- bzero (screen->buf [4 * screen->cur_row + 3], (screen->max_col + 1));
+ bzero (SCRN_BUF_CHARS(screen, screen->cur_row), (screen->max_col + 1));
+ bzero (SCRN_BUF_ATTRS(screen, screen->cur_row), (screen->max_col + 1));
+ bzero (SCRN_BUF_FORES(screen, screen->cur_row), (screen->max_col + 1));
+ bzero (SCRN_BUF_BACKS(screen, screen->cur_row), (screen->max_col + 1));
}
void