Home News Browse Search Reviews Interviews Webwatch Top 40
Poll Tips Glossary Codebase Links Lists Help Log in

 Code sample
word-wrapping editor ver. 3.26
Submitted by ianchapple on 11:25:45 20021 8th January 2002 (2876 hits)
OPL16 : Miscellaneous
Level: Advanced
This code is a simple, word-wrapping text editor, allowing a maximum of 255 characters to be entered. It offers the possibility to insert symbols or letters with accents via a dialog box, allows text to be marked for deletion and/or copying & pasting, and has a search & replace facility.

It can be called from within a program as follows:

a$=editor$:(text$,winw%,nrlines%,winx%,winy%,pos%,ov%,lines%,style%,file$)

where:
text$ - initial text to be edited
winw% - editor window width (in pixels)
nrlines% - number of lines of text (1-9)
winx% - x coordinate of top left corner of editor window
winy% - y coordinate of top left corner of editor window
pos% - 0=position cursor at the beginning of the text, 1=position it at the end of the text
ov% - 0=insert, 1=overwrite
lines% - 0=lines off, 1=lines on
style% - font style (0=normal, 1=bold, 2=underlined, 32=italic)
file$ - name of file in m:\opd where text is to be saved (must be a valid filename with no extension).

List of keystrokes:
Psion C Copy
Psion I paste
Psion L mark the current Line
Psion R search and Replace
Shift Psion C insert special Character
Psion O select insert or Overwrite mode
Psion W Word count
Psion V conVert case
Home/End go to beginning/end of line
Psion Up/Down Page Up/Page Down
Ctrl Left/Right jump to previous/next word
Shift Left/Right mark text
Shift Ctrl Left/Right mark previous/next word
Shift Psion Left/Right mark to beginning/end of line
Tab insert 10 spaces
rem editor.opl
rem version 3.15

PROC editor$:(text$,winw%,nrlines%,winx%,winy%,pos%,o%,lines%,style%,file$)
	global edit$(10,255),b$(255),k$(255),tab$(10),edver$(20)
	global eds$(20),edr$(20),txt$(255),edch$(8,16),edclip$(255)
	global win1%,win2%,kb%,w%,b%,y%,x%,k%,c%,l%,flag%,dl%,step%
	global mk%,sb%,eb%,w1%,w2%,chng%,cs%,ov%,spx%,spy%,nl%,m%
	edver$="ver. 3.15"

	rem text$=initial text to be edited
	rem winw%=editor window width
	rem nrlines%=number of lines of text (1-9)
	rem winx%=x coordinate of top left corner of editor window
	rem winy%=y coordinate of top left corner of editor window
	rem pos%: 0=position cursor at beginning of text, 1=position at end
	rem o%: 0=insert, 1=overwrite
	rem lines%: 0=lines off, 1=lines on
	rem style%=font style
	rem file$=name of file in m:\opd where text is to be saved
	rem
	rem ENTER save text in m:\opd\'file$'.txt
	rem ESC quit without saving
	rem

	nl%=nrlines%
	if winw%<40 or nl%<1 or nl%>9 or winx%<0 or winx%+winw%>480 or winy%<0 or winy%+16*nl%+2>160 or file$="" or len(file$)>8
		return ""
	endif

	win1%=gcreate(winx%,winy%,winw%,16*nl%+5,0,1)
	win2%=gcreate(100,20,252,136,0,1)
	guse win1%
	gstyle style%
	gtmode 2
	if lines%=1
		edlines:(winw%)
	endif
	edit$(1)=text$
	ov%=o%
	if ov%>1 or ov%<0
		ov%=0
	endif
	w%=gwidth-5
	step%=w%/3
	edwrap:(1)
	y%=1
	x%=0
	b%=0
	if edit$(1)<>"" and pos%=1
		edPgDn:
		edend:
	endif
	gat x%,16*y%
	cursor win1%,14,2+4*ov%,15
	chng%=0
	mk%=0
	sb%=0
	eb%=0
	tab$="          "
	edclip$=""

	rem create special character window
	edch$(1)="£°±"+chr$(28)+chr$(4)+chr$(5)+chr$(6)+chr$(11)+chr$(12)+chr$(29)+"¿"+chr$(25)+chr$(24)+chr$(27)+chr$(26)
	edch$(2)="«»ÿ·µƒ¢©®¼½¾§÷¤"
	edch$(3)="|áÁàÀäÄâÂåÅæÆçÇ"
	edch$(4)="èÈéÉêÊë˃íÍìÌïÏ"
	edch$(5)="îÎñÑöÖòÒóÓôÔõÕø"
	edch$(6)="ØþÞßüÜûÛùÙúÚÿýÝ"
	guse win2%
	ggmode 2
	gborder 1
	spy%=1
	do
		spx%=1
		do
			gat 16*spx%-8,16*spy%+2
			gprint mid$(edch$(spy%),spx%,1)
			spx%=spx%+1
		until spx%=16
		spy%=spy%+1
	until spy%=7
	gat 90,110
	gbutton "Esc",1,35,20,1
	gat 130,110
	gbutton "OK",1,30,20,1
	rem end of special character window creation

	spx%=1
	spy%=1
	guse win1%
	gvisible on
	do
		k$=""
		kb%=get
		k%=kmod
		if k%>15
			k%=k%-16
		endif
		k$=chr$(kb%)
		b$=edit$(y%)
		w1%=gtwidth(left$(b$,sb%))
		w2%=gtwidth(left$(b$,eb%))
		if kb%<127 and kb%>31
			edinsert:
		elseif kb%=8
			if mk%=0
				edbkspc:
			else
				eddelmrk:(1)
			endif
		elseif kb%=9
			k$=tab$
			edinsert:
		elseif kb%=127
			if mk%=0
				eddelete:
			else
				eddelmrk:(0)
			endif
		elseif kb%=611 and k%=10
			edspcchr:
			if k$<>""
				edinsert:
			endif
		elseif kb%=611 and k%=8
			edcopy:
		elseif kb%=617
			edpaste:
		elseif kb%=623
			if ov%=0
				ov%=1
			else
				ov%=0
			endif
			cursor win1%,14,2+4*ov%,15
		elseif kb%=290
			edmenu:
		elseif kb%=291 or kb%=616
			edhelp:
		elseif kb%=631
			edwrdcnt:
		elseif kb%=630
			edcase:
		elseif kb%=258 and k%=0
			if mk%>0
				b%=eb%
				edclrmrk:
			else
				edright:
			endif
		elseif kb%=258 and k%=6
			edwrdmrk:
			mk%=1
		elseif kb%=258 and k%=4
			edrtwrd:
		elseif kb%=258 and k%=2
			edshrt:
		elseif kb%=259 and k%=0
			if mk%>0
				b%=sb%
				edclrmrk:
			else
				edleft:
			endif
		elseif kb%=259 and k%=4
			edlftwrd:
		elseif kb%=259 and k%=6
				edwrdmrk:
				mk%=2
		elseif kb%=259 and k%=2
			edshlft:
		elseif kb%=256
			edup:
		elseif kb%=257
			eddown:
		elseif kb%=263 and k%=8
			edend:
		elseif kb%=260 and k%=8
			edPgUp:
		elseif kb%=260 and k%=12
			edPgUp:
			edhome:
		elseif kb%=261 and k%=8
			edPgDn:
		elseif kb%=261 and k%=12
			edPgDn:
			edend:
		elseif kb%=620
			edmrkln:
		elseif kb%=263 and k%=10
			edmrkend:
		elseif kb%=262 and k%=8
			edhome:
		elseif kb%=262 and k%=10
			edmrkhm:
		elseif kb%=626
			edsrepl:
		elseif kb%=27
			if mk%>0
				edclrmrk:
			endif
			if chng%=1
				dinit "Discard changes?"
				dbuttons "No",%n,"Yes",%y
				dl%=dialog
				if dl%=%y
					goto nosave::
				endif
			else
				goto nosave::
			endif
		endif
	until kb%=13
	edsave:(file$)
	gclose win1%
	gclose win2%
	return edit$(1)+edit$(2)+edit$(3)+edit$(4)+edit$(5)+edit$(6)+edit$(7)+edit$(8)+edit$(9)
	nosave::
	if exist("m:\opd\"+file$+".txt")
		delete "m:\opd\"+file$+".txt"
	endif
	gclose win1%
	gclose win2%
	return text$
ENDP

PROC edlines:(winw%)
	l%=1
	ggrey 1
	do
		gat 0,16*l%+2
		glineto winw%,16*l%+2
		l%=l%+1
	until l%>nl%
	ggrey 0
ENDP

PROC edmenu:
	minit
	mcard "Edit","Copy",%c,"Paste",%i,"Mark Line",%l,"Search & Replace",%r
	mcard "Insert","Special Character",%C
	mcard "Special","Word Count",%w,"Convert Case",%v,"About Editor",%a,"Help",%h
	m%=menu
	if m%=%c
		edcopy:
	elseif m%=%i
		edpaste:
	elseif m%=%l
		edmrkln:
	elseif m%=%r
		edsrepl:
	elseif m%=%C
		edspcchr:
		if k$<>""
			edinsert:
		endif
	elseif m%=%w
		edwrdcnt:
	elseif m%=%v
		edcase:
	elseif m%=%a
		edabout:
	elseif m%=%h
		edhelp:
	endif
ENDP

PROC eddown:
	if mk%>0
		edclrmrk:
	endif
	if y%<nl% and edit$(y%+1)<>""
		y%=y%+1
		if b%>len(edit$(y%))
			b%=len(edit$(y%))
		endif
		x%=gtwidth(left$(edit$(y%),b%))
		gat x%,16*y%
	endif
ENDP

PROC edup:
	if mk%>0
		edclrmrk:
	endif
	if y%>1
		y%=y%-1
		if b%>len(edit$(y%))
			b%=len(edit$(y%))
		endif
		x%=gtwidth(left$(edit$(y%),b%))
		gat x%,16*y%
	endif
ENDP

PROC edhome:
	if mk%>0
		edclrmrk:
	endif
	b%=0
	x%=0
	gat x%,16*y%
ENDP

PROC edend:
	if mk%>0
		edclrmrk:
	endif
	b%=len(edit$(y%))
	x%=gtwidth(edit$(y%))
	gat x%,16*y%
ENDP

PROC edPgUp:
	if mk%>0
		edclrmrk:
	endif
	y%=1
	if b%>len(edit$(1))
		b%=len(edit$(1))
	endif
	x%=gtwidth(left$(edit$(1),b%))
	gat x%,16*y%
ENDP

PROC edPgDn:
	if mk%>0
		edclrmrk:
	endif
	if y%=nl% and edit$(y%)<>""
		return
	endif
	y%=1
	do
		y%=y%+1
	until y%=nl% or edit$(y%)=""
	if edit$(y%)=""
		y%=y%-1
	endif
	if b%>len(edit$(y%))
		b%=len(edit$(y%))
	endif
	x%=gtwidth(left$(edit$(y%),b%))
	gat x%,16*y%
ENDP

PROC eddispl:(a%)
	local loop%
	loop%=a%
	cursor off
	do
		gat 0,16*loop%
		gprintb edit$(loop%),w%
		loop%=loop%+1
	until loop%>nl%
	cursor win1%,14,2+4*ov%,15
ENDP

PROC edright:
	if b%<len(b$)
		b%=b%+1
		x%=gtwidth(left$(b$,b%))
		gat x%,16*y%
	elseif y%<nl% and edit$(y%+1)<>""
		y%=y%+1
		b%=0
		x%=0
	endif
	gat x%,16*y%
ENDP

PROC edleft:
	if b%>0
		b%=b%-1
		x%=gtwidth(left$(b$,b%))
		gat x%,16*y%
	elseif y%>1
		y%=y%-1
		x%=gtwidth(edit$(y%))
		b%=len(edit$(y%))
		gat x%,16*y%
	endif
ENDP

PROC edinsert:
	local ll%
	ll%=len(edit$(1))+len(edit$(2))+len(edit$(3))+len(edit$(4))+len(edit$(5))+len(edit$(6))+len(edit$(7))+len(edit$(8))+len(edit$(9))
	if (ov%=0 and mk%=0 and ll%+len(k$)>255) or (ov%=1 and ll%+len(k$)>255) or (mk%>0 and ll%-eb%+sb%+len(k$)>255)
		return
	endif
	if y%=nl%
		if mk%=0 and gtwidth(b$)+gtwidth(k$)>=w%
			return
		endif
		if mk%>0
			if gtwidth(b$)-gtwidth(mid$(b$,sb%,eb%-sb%+1))+gtwidth(k$)>=w%
				return
			endif
		endif
	endif
	if mk%>0
		if sb%=0 and eb%=len(b$)
			edit$(y%)=""
		elseif sb%=0
			edit$(y%)=right$(b$,len(b$)-eb%)
		elseif eb%=len(b$) and sb%=len(b$) and eb%>1
			edit$(y%)=left$(b$,sb%-1)
		elseif eb%=len(b$)
			edit$(y%)=left$(b$,sb%)
		else
			edit$(y%)=left$(b$,sb%)+right$(b$,len(b$)-eb%)
		endif
		edshwmrk:
		edclip$=mid$(b$,sb%+1,eb%-sb%)
		if edit$(y%)="" and y%>1
			y%=y%-1
			sb%=len(edit$(y%))
		endif
		b$=edit$(y%)
		b%=sb%
		x%=gtwidth(left$(b$,b%))
		cursor win1%,14,2+4*ov%,15
	endif
	if b$=""
		b$=b$+k$
	elseif b%=0
		if ov%=1 and k$<>tab$
			b$=right$(b$,len(b$)-1)
		endif
		b$=k$+b$
	elseif b%<len(b$)
		if ov%=1 and k$<>tab$
			b$=left$(b$,b%)+right$(b$,len(b$)-b%-1)
		endif
		b$=left$(b$,b%)+k$+right$(b$,len(b$)-b%)
	elseif b%=len(b$) and y%<nl% and edit$(y%+1)<>"" and ov%=1
		y%=y%+1
		b$=edit$(y%)
		b%=0
		x%=0
		b$=right$(b$,len(b$)-1)
		b$=k$+b$
	else
		b$=b$+k$
	endif
	chng%=1
	b%=b%+len(k$)
	x%=x%+gtwidth(k$)
	edit$(y%)=b$
	l%=0
	if (k$=" " or k$=tab$) and y%>1
		l%=len(edit$(y%-1))
		edwrap:(y%-1)
		if len(edit$(y%-1))>l%
			x%=0
			b%=0
		elseif y%<nl% and b%>len(edit$(y%))
			b%=b%-len(edit$(y%))
			y%=y%+1
			x%=gtwidth(left$(edit$(y%),b%))
		endif
	elseif gtwidth(b$)>=w% or ov%=1 or mk%=1
		if y%>1
			l%=len(edit$(y%-1))
			edwrap:(y%-1)
		else
			edwrap:(1)
		endif
		if y%>1
			if len(edit$(y%-1))>l%
				x%=0
				b%=0
			endif
		endif
		if y%<nl% and b%>len(edit$(y%))
			b%=b%-len(edit$(y%))
			y%=y%+1
			x%=gtwidth(left$(edit$(y%),b%))
		endif
	else
		gat 0,16*y%
		gprintb b$,w%
	endif
	mk%=0
	gat x%,16*y%
ENDP

PROC edbkspc:
	if b%=0 and y%>1
		y%=y%-1
		b$=edit$(y%)
		b%=len(b$)-1
		b$=left$(b$,b%)
		x%=gtwidth(b$)
	elseif b%=1
		if len(b$)>1
			b$=right$(b$,len(b$)-1)
		else
			b$=""
		endif
		b%=0
		x%=0
	elseif b%>1 and b%<len(b$)
		b$=left$(b$,b%-1)+right$(b$,len(b$)-b%)
		b%=b%-1
		x%=gtwidth(left$(b$,b%))
	elseif b%=len(b$) and b%>0
		b$=left$(b$,len(b$)-1)
		b%=b%-1
		x%=gtwidth(b$)
	endif
	eddelet1:
ENDP

PROC eddelete:
	if b%=0 and b$<>""
		if len(b$)=1
			b$=""
		else
			b$=right$(b$,len(b$)-1)
		endif
	elseif b%=len(b$) and b$<>""
		if y%<nl% and edit$(y%+1)<>""
			y%=y%+1
			b$=edit$(y%)
			b%=0
			x%=0
			b$=right$(b$,len(b$)-1)
		else
			return
		endif
	elseif b$<>""
		b$=left$(b$,b%)+right$(b$,len(b$)-b%-1)
	endif
	eddelet1:
ENDP

PROC eddelet1:
	local l%,l1%
	chng%=1
	edit$(y%)=b$
	l%=len(b$)
	if y%>1
		l1%=len(edit$(y%-1))
		edwrap:(y%-1)
	else
		l1%=0
		edwrap:(1)
	endif
	if y%>1
		if len(edit$(y%-1))>l1%
			y%=y%-1
			b%=b%+l1%
			x%=gtwidth(left$(edit$(y%),b%))
		endif
	endif
	if len(edit$(y%))<l%
		b%=l%-len(edit$(y%))
		y%=y%+1
		x%=gtwidth(left$(edit$(y%),b%))
	endif
	gat x%,16*y%
ENDP

PROC edwrap:(a%)
	local p%,f%,last%,flag%
	txt$=""
	edit$(10)=""
	f%=a%
	do
		if len(txt$)+len(edit$(f%))<255
			txt$=txt$+edit$(f%)
			f%=f%+1
		else
			txt$=txt$+left$(edit$(f%),255-len(txt$))
			f%=nl%+1
		endif
	until f%>nl%
	f%=a%
	do
		edit$(f%)=""
		f%=f%+1
	until f%>nl%
	f%=a%
	last%=1
	flag%=0
	do
		p%=last%+step%
		if p%>len(txt$)
			if gtwidth(right$(txt$,len(txt$)-last%+1))<w%
				edit$(f%)=right$(txt$,len(txt$)-last%+1)
				flag%=1
			else
				p%=len(txt$)
			endif
		endif
		if flag%=0
			do
				if mid$(txt$,p%,1)=" "
					if gtwidth(mid$(txt$,last%,p%-last%+1))<w%
						edit$(f%)=mid$(txt$,last%,p%-last%+1)
						last%=p%+1
						f%=f%+1
						break
					endif
				endif
				p%=p%-1
			until p%=last%
			if p%=last%
				p%=last%+step%
				if p%>len(txt$)
					p%=len(txt$)
				endif
				do
					p%=p%-1
				until gtwidth(mid$(txt$,last%,p%-last%+1))<w%
				edit$(f%)=mid$(txt$,last%,p%-last%+1)
				last%=p%+1
				f%=f%+1
			endif
		endif
	until flag%=1 or f%>nl%
	eddispl:(a%)
ENDP

PROC edlftwrd:
	local l%,sp$(2)
	if mk%>0
		edclrmrk:
	endif
	if b%=0
		if y%=1
			return
		else
			y%=y%-1
			b$=edit$(y%)
			b%=len(b$)
		endif
	endif
	flag%=0
	l%=b%
	do
		l%=l%-1
		if l%=0
			if y%=1
				return
			else
				y%=y%-1
				b$=edit$(y%)
				b%=len(b$)
				l%=b%
			endif
		else
			sp$=mid$(b$,l%,2)
			if left$(sp$,1)=" " and right$(sp$,1)<>" "
				flag%=l%
			endif
		endif
	until flag%>0 or l%=1
	if flag%>0
		b%=flag%
		x%=gtwidth(left$(b$,b%))
	else
		b%=0
		x%=0
	endif
	gat x%,16*y%
ENDP

PROC edrtwrd:
	local sp$(2)
	if mk%>0
		edclrmrk:
	endif
	if b%>=len(b$)-1
		if y%=nl%
			b%=len(b$)
			x%=gtwidth(b$)
			gat x%,16*y%
			return
		elseif y%<nl% and edit$(y%+1)=""
			b%=len(b$)
			x%=gtwidth(b$)
			gat x%,16*y%
			return
		else
			y%=y%+1
			b$=edit$(y%)
			b%=0
			x%=0
			gat x%,16*y%
			return
		endif
	endif
	flag%=0
	l%=b%
	do
		l%=l%+1
		sp$=mid$(b$,l%,2)
		if left$(sp$,1)=" " and right$(sp$,1)<>" "
			flag%=l%
		endif
	until flag%>0 or l%=len(b$)-1
	if flag%>0
		b%=flag%
		x%=gtwidth(left$(b$,b%))
		if b%=len(b$)-1 and y%<nl% and edit$(y%+1)<>""
			y%=y%+1
			b%=0
			x%=0
		endif
	else
		if y%<nl% and edit$(y%+1)<>"" and right$(b$,1)=" "
			y%=y%+1
			b%=0
			x%=0
		elseif edit$(y%+1)=""
			b%=len(b$)
			x%=gtwidth(b$)
		endif
	endif
	gat x%,16*y%
ENDP

PROC edwrdmrk:
	if mk%=0
		sb%=b%
		eb%=b%
	else
		edshwmrk:
	endif
	if len(b$)<3
		sb%=0
		eb%=len(b$)
	elseif sb%<2
		sb%=0
	elseif mk%=0 or mk%=2
		if mk%=2
			l%=sb%-1
		else
			l%=sb%
		endif
		do
			if mid$(b$,l%,1)=" "
				sb%=l%
				break
			endif
			l%=l%-1
		until l%=0
		if l%=0
			sb%=0
		endif
	endif
	if eb%>len(b$)-2
		eb%=len(b$)
	elseif mk%=0 or mk%=1
		l%=eb%+1
		do
			if mid$(b$,l%,1)=" "
				eb%=l%
				break
			endif
			l%=l%+1
		until l%=len(b$)
		if l%=len(b$)
			eb%=len(b$)
		endif
	endif
	cursor off
	gat gtwidth(left$(b$,sb%)),y%*16-14
	ginvert gtwidth(left$(b$,eb%))-gtwidth(left$(b$,sb%)),17
ENDP

PROC edmrkend:
	if b%=len(b$) or (mk%>0 and eb%=len(b$))
		return
	endif
	if mk%>0
		edshwmrk:
	endif
	if mk%=0
		sb%=b%
	elseif mk%=2
		sb%=eb%
	endif
	mk%=1
	eb%=len(b$)
	w1%=gtwidth(left$(b$,sb%))
	w2%=gtwidth(b$)
	cursor off
	edshwmrk:
ENDP

PROC edmrkhm:
	if b%=0 or (mk%>0 and sb%=0)
		return
	endif
	if mk%>0
		edshwmrk:
	endif
	if mk%=0
		eb%=b%
	elseif mk%=1
		eb%=sb%
	endif
	mk%=2
	sb%=0
	w1%=0
	w2%=gtwidth(left$(b$,eb%))
	cursor off
	edshwmrk:
ENDP

PROC edmrkln:
	if b$=""
		return
	endif
	if mk%>0
		edclrmrk:
	endif
	b%=0
	sb%=0
	eb%=len(b$)
	mk%=1
	w1%=0
	w2%=gtwidth(b$)
	cursor off
	edshwmrk:
ENDP

PROC eddelmrk:(clip%)
	chng%=1
	if sb%=0 and eb%=len(b$)
		edit$(y%)=""
	elseif sb%=0
		edit$(y%)=right$(b$,len(b$)-eb%)
	elseif eb%=len(b$) and sb%=len(b$) and eb%>1
		edit$(y%)=left$(b$,sb%-1)
	elseif eb%=len(b$)
		edit$(y%)=left$(b$,sb%)
	else
		edit$(y%)=left$(b$,sb%)+right$(b$,len(b$)-eb%)
	endif
	if clip%=1
		edclip$=mid$(b$,sb%+1,eb%-sb%)
	endif
	edshwmrk:
	b%=sb%
	x%=gtwidth(left$(edit$(y%),b%))
	mk%=0
	eb%=0
	sb%=0
	edwrap:(1)
	if edit$(y%)="" and y%>1
		y%=y%-1
		b%=len(edit$(y%))
		x%=gtwidth(edit$(y%))
	endif
	if b%>len(edit$(y%))
		b%=len(edit$(y%))
		x%=gtwidth(edit$(y%))
	endif
	gat x%,16*y%
	cursor win1%,14,2+4*ov%,15
ENDP

PROC edclrmrk:
	edshwmrk:
	eddispl:(1)
	mk%=0
	sb%=0
	eb%=0
	x%=gtwidth(left$(b$,b%))
	gat x%,16*y%
	cursor win1%,14,2+4*ov%,15
ENDP

PROC edshrt:
	if mk%=0 and b%<len(b$)
		cursor off
		sb%=b%
		w1%=gtwidth(left$(b$,sb%))
		mk%=1
		eb%=b%+1
		w2%=gtwidth(left$(b$,eb%))
		edshwmrk:
	elseif mk%=1 and eb%<len(b$)
		edshwmrk:
		eb%=eb%+1
		w2%=gtwidth(left$(b$,eb%))
		edshwmrk:
	elseif mk%=2
		edshwmrk:
		sb%=sb%+1
		if sb%<eb%
			w1%=gtwidth(left$(b$,sb%))
			edshwmrk:
		else
			b%=sb%
			x%=gtwidth(left$(b$,b%))
			gat x%,16*y%
			cursor win1%,14,2+4*ov%,15
			mk%=0
		endif
	endif
ENDP

PROC edshlft:
	if mk%=0 and b%>0
		cursor off
		eb%=b%
		w2%=gtwidth(left$(b$,eb%))
		mk%=2
		sb%=b%-1
		w1%=gtwidth(left$(b$,sb%))
		edshwmrk:
	elseif mk%=1
		edshwmrk:
		eb%=eb%-1
		if eb%>sb%
			w2%=gtwidth(left$(b$,eb%))
			edshwmrk:
		else
			b%=sb%
			x%=gtwidth(left$(b$,b%))
			gat x%,16*y%
			mk%=0
			cursor win1%,14,2+4*ov%,15
		endif
	elseif mk%=2 and sb%>0
		edshwmrk:
		sb%=sb%-1
		w1%=gtwidth(left$(b$,sb%))
		edshwmrk:
	endif
ENDP

PROC edshwmrk:
	gat w1%,16*y%-14
	ginvert w2%-w1%,17
ENDP

PROC edpaste:
	local ll%
	if edclip$=""
		return
	endif
	k$=edclip$
	ll%=len(edit$(1))+len(edit$(2))+len(edit$(3))+len(edit$(4))+len(edit$(5))+len(edit$(6))+len(edit$(7))+len(edit$(8))+len(edit$(9))
	if (ov%=0 and mk%=0 and ll%+len(k$)>255) or (ov%=1 and ll%+len(k$)>255) or (mk%>0 and ll%-eb%+sb%+len(k$)>255)
		return
	endif
	if y%=nl%
		if mk%=0 and gtwidth(b$)+gtwidth(k$)>=w%
			return
		endif
		if mk%>0
			if gtwidth(b$)-gtwidth(mid$(b$,sb%,eb%-sb%+1))+gtwidth(k$)>=w%
				return
			endif
		endif
	endif
	edinsert:
ENDP

PROC edcopy:
	if mk%=0
		return
	endif
	edclip$=mid$(b$,sb%+1,eb%-sb%)
	edshwmrk:
	mk%=0
	b%=sb%
	x%=gtwidth(left$(edit$(y%),b%))
	gat x%,16*y%
	cursor win1%,14,2+4*ov%,15
ENDP

PROC edsrepl:
	local p%,s%,r%,rp%
	if mk%>0
		edclrmrk:
	endif
	if edit$(1)=""
		return
	endif
	txt$=edit$(1)+edit$(2)+edit$(3)+edit$(4)+edit$(5)+edit$(6)+edit$(7)+edit$(8)+edit$(9)
	dinit "Search & Replace"
	dedit eds$,"Search for",20
	dedit edr$,"Replace with",20
	dchoice cs%,"Case sensitive","No,Yes"
	dialog
	s%=len(eds$)
	r%=len(edr$)
	if eds$="" or len(txt$)<s% or eds$=edr$
		return
	endif
	rp%=0
	p%=1
	do
		if mid$(txt$,p%,s%)=eds$ or (cs%=1 and lower$(mid$(txt$,p%,s%))=lower$(eds$))
			if len(txt$)+r%-s%<256
				txt$=left$(txt$,p%-1)+edr$+right$(txt$,len(txt$)-p%-s%+1)
				rp%=1
				if r%>0
					p%=p%+r%-1
				endif
			else
				break
			endif
		else
			p%=p%+1
		endif
	until p%>len(txt$)-s%+1
	if rp%=0
		return
	endif
	edit$(1)=""
	edit$(2)=""
	edit$(3)=""
	edit$(4)=""
	edit$(5)=""
	edit$(6)=""
	edit$(7)=""
	edit$(8)=""
	edit$(9)=""
	edit$(1)=txt$
	edwrap:(1)
	x%=0
	y%=1
	b%=0
	chng%=1
	gat x%,16*y%
ENDP

PROC edspcchr:
	guse win2%
	edspcurs:
	gvisible on
	k$=""
	do
		k%=get
		if k%=257 and spy%<6
			edspcurs:
			spy%=spy%+1
			edspcurs:
		elseif k%=256 and spy%>1
			edspcurs:
			spy%=spy%-1
			edspcurs:
		elseif k%=259 and spx%>1
			edspcurs:
			spx%=spx%-1
			edspcurs:
		elseif k%=258 and spx%<15
			edspcurs:
			spx%=spx%+1
			edspcurs:
		elseif k%=13
			k$=mid$(edch$(spy%),spx%,1)
			edspcurs:
			gvisible off
			guse win1%
			return
		endif
	until k%=27
	gvisible off
	edspcurs:
	guse win1%
ENDP

PROC edspcurs:
	gat 16*spx%-12,16*spy%-11
	gbox 16,16
ENDP

PROC edwrdcnt:
	local p%,sp%,words%
	txt$=edit$(1)+edit$(2)+edit$(3)+edit$(4)+edit$(5)+edit$(6)+edit$(7)+edit$(8)+edit$(9)
	if txt$=""
		return
	endif
	p%=1
	sp%=1
	words%=0
	do
		if mid$(txt$,p%,1)<>" " and sp%=1
			words%=words%+1
			sp%=0
		elseif mid$(txt$,p%,1)=" "
			sp%=1
		endif
		p%=p%+1
	until p%>len(txt$)
	if words%=0
		return
	endif
	dinit "Word Count"
	dtext "","Number of words: "+num$(words%,3),2
	dialog
ENDP

PROC edcase:
	local c%
	if edit$(1)=""
		return
	endif
	dinit ""
	dchoice c%,"Convert to","Upper Case,Lower Case"
	dl%=dialog
	if dl%=0
		return
	endif
	if c%=2
		edit$(1)=lower$(edit$(1))
		edit$(2)=lower$(edit$(2))
		edit$(3)=lower$(edit$(3))
		edit$(4)=lower$(edit$(4))
		edit$(5)=lower$(edit$(5))
		edit$(6)=lower$(edit$(6))
		edit$(7)=lower$(edit$(7))
		edit$(8)=lower$(edit$(8))
		edit$(9)=lower$(edit$(9))
	else
		edit$(1)=upper$(edit$(1))
		edit$(2)=upper$(edit$(2))
		edit$(3)=upper$(edit$(3))
		edit$(4)=upper$(edit$(4))
		edit$(5)=upper$(edit$(5))
		edit$(6)=upper$(edit$(6))
		edit$(7)=upper$(edit$(7))
		edit$(8)=upper$(edit$(8))
		edit$(9)=upper$(edit$(9))
	endif
	chng%=1
	edwrap:(1)
	eddispl:(1)
	edPgDn:
	edend:
ENDP

PROC edsave:(file$)
	cursor off
	lopen "m:\opd\"+file$+".txt"
	lprint edit$(1)
	lprint edit$(2)
	lprint edit$(3)
	lprint edit$(4)
	lprint edit$(5)
	lprint edit$(6)
	lprint edit$(7)
	lprint edit$(8)
	lprint edit$(9)
	lclose
ENDP

PROC edhelp:
	dinit "Help - 1"
	dtext "Psion+C","Copy",0
	dtext "Psion+I","Paste",0
	dtext "Psion+L","Mark the current line",0
	dtext "Psion+R","Search & replace",0
	dtext "Shift+Psion+C","Insert Special Character",0
	dtext "Psion+O","Select insert or overwrite mode",0
	dtext "Psion+W","Word Count",0
	dl%=dialog
	if dl%=0
		return
	endif
	dinit "Help - 2"
	dtext "Psion+V","Convert case"
	dtext "Delete/Shift+Delete","Delete character or marked text",0
	dtext "Shift+"+chr$(27)+"/"+chr$(26),"Mark text",0
	dtext "Shift+Ctrl+"+chr$(27)+"/"+chr$(26),"Mark the current word",0
	dtext "Shift+Psion+"+chr$(27)+"/"+chr$(26),"Mark to the beginning/end of the line",0
	dtext "Esc","Quit",0
	dtext "Enter","Save",0
	dialog
ENDP

PROC edabout:
	dinit "Editor "+edver$
	dtext "","Ian Chapple",2
	dtext "","e-mail: ian_and_aida@compuserve.com",2
	dialog
ENDP
[ show as plain text ]   [ codebase index ]
Comments: 0 [ expand all ] [ post a new comment ]

Disclaimer: The following comments are the responsibility of the poster. epoczone.com is not responsible in any way for what they may say.
If you have not already done so, please read the terms and conditions before you post a comment.

Digital SLR News - DSLR camera information

 Log in
Username:
Password:

 Poll
With very few new releases of software, no new PDAs, and very little site maintenance happening, should the EPOC Zone be shut down?
Yes, it's pretty much useless...
No, it's one of the last Psion outposts!
[ results ]

 Top 5
MyNotes
Biklog5
VoiceMan5
MBMView
PsiDat

 Tips
DjVu Viewer
Sdictionary
Sviewer - .TXT.GZ file viewer
Maximum memory for revo
CF-data is not secured




 Glossary
Revo
DI 27/DI 28
GPRS
Parse
Kill (an EPOC application)

 Codebase
Handing stacks
Finding out the number of images in an MBM file.
Plotting Math functions
word-wrapping editor ver. 3.26
word-wrapping editor ver. 3.26

 Mailing list
Enter your email address and hit 'Subscribe' to join the software mailing list

Search:
Keywords:
In Association with Amazon.co.uk


(C)opyright 1999-2007 epoczone.com
Not logged in.
Please read the legal stuff.
A shrunken.net site