home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 April
/
PCWorld_2000-04_cd.bin
/
Software
/
TemaCD
/
winedit
/
ctrlines.wb_
< prev
next >
Wrap
Text File
|
1999-10-04
|
4KB
|
50 lines
_Centre ; v1.00 18/09/1999
lmax=106 ; max screen width
if wgetselstate() then ; anything selected
xxcurl2=wgetlineno() ; get end of selection line number
wcut() ; yes, copy it to clipboard
xxcurl1=wgetlineno() ; get start of selection line number
else ;
xxcurl1=1 ; line # 1 for all
wSelectAll() ; no, get the lot
xxcurl2=wgetlineno() ; get end of selection line number
wcut() ; now
endif ;
afiles=2000000 ; way too much, but...
rbuf=binaryalloc(afiles) ; buf for current file
nbuf=binaryalloc(afiles+1000000) ; buf for modified lines
binaryclipget(rBuf, 1) ; and stick it in the buffer
ls=0 ; starting point for unmodified lines
Brk = binaryeodget(rBuf) ; max buffer
while ls < Brk ; go through input buffer
rc=0 ; no @crlf required
le = binaryindexex(rbuf,ls,@crlf,@fwdscan,0) ; find end of line
if le < 0 then le = brk ; end of buffer; last line
else rc=1 ; @crlf required
ll=le-ls ; ll is length of current line
dataline=binarypeekstr(rbuf,ls,ll) ; process i/p record
ls=ls+ll ; add length of old data
gosub centre ; centre subroutine
if rc then binarypokestr(nbuf,binaryeodget(nbuf),strcat(dataline,@crlf)) ; add to new buffer with @crlf
else binarypokestr(nbuf,binaryeodget(nbuf),dataline) ; add to new buffer data only
if rc then ls=ls+2 ; minimum increase in rbuf size
endwhile ;
binaryeodset(nbuf,binaryeodget(nbuf)) ; set length of restore
binaryclipput(nBuf, 1) ; text format
wpaste() ; stick back in edit file
wgotoline(xxcurl1) ; point back at original location
binaryfree(nbuf) ; free output buffer
binaryfree(rbuf) ; free input buffer
mouseclick(@lclick,0) ; regain focus
drop(lmax,xxcurl1,xxcurl2,afiles,brk,nbuf) ; drop 'em
drop(rbuf,ls,le,ll,dataline,rc,a,dl) ; drop 'em
exit ;
:centre ;
dataline=strtrim(dataline) ; get bare data
dl=strlen(dataline) ; and its length
a=lmax-dl ; how about a fit
if a<2 then return ; too fat, display all
dataline=strcat(strfill(" ",a/2),dataline) ; that'll do nicely
return ;