home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
ronheb.zip
/
RONMEMO.PRG
< prev
Wrap
Text File
|
1988-03-22
|
14KB
|
511 lines
* -- ÜîüéàÄ ,ìëïæÄ 'æÄ ëÉö îÆ (ÜàïàÿÇ ÜàÇÿÖÿÖ) àÄÄ-ëÉÜÖÄ ÜïëÿÆ ÜëûùÉàö
* -- ÜÇ ìëÿêÄÿöï ÜîüùÄ .äéûä/äïëÿÆî Åàîç ÜçÜàö .ÜàÿàÖ 66-î ÜëÜàÿëÿÖ
* -- ÜâÆàëÄ .äïëÿÆ-Üëéàî äëûùëâÉëÇ,Åàîçä ìàùëÄ,äéûä/äïëÿÆî äÉÜÖÄä ìÖ
* -- äÿàûü ùåçàÄ äÉÜÖÄä .ìëïàÿÇ ìëëÿüÆ ÜàâÖ ÿàüÆ MEMOEDIT() ÜÇ ôëîçäî
* -- .INVERTED
* -- edit_var=hebedit('edit_var',ltrow,ltcol,rtrow,rtcol,update) äÇëÿùä
function hebedit
parameters txtname,ltrow,ltcol,rtrow,rtcol,updt
txt=&txtname
width=rtcol-ltcol-4
rows=rtrow-ltrow-1
if (width<1).or.(width>75).or.(rows<1).or.(rows>66)
return(txt)
endif
rhcolor=setcolor()
rhcolour()
declare edbak[rows]
if updt
@ 24,0 say " äÇëûë<-ESC │ ìàëæ<-^END │ äÿàÖ îêü/ôæàä<═╝/BS│ ÿàçÇî èæÄ<-PgUp│ äÄëâù èæÄ<-PgDn"
else
@ 24,0 say " äÇëûë<-ESC ÿàçÇî èæÄ<-PgUp äÄëâù èæÄ<-PgDn "
endif
setcolor(rhcolor)
@ ltrow,ltcol clear to rtrow,rtcol
@ ltrow,ltcol to rtrow,rtcol
rhmemoact=0
rhstrt=0
rowstrt=1
rhpgsize=66
do while .t.
subtxt=rhhmed(substr(txt,rhstrt*width+1,rows*width))
do case
case rhmemoact=3
if updt
txt=left(txt,rhstrt*width)+subtxt+;
substr(txt,(rhstrt+rows)*width+1,max(len(txt)-(rhstrt+rows)*width,0))
endif
rhstrt=iif((rhstrt+rows)*width<len(txt),rhstrt+rows,len(txt)/width)
rowstrt=1
case rhmemoact=18
if updt
txt=left(txt,rhstrt*width)+subtxt+;
substr(txt,(rhstrt+rows)*width+1,max(len(txt)-(rhstrt+rows)*width,0))
endif
rhstrt=iif(rhstrt>=rows,rhstrt-rows,0)
rowstrt=1
case rhmemoact=23
if updt
txt=left(txt,rhstrt*width)+subtxt+;
substr(txt,(rhstrt+rows)*width+1,max(len(txt)-(rhstrt+rows)*width,0))
endif
return(txt)
rowstrt=1
case rhmemoact=27
txt=&txtname
return(txt)
otherwise
if updt
txt=left(txt,rhstrt*width)+subtxt+;
substr(txt,(rhstrt+rows)*width+1,max(len(txt)-(rhstrt+rows)*width,0))
endif
endcase
enddo
function rhhmed
parameters rhremain
private i,y,z,rhsubst,carrystr
y=0
* fill arrays and take care of word-wrapping
for i=1 to rows
rhsubst=substr(rhremain,1,width)
z=len(rhsubst)
y=y+z
rhremain=substr(rhremain,z+1,len(rhremain)-z)
edbak[i]=space(width-z)+inv(rhsubst)
next
carrystr=""
do while .t.
@ ltrow+1,ltcol+1 clear to rtrow-1,rtcol-1
for i=1 to rows
rhcolour()
@ ltrow+i,ltcol+4 say edbak[i]
setcolor(rhcolor)
@ ltrow+i,ltcol+1 say str(iif((rhstrt+i)!=rhpgsize,;
(rhstrt+i)%rhpgsize,rhpgsize),2)+"<"
next
if updt
rhcolour()
h=1
v=rowstrt
@ ltrow+v,rtcol-1 say ""
ins=.f.
rhact=.f.
tmp=edbak[v]
carrystr=""
do while .t.
if rhact
for i=1 to rows
@ ltrow+i,ltcol+4 say edbak[i]
next
@ ltrow+v,rtcol-h say ""
rhact=.f.
endif
inkey(0)
l=lastkey()
do case
case l>31
if h>width
if v<rows
edbak[v]=tmp
* check word-wrapping
atspace=at(" ",tmp)
if (substr(tmp,1,1)>" ").and.(atspace>0)
carrystr=" "+htrans(l)+substr(tmp,1,atspace-1)
h=atspace+1
i=v
do while !empty(carrystr)
edbak[i]=stuff(edbak[i],1,atspace-1,space(atspace-1))
i=i+1
if i<=rows
edbak[i]=edbak[i]+carrystr
carrystr=""
atspace=at(" ",edbak[i])
if atspace>0
carrystr=" "+substr(edbak[i],1,atspace-1)
endif
edbak[i]=substr(edbak[i],len(edbak[i])-width+1,width)
else
rhremain=inv(carrystr)+rhremain
carrystr=""
exit
endif
enddo
v=v+1
tmp=edbak[v]
rhact=.t.
loop
else
v=v+1
tmp=edbak[v]
ins=.f.
h=1
endif
else
h=width
?? chr(7)
loop
endif
endif
tmprvar=htrans(l)
if .not.ins
tmp=substr(tmp,1,width-h)+tmprvar+substr(tmp,width-h+2,h-1)
* htrans will transform an inkey() value into
* corresponding hebrew set charecter by substr a charecter-list string.
* if .not. ins then say tmp[i] and cursor only. else say by arraysay
* after ains with pos=i+1
@ ltrow+v,rtcol-h say tmprvar
h=h+1
@ ltrow+v,rtcol-h say ""
loop
else
* check word-wrapping
atspace=at(" ",tmp)
if (substr(tmp,1,1)>" ").and.(atspace>0)
carrystr=" "+substr(tmp,1,atspace-1)
edbak[v]=tmp
i=v
do while !empty(carrystr)
edbak[i]=stuff(edbak[i],1,atspace-1,space(atspace-1))
i=i+1
if i<=rows
edbak[i]=edbak[i]+carrystr
carrystr=""
atspace=at(" ",edbak[i])
if atspace>0
carrystr=" "+substr(edbak[i],1,atspace-1)
endif
edbak[i]=substr(edbak[i],len(edbak[i])-width+1,width)
else
rhremain=inv(carrystr)+rhremain
carrystr=""
exit
endif
enddo
rhact=.t.
tmp=edbak[v]
tmp=substr(tmp,2,width-h)+tmprvar+substr(tmp,width-h+2,h-1)
h=h+1
loop
else
tmp=substr(tmp,2,width-h)+tmprvar+substr(tmp,width-h+2,h-1)
@ ltrow+v,rtcol-width say substr(tmp,1,width-h+1)
h=h+1
@ ltrow+v,rtcol-h say ""
loop
endif
endif
case (h=1).and.(l=8)
adel(edbak,v)
rowstrt=v
rhmemoact=8
result=""
for i=1 to rows-1
result=result+inv(edbak[i])
next
result=result+rhremain
setcolor(rhcolor)
return(result)
case (ins).and.(l=13)
rhremain=inv(edbak[rows])+rhremain
ains(edbak,v)
edbak[v]=space(width)
tmp=space(width)
rhact=.t.
loop
case l=4 && rt arrow
if h>1
h=h-1
else
if v>1
edbak[v]=tmp
v=v-1
tmp=edbak[v]
ins=.f.
h=width
else
?? chr(7)
h=1
endif
endif
* say cursor only
@ ltrow+v,rtcol-h say ""
loop
case l=19 && lt arrow
if h<width
h=h+1
else
if v<rows
edbak[v]=tmp
v=v+1
tmp=edbak[v]
ins=.f.
h=1
else
h=width
?? chr(7)
endif
endif
* say cursor only
@ ltrow+v,rtcol-h say ""
loop
case l=13
if v<rows
edbak[v]=tmp
v=v+1
tmp=edbak[v]
ins=.f.
endif
h=1
@ ltrow+v,rtcol-h say ""
loop
case l=22 && insert
ins=iif(ins,.f.,.t.)
loop
case l=7 && del
tmp=" "+substr(tmp,1,width-h)+substr(tmp,width-h+2,h-1)
@ ltrow+v,rtcol-width say tmp
@ ltrow+v,rtcol-h say ""
loop
case l=5 && up arrow
if v>1
edbak[v]=tmp
v=v-1
@ ltrow+v,rtcol-h say ""
tmp=edbak[v]
ins=.f.
endif
loop
case l=24 && down arrow
if v<rows
edbak[v]=tmp
v=v+1
tmp=edbak[v]
@ ltrow+v,rtcol-h say ""
ins=.f.
endif
loop
case l=8 && backspace
h=h-1
tmp=substr(tmp,1,width-h)+" "+substr(tmp,width-h+2,h-1)
@ ltrow+v,rtcol-width say tmp
@ ltrow+v,rtcol-h say ""
loop
case l=1
h=1
@ ltrow+v,rtcol-h say ""
loop
case l=2
loop
case l=26
loop
case l=29
loop
case l=30
loop
case l=31
loop
case l=27
rhmemoact=27
setcolor(rhcolor)
return(" ")
case l=3 && pgdn
edbak[v]=tmp
rhmemoact=3
return(rhedrslt())
case l=18 && pgup
edbak[v]=tmp
rhmemoact=18
return(rhedrslt())
case l=23
edbak[v]=tmp
rhmemoact=23
return(rhedrslt())
otherwise
* check for pre-defined hot-keys
if !(rhsk[l+40]=="")
dorhsk=rhsk[l+40]
setcolor(rhcolor)
do &dorhsk with prg,0,txtname
rhcolor=setcolor()
rhcolour()
@ ltrow+v,rtcol-h say ""
ins=.f.
loop
endif
endcase
enddo
else
inkey(0)
do case
case lastkey()=3
rhmemoact=3
return(" ")
case lastkey()=18
rhmemoact=18
return(" ")
case lastkey()=27
rhmemoact=27
return(" ")
endcase
endif
enddo
function rhedrslt
private i,y
i=rows
if empty(rhremain)
do while i>0
if !empty(edbak[i])
exit
endif
i=i-1
enddo
endif
for y=i to 1 step -1
rhremain=inv(edbak[y])+rhremain
next
setcolor(rhcolor)
return(rhremain)
* -- (âàÄÆ îâàé) ÜàÿàÖ 66-î ÜëÜàÿëÿÖ ÜîüéàÄ .ìëïàÿÇ ìëëÿüÆ ÜàâÖî äæöâä ÜëûùÉàö
* -- hebprn(äæöâäî äâÖä ìÖ,ìëëîÇÄÖ ìëëîàÖ,ìëëÉÄë ìëëîàÖ) :äÇëÿùä Üÿàû
function hebprn
parameters txt,ltmargin,rtmargin
declare edarray[67]
width=80-rtmargin-ltmargin
if width>75
return(.f.)
endif
rows=iif((len(txt)/width)>int(len(txt)/width),int(len(txt)/width)+1,;
len(txt)/width)
afill(edarray,space(width))
y=1
for i=1 to rows
edarray[i]=edarray[i]+inv(substr(txt,y,width))
edarray[i]=substr(edarray[i],len(edarray[i])-width+1,width)
y=y+width
next
for i=1 to rows
@ prow(),ltmargin say edarray[i]
@ prow()+1,0 say ""
next
eject
return(.t.)
function hebmac
* -- ëÿüÆ àÄÄ äâÖî àÿùÄ .ìëëÿüÆ àÄÄ ÜàâÖü 'àÿùÄ ÜçëÜöî ÜÇå äëûùÉàö
* -- ìëÄëÇÜÄ ìëçààÿ ÿÇÖàäÖ äçëÉÄ äçëÜöä .îëéÿ Åààïü { } Åëü îÆ ÅëàûÄ
* -- .ÜàÿàÖü
parameters txt
z=1
i=0
y=0
head=""
tail=txt
do while len(tail)>0
i=at("}",tail)
y=at("{",tail)
if (i=0).or.(y=0)
head=head+tail
tail=""
exit
endif
if y<i
head=head+substr(tail,1,i)
tail=substr(tail,i+1,len(tail)-i)
loop
endif
mac=inv(substr(tail,i+1,2))
xpand=y-i+1
spand=space(xpand)
do case
case type('&mac')='C'
xval=inv(right(ltrim(trim(&mac)),min(xpand,len(ltrim(trim(&mac))))))
case type('&mac')='N'
xval=inv(left(ltrim(str(&mac)),xpand))
case type('&mac')='D'
xval=inv(left(dtoc(&mac),xpand))
endcase
tail=stuff(tail,i,xpand,stuff(spand,1,len(xval),xval))
head=head+substr(tail,1,i+xpand-1)
tail=substr(tail,i+xpand,len(tail)-i-xpand+1)
enddo
txt=head
return(txt)