[1009] in Zephyr_Bugs
zwgc patches to make c&p EOL handling work better
daemon@ATHENA.MIT.EDU (Marc Horowitz)
Fri Dec 22 20:58:09 2000
From: Marc Horowitz <marc@MIT.EDU>
To: bug-zephyr@mit.edu
cc: rainbow@stacken.kth.se
Date: 22 Dec 2000 20:58:02 -0500
Message-ID: <t53wvcrzyol.fsf@horowitz.ne.mediaone.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
These patches make zwgc handle copy and paste of EOL much more
intelligently. Basically, it acts more like xterm, highligting the
space between the last text of the line and the right edge when a
newline should be copied.
Marc
Index: X_gram.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/zephyr/repository/zephyr/clients/zwgc/X_gram.c,v
retrieving revision 1.21
diff -c -r1.21 X_gram.c
*** X_gram.c 1995/07/07 21:59:16 1.21
--- X_gram.c 1997/01/27 04:13:45
***************
*** 435,442 ****
XChangeGC(dpy,gc,GCFunction,&gcvals);
for (i=0,xb=gram->blocks ; i<gram->numblocks ; i++,xb++) {
! if (XRectInRegion(region,xb->x1,xb->y1,xb->x2-xb->x1,
! xb->y2-xb->y1) != RectangleOut) {
SetFG(gram->bgcolor^xb->fgcolor);
text.chars=gram->text+xb->strindex;
text.nchars=xb->strlen;
--- 435,443 ----
XChangeGC(dpy,gc,GCFunction,&gcvals);
for (i=0,xb=gram->blocks ; i<gram->numblocks ; i++,xb++) {
! if ((xb->strlen > 0) &&
! (XRectInRegion(region,xb->x1,xb->y1,xb->x2-xb->x1,
! xb->y2-xb->y1) != RectangleOut)) {
SetFG(gram->bgcolor^xb->fgcolor);
text.chars=gram->text+xb->strindex;
text.nchars=xb->strlen;
Index: xmark.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/zephyr/repository/zephyr/clients/zwgc/xmark.c,v
retrieving revision 1.8
diff -c -r1.8 xmark.c
*** xmark.c 1995/06/30 21:53:13 1.8
--- xmark.c 1997/01/27 06:10:54
***************
*** 49,55 ****
int x,y;
int which;
{
! int i,xofs,yofs;
XFontStruct *font;
xblock *xb;
unsigned char *s;
--- 49,55 ----
int x,y;
int which;
{
! int i,j,xofs,yofs;
XFontStruct *font;
xblock *xb;
unsigned char *s;
***************
*** 105,130 ****
}
for (yofs=xb->y1;(i<gram->numblocks) && (xb->y1 == yofs);i++,xb++) {
-
if (x <= xb->x2) {
markblock[which]=i;
xofs=xb->x1;
if ((x < xofs) || (y < xb->y1)) {
markchar[which]=0;
RETURN;
}
font=get_fontst_from_fid(xb->fid);
! for (i=0,s=(unsigned char *)((gram->text)+(xb->strindex));
! xofs<x && i<xb->strlen;
! i++,s++) {
! /* if font->per_char is NULL, then we should use min_bounds */
! short usewidth = font->per_char ? font->per_char[*s - font->min_char_or_byte2].width : font->min_bounds.width;
! if (x <= (xofs+=usewidth)) {
! markchar[which]=i;
! markpixel[which]=xofs - xb->x1 - usewidth;
! RETURN;
! }
}
}
}
--- 105,138 ----
}
for (yofs=xb->y1;(i<gram->numblocks) && (xb->y1 == yofs);i++,xb++) {
if (x <= xb->x2) {
markblock[which]=i;
xofs=xb->x1;
+
if ((x < xofs) || (y < xb->y1)) {
markchar[which]=0;
+ markpixel[which]=0;
+ RETURN;
+ }
+
+ if (xb->strlen == -1) {
+ markchar[which]=0;
+ markpixel[which]=0;
RETURN;
}
+
font=get_fontst_from_fid(xb->fid);
! for (j=0,s=(unsigned char *)((gram->text)+(xb->strindex));
! xofs<x && j<xb->strlen;
! j++,s++) {
! /* if font->per_char is NULL, then we should use min_bounds */
! short usewidth = font->per_char ? font->per_char[*s - font->min_char_or_byte2].width : font->min_bounds.width;
! if (x <= (xofs+=usewidth)) {
! markchar[which]=j;
! markpixel[which]=xofs - xb->x1 - usewidth;
! RETURN;
! }
}
}
}
***************
*** 365,385 ****
}
for (i=startblock; i<=endblock; i++) {
- if (last_y != -1 && last_y != markgram->blocks[i].y)
- text_so_far = string_Concat2(text_so_far, "\n");
index = markgram->blocks[i].strindex;
len = markgram->blocks[i].strlen;
! if (startblock == endblock)
! temp = string_CreateFromData(text+index+startchar,
! endchar-startchar);
! else if (i==startblock)
! temp = string_CreateFromData(text+index+startchar,len-startchar);
! else if (i==endblock)
! temp = string_CreateFromData(text+index,endchar);
! else
! temp = string_CreateFromData(text+index,len);
! text_so_far = string_Concat2(text_so_far, temp);
! free(temp);
last_y = markgram->blocks[i].y;
}
}
--- 373,396 ----
}
for (i=startblock; i<=endblock; i++) {
index = markgram->blocks[i].strindex;
len = markgram->blocks[i].strlen;
! if ((len == -1) && (i != endblock)) {
! text_so_far = string_Concat2(text_so_far, "\n");
! } else {
! if (startblock == endblock)
! temp = string_CreateFromData(text+index+startchar,
! endchar-startchar);
! else if (i==startblock)
! temp = string_CreateFromData(text+index+startchar,
! len-startchar);
! else if (i==endblock)
! temp = string_CreateFromData(text+index, endchar);
! else
! temp = string_CreateFromData(text+index, len);
! text_so_far = string_Concat2(text_so_far, temp);
! free(temp);
! }
last_y = markgram->blocks[i].y;
}
}
Index: xshow.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/zephyr/repository/zephyr/clients/zwgc/xshow.c,v
retrieving revision 1.14
diff -c -r1.14 xshow.c
*** xshow.c 1995/07/07 22:00:50 1.14
--- xshow.c 1997/01/27 05:36:25
***************
*** 134,140 ****
x_gram *gram;
int strindex = 0;
! int line, block=0;
int maxwidth=0, chars=0, maxascent, maxdescent;
int ssize, lsize,csize, rsize, width;
int i, ascent, descent;
--- 134,140 ----
x_gram *gram;
int strindex = 0;
! int line, block;
int maxwidth=0, chars=0, maxascent, maxdescent;
int ssize, lsize,csize, rsize, width;
int i, ascent, descent;
***************
*** 156,162 ****
/* add up sizes for each block, get max ascent and descent */
! for (i=0; i<lines[line].numblock; i++,block++) {
chars += auxblocks[block].len;
ssize = XTextWidth(auxblocks[block].font, auxblocks[block].str,
auxblocks[block].len);
--- 156,163 ----
/* add up sizes for each block, get max ascent and descent */
! for (i=0, block=lines[line].startblock; i<lines[line].numblock;
! i++,block++) {
chars += auxblocks[block].len;
ssize = XTextWidth(auxblocks[block].font, auxblocks[block].str,
auxblocks[block].len);
***************
*** 164,182 ****
ascent = auxblocks[block].font->ascent;
descent = auxblocks[block].font->descent;
if (ascent>maxascent)
! maxascent = ascent;
if (descent>maxdescent)
! maxdescent = descent;
switch (auxblocks[block].align) {
! case LEFTALIGN:
lsize += ssize;
break;
!
! case CENTERALIGN:
csize += ssize;
break;
!
! case RIGHTALIGN:
rsize += ssize;
break;
}
--- 165,183 ----
ascent = auxblocks[block].font->ascent;
descent = auxblocks[block].font->descent;
if (ascent>maxascent)
! maxascent = ascent;
if (descent>maxdescent)
! maxdescent = descent;
switch (auxblocks[block].align) {
! case LEFTALIGN:
lsize += ssize;
break;
!
! case CENTERALIGN:
csize += ssize;
break;
!
! case RIGHTALIGN:
rsize += ssize;
break;
}
***************
*** 246,252 ****
/* set x1,y1,x2,y2 of each block also. */
gram->text = (char *)malloc(chars);
- block = 0;
for (line=0; line<numlines; line++) {
lofs = internal_border_width;
--- 247,252 ----
***************
*** 257,263 ****
yend = yofs+lines[line].descent+1; /* +1 because lines look scrunched
without it. */
! for (i=0; i<lines[line].numblock; i++,block++) {
blocks[block].fid = auxblocks[block].font->fid;
switch (auxblocks[block].align) {
case LEFTALIGN:
--- 257,264 ----
yend = yofs+lines[line].descent+1; /* +1 because lines look scrunched
without it. */
! for (i=0, block=lines[line].startblock; i<lines[line].numblock;
! i++,block++) {
blocks[block].fid = auxblocks[block].font->fid;
switch (auxblocks[block].align) {
case LEFTALIGN:
***************
*** 291,298 ****
strindex += blocks[block].strlen;
}
! yofs = yend;
}
if ((geometry = var_get_variable("X_geometry")),(geometry[0]=='\0'))
--- 292,311 ----
strindex += blocks[block].strlen;
}
! blocks[block].fid = block?blocks[block-1].fid:auxblocks[0].font->fid;
! blocks[block].x = maxwidth + internal_border_width;
! blocks[block].x1 = (lines[line].rsize?rofs:
! (lines[line].csize?cofs:
! lofs));
! blocks[block].x2 = maxwidth + internal_border_width*2;
! blocks[block].y = yofs;
! blocks[block].y1 = ystart;
! blocks[block].y2 = yend;
! blocks[block].strindex = 0;
! blocks[block].strlen = -1; /* magic value indicates newline */
! block++;
+ yofs = yend;
}
if ((geometry = var_get_variable("X_geometry")),(geometry[0]=='\0'))
***************
*** 374,381 ****
lines = (xlinedesc *)malloc(sizeof(xlinedesc)*(numnl+1));
! blocks = (xblock *)malloc(sizeof(xblock)*numstr);
! auxblocks = (xauxblock *)malloc(sizeof(xauxblock)*numstr);
curmode.bold = 0;
curmode.italic = 0;
--- 387,394 ----
lines = (xlinedesc *)malloc(sizeof(xlinedesc)*(numnl+1));
! blocks = (xblock *)malloc(sizeof(xblock)*(numstr+numnl+1));
! auxblocks = (xauxblock *)malloc(sizeof(xauxblock)*(numstr+numnl+1));
curmode.bold = 0;
curmode.italic = 0;
***************
*** 504,515 ****
break;
case DT_NL:
lines[line].startblock = linestart;
! lines[line].numblock = nextblock-linestart;
font = MODE_TO_FONT(dpy,style,&curmode);
lines[line].ascent = font->ascent;
lines[line].descent = font->descent;
line++;
linestart = nextblock;
break;
}
--- 517,538 ----
break;
case DT_NL:
+ auxblocks[nextblock].len = -1;
+ if (curmode.expcolor)
+ blocks[nextblock].fgcolor = curmode.color;
+ else
+ blocks[nextblock].fgcolor =
+ x_string_to_color(mode_to_colorname(dpy,style,&curmode),
+ default_fgcolor);
+ nextblock++;
+
lines[line].startblock = linestart;
! lines[line].numblock = (nextblock-linestart)-1;
font = MODE_TO_FONT(dpy,style,&curmode);
lines[line].ascent = font->ascent;
lines[line].descent = font->descent;
line++;
+
linestart = nextblock;
break;
}
***************
*** 518,525 ****
/* case DT_EOF: will drop through to here. */
if (linestart != nextblock) {
lines[line].startblock = linestart;
! lines[line].numblock = nextblock-linestart;
font = MODE_TO_FONT(dpy,style,&curmode);
lines[line].ascent = 0;
lines[line].descent = 0;
--- 541,557 ----
/* case DT_EOF: will drop through to here. */
if (linestart != nextblock) {
+ auxblocks[nextblock].len = -1;
+ if (curmode.expcolor)
+ blocks[nextblock].fgcolor = curmode.color;
+ else
+ blocks[nextblock].fgcolor =
+ x_string_to_color(mode_to_colorname(dpy,style,&curmode),
+ default_fgcolor);
+ nextblock++;
+
lines[line].startblock = linestart;
! lines[line].numblock = (nextblock-linestart)-1;
font = MODE_TO_FONT(dpy,style,&curmode);
lines[line].ascent = 0;
lines[line].descent = 0;
cvs diff: Diffing clients/zwrite
cvs diff: Diffing doc
cvs diff: Diffing doc/progman
cvs diff: Diffing h
cvs diff: Diffing lib
cvs diff: Diffing lib/dyn
cvs diff: Diffing lib/et
cvs diff: Diffing lib/ss
cvs diff: Diffing lib/zephyr