Post by zzz000abc on Oct 24, 2019 21:25:39 GMT
here is an attempt to make a simple text editor which displays colored text.
I guees the main problem is mapping scroll bar position to row/column numbers and long press of mouse button to detected..So I solved just that problem and full functionality can be enhanced easily but requires little more calculations.Here is the code:
I guees the main problem is mapping scroll bar position to row/column numbers and long press of mouse button to detected..So I solved just that problem and full functionality can be enhanced easily but requires little more calculations.Here is the code:
nomainwin
fn$="threePointCircle.bas"
open fn$ for input as#1
s$=input$(#1,lof(#1))
close#1
while word$(s$,nr+1,chr$(10))<>""
nr=nr+1
wend
dim rowlim(5)
WindowWidth=400
WindowHeight=300
sbx=377:sby=10:sbxx=387:sbyy=250
cx=382:cy=20:cr=4
cbc1$=" ;color white;backcolor white ;":cbc2$=" ;color black;backcolor black ;"
cbc3$=";color 0 0 200"
open"colorful"for graphics_nsb as #1
#1,"down;place ";sbx;" ";sby;" ";";box ";sbxx;" ";sbyy;""
#1,"place ";cx;" ";cy;" ";cbc2$;"circlefilled ";cr
#1,"when leftButtonDown [lbd]"
#1,"when leftButtonUp [lbu]"
fr=1:lr=10
if (nr-fr)<10 then lr=nr
call dsp fr,lr,s$
wait
[lbd]
lb=1
[lbd1]
if chkdwn(MouseX,MouseY)=0 then goto[uinput]
if fr+9<nr and cy<240 then fr=fr+1:lr=fr+10
if cy<240 then cy=cy+10
call nodsp fr-1,lr-1,s$
call dsp fr,lr,s$
call cdwn cx,cy,cr,cbc1$,cbc2$
t1=time$("ms")
timer 200,[wt1]
wait
[wt1]
timer 0
t2=time$("ms")
if lb=1 and (t2-t1)>199 then goto [lbd1]
wait
[lbu]
lb=0
wait
function chkdwn(mx,my)
if mx>377 and mx<387 _
and my>120 and my<250 then _
chkdwn=1 else chkdwn=0
end function
[uinput]
print MouseX,MouseY
wait
sub cdwn x,y,r,t1$,t2$
#1,"place ";x;" ";y-10;" ";t1$;"circlefilled ";r
#1,"place ";x;" ";y;" ";t2$;"circlefilled ";r
end sub
sub dsp fr,lr,s$
y=20
#1,"place 10 10;backcolor white;down"
cs$="blue red brown darkgreen"
while fr<lr
k=int(rnd(1)*4)+1
if k<>kk then
#1,"color ";word$(cs$,k)
#1,"place 0 ";y
#1,"|";mid$(word$(s$,fr+1,chr$(10)),1,40)
fr=fr+1:y=y+20
kk=k
end if
wend
end sub
sub nodsp fr,lr,s$
y=20
#1,"place 10 10;backcolor white;down;color white"
while fr<lr
#1,"place 0 ";y
#1,"|";mid$(word$(s$,fr+1,chr$(10)),1,40)
fr=fr+1:y=y+20
wend
end sub