Re: A few simple questions...
Scott Husen wrote:
<snip>
Do you know of anyway to do a wrap function that wraps the text for
> long sentences but not at whatever letter the side of the screen ends at
> but then goes back to the last Word and wraps it?
>
</snip>
The following code will do it on DOS or Linux, printing a given text string
with word wrapping:
include graphics.e
global procedure wrap_text(sequence theText)
-- For DOS and Linux
-- Wraps text at end of last word in line.
-- Honors newlines in the text, replaces tabs with 5 spaces.
-- Assumes that theText is a valid string
sequence vidconf,pos
integer cols,col,index
vidconf=video_config()
cols=vidconf[VC_COLUMNS]
pos=get_position()
col=pos[2]-1
theText=repeat(' ',col)&theText
while 1 do
index=find('\t',theText)
if index=0 then exit end if
theText=theText[1..index-1]&repeat(' ',5)
&theText[index+1..length(theText)]
end while
while length(theText)>cols do
index=find('\n',theText)
if index>0 and index<=cols then
puts(1,theText[col+1..index])
theText=theText[index+1..length(theText)]
col=0
else
for i=cols to 1 by -1 do
if theText[i]=' ' then
theText[i]='\n'
exit
end if
if i=1 then
end if
end for
end if
end while
if length(theText)>0 then
puts(1,theText)
end if
end procedure
|
Not Categorized, Please Help
|
|