Changeset 30e0e72 in tol
- Timestamp:
- Mar 25, 2011, 6:56:11 PM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 5a9a0ff
- Parents:
- 2075779
- File:
-
- 1 edited
-
tol/bbasic/txtalgeb.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol/bbasic/txtalgeb.cpp
r2075779 r30e0e72 1978 1978 } 1979 1979 1980 1980 //-------------------------------------------------------------------- 1981 BText BText::Wrap ( 1982 int lineSize, 1983 const BText& wordSep_, 1984 const BText& prefix_) 1985 //-------------------------------------------------------------------- 1986 { 1987 const char* wordSep = wordSep_.String(); 1988 const char* prefix = prefix_.String(); 1989 const char* s = String(); 1990 const char *head = s; 1991 char* w0 = new char[2*length_]; 1992 char* w = w0; 1993 int pos, lastSpace; 1994 1995 pos = lastSpace = 0; 1996 while(head[pos]!=0) { 1997 int isLf = (head[pos]=='\n'); 1998 if (isLf || pos==lineSize) { 1999 if (isLf || lastSpace == 0) { lastSpace = pos; } // just cut it 2000 if (prefix!=NULL) { w+=sprintf(w,"%s", prefix); } 2001 while(*head!=0 && lastSpace-- > 0) { w+=sprintf(w,"%c", *head++); } 2002 w+=sprintf(w,"\n"); 2003 if (isLf) { head++; } // jump the line feed 2004 while (*head!=0 && strchr(wordSep,*head)) { head++; } // clear the leading space 2005 lastSpace = pos = 0; 2006 } else { 2007 if (strchr(wordSep,head[pos])) { lastSpace = pos; } 2008 pos++; 2009 } 2010 } 2011 w+=sprintf(w,"%s\n", head); 2012 w[0]='\0'; 2013 int len = w-w0+1; 2014 BText wrap(w0,len); 2015 delete [] w0; 2016 return(wrap); 2017 }
Note: See TracChangeset
for help on using the changeset viewer.
