Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NEW set of word wrap patches




 The ones I posted a couple hours ago had a problem in which they
would wrap a line of spaces (caused inventory to be double spaced.)

 This revised set fixes that problem (won't have a line be printed
if it only contains spaces.)

 This set, like the last, are diff -c from the original xio.c file
(server directory).

 Sorry for the error, wasn't expecting lines to be passed ending in
spaces.

 Mark Wedel
master@cats.ucsc.edu

*** xio.c.orig	Thu Mar 11 18:03:20 1993
--- xio.c	Fri Mar 12 01:15:08 1993
***************
*** 1215,1220 ****
--- 1215,1246 ----
      draw_info(pl,cp);
      return;
    }
+   /* Lets do the word wrap for messages - MSW (master@cats.ucsc.edu) */
+   if (strlen(str)>=pl->contr->infochars) {
+ 	int i=pl->contr->infochars-1;
+ 	char buf[VERY_BIG_BUF];
+ 
+ 	fprintf(stderr,"'%s'\n",str);
+ 	/* i=last space (or ')' for armor.  Wrap armor, because
+ 	otherwise, the two sets of ()() can be about half the line */
+ 	while ((str[--i]!=' ') && (str[i]!=')') && (i!=0)) ;
+ 	/* if i==0, string has no space.  Just let it be truncated */
+ 	if (i!=0) {
+ 	    int j;
+ 
+ 	    i++;	/* want to keep the ')'.  This also keeps
+ 			the space, but that really doesn't matter */
+ 	    strncpy(buf, str, i);
+ 	    buf[i]='\0';
+ 	    draw_info(pl, buf);
+ 
+ 	    for (j=i; j<strlen(str); j++)	/* if the wrap portion is */
+ 		if (str[j]!=' ') break;		/* only space, don't wrap it*/
+ 	    if ((((strlen(str)-i)!=1) || (str[i]!='.')) && (j!=strlen(str)))
+ 		draw_info(pl, (str+i));
+ 	    return;
+ 	}
+   }
    strncpy(pl->contr->info[pl->contr->infoline],str,pl->contr->infochars);
    XDrawImageString(pl->contr->gdisp,pl->contr->win_info,
      pl->contr->gc_info,FONTWIDTH,(pl->contr->infoline+1)*FONTHEIGHT,
***************
*** 1284,1289 ****
--- 1310,1319 ----
  
  void clear_win_info(object *op) {
    int i;
+ 
+ 	/* don't clear if in scroll mode MSW (master@cats.ucsc.edu */
+   if((op->type==PLAYER)  &&  (op->contr->scroll)) return;
+ 
    for(i=0;i<op->contr->infolines;i++) {
      (void) memset(op->contr->info[i],' ',op->contr->infochars);
      op->contr->info[i][op->contr->infochars]='\0';

 (END)
d