Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'In der unteren Leiste offene Dateien anzeigen
- dim shared as integer xscale, yscale, scrollx, scrolly=1, num_lines
- xscale=loword(width)
- yscale=hiword(width)
- dim shared as ushort feld(xscale, yscale)
- dim shared as ubyte feld_clr_fg(xscale,yscale),feld_clr_bg(xscale,yscale),old_bg
- old_bg=hiword(color)
- redim as string lines(0 to 1000)
- sub change_backcolor(y as integer, clr as integer)
- for i as integer=4 to xscale-1
- feld_clr_bg(i,y)=clr
- next
- end sub
- sub clear_text()
- for y as integer=0 to yscale-2
- for x as integer=0 to xscale-1
- feld(x,y)=0
- feld_clr_fg(x,y)=0
- feld_clr_bg(x,y)=0
- next
- next
- end sub
- sub render_text()
- locate 1,1,0
- for y as integer=0 to yscale-2
- for x as integer=0 to xscale-1
- color feld_clr_fg(x,y),old_bg
- if feld_clr_bg(x,y)<>0 then color ,feld_clr_bg(x,y)
- if feld(x,y)=0 then
- print " ";
- else
- print wchr(feld(x,y));
- end if
- next
- print
- next
- end sub
- sub print_text(text as string, x as integer, y as integer, clr as integer=15)
- for i as integer=0 to len(text)-1
- if text[i]<>&hA then feld(x+i,y)=text[i]
- feld_clr_fg(x+i,y)=clr
- next
- end sub
- sub print_char(char as ushort, x as integer, y as integer, clr as integer=15)
- feld(x,y)=char
- feld_clr_fg(x,y)=clr
- end sub
- var ff=freefile
- open "test.bas" for input as #ff
- do
- num_lines+=1
- line input #ff,lines(num_lines)
- for i as integer=0 to len(lines(num_lines))-1
- if lines(num_lines)[i]=9 then
- if i=0 then
- lines(num_lines)=space(3)+mid(lines(num_lines),i+2)
- else
- lines(num_lines)=mid(lines(num_lines),1,i-1)+space(3)+mid(lines(num_lines),i+2)
- end if
- end if
- next
- loop until eof(ff)
- close #ff
- dim shared as integer mousex,mousey,mousez,old_mousez,mouseb,cursorx,cursory
- function keypress(key as integer) as integer
- static lastkey(255) as integer
- static keytimer as double
- if multikey(key) and not lastkey(key) then
- keytimer=timer
- end if
- if timer>keytimer+0.5 then
- return multikey(key)
- end if
- function = (multikey(key) and not lastkey(key))
- lastkey(key) = multikey(key)
- end function
- dim shared as ubyte change=1
- dim as ubyte key
- do
- key=asc(inkey())
- select case as const key
- case 32 to 254
- lines(cursory)=mid(lines(cursory),1,cursorx-4)+chr(key)+mid(lines(cursory),cursorx-3)
- cursorx+=1
- change=1
- end select
- getmouse mousex,mousey,mousez,mouseb
- if mousez<>old_mousez and mousez<>-1 then
- scrolly+=(old_mousez-mousez)*4
- change=1
- end if
- old_mousez=mousez
- if keypress(&h50) then 'Hoch
- cursory+=1
- if cursory>yscale-1 then scrolly+=1
- change=1
- elseif keypress(&h48) then 'Runter
- cursory-=1
- if cursory<scrolly then scrolly-=1
- if scrolly<1 then scrolly=1
- change=1
- elseif keypress(&h4D) then 'Rechts
- cursorx+=1
- change=1
- elseif keypress(&h4B) then 'Links
- cursorx-=1
- change=1
- elseif keypress(&h51) then 'Bild Runter
- cursory+=yscale
- scrolly+=yscale
- change=1
- elseif keypress(&h49) then 'Bild Rauf
- cursory-=yscale
- scrolly-=yscale
- change=1
- elseif keypress(&h47) then 'Pos1
- cursorx=4
- change=1
- elseif keypress(&h4F) then 'Ende
- cursorx=4+len(lines(cursory))
- change=1
- end if
- if mouseb=1 then
- cursorx=mousex
- cursory=mousey+scrolly
- change=1
- mouseb=0
- end if
- if cursory<1 then cursory=1
- if cursory>num_lines then cursory=num_lines
- if cursorx<4 then cursorx=4
- if cursorx>4+len(lines(cursory)) then cursorx=4+len(lines(cursory))
- if scrolly<1 then scrolly=1
- if scrolly>num_lines-1 then scrolly=num_lines-1
- if change=1 then clear_text
- for i as integer=scrolly to scrolly+yscale-1
- if i<10 then
- print_text(" "+str(i),0,i-scrolly,8)
- elseif i<100 then
- print_text(" "+str(i),0,i-scrolly,8)
- else
- print_text(str(i),0,i-scrolly,8)
- end if
- print_text(lines(i),4,i-scrolly,15)
- if cursory=i then
- change_backcolor(i-scrolly,8)
- print_char(&h2588,cursorx,i-scrolly,15)
- end if
- next
- if change=1 then
- render_text()
- change=0
- end if
- sleep 2,1
- loop 'until key=chr(27)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement