too much white space

It's a waste of drive space.
This commit is contained in:
visionmercer 2026-05-01 12:36:29 +02:00
commit b6ed340f81

View file

@ -2,12 +2,10 @@ function textinput$ (x as integer, y as integer, w as integer, h as integer, __t
dim text as string, keyin as string dim text as string, keyin as string
dim cursor as integer, done as integer dim cursor as integer, done as integer
text=__text text=__text
' Initial Hover Check
if not (_mousex>x and _mousey>y AND _mousex<x+w AND _mousey<y+h) then if not (_mousex>x and _mousey>y AND _mousex<x+w AND _mousey<y+h) then
drawtextinput x,y,w,h,__text,0 drawtextinput x,y,w,h,__text,0
exit function exit function
end if end if
drawtextinput x,y,w,h,__text,1 drawtextinput x,y,w,h,__text,1
if not mouseclicked then exit function if not mouseclicked then exit function
text="" text=""
@ -15,8 +13,6 @@ function textinput$ (x as integer, y as integer, w as integer, h as integer, __t
dim relativeX as integer dim relativeX as integer
do do
keyin=inkey$ keyin=inkey$
' Handle Extended Keys (Arrows, Home, End, Delete)
if len(keyin)=2 then if len(keyin)=2 then
select case asc(right$(keyin,1)) select case asc(right$(keyin,1))
case 75 ' Left Arrow case 75 ' Left Arrow
@ -52,24 +48,18 @@ function textinput$ (x as integer, y as integer, w as integer, h as integer, __t
done=-1 done=-1
end select end select
end if end if
' Send the cursor position to your drawing routine
drawtextinput x, y, w, h, text, cursor
' Check for clicks inside the box to reposition cursor
while _mouseinput: wend while _mouseinput: wend
if _mousebutton(1) then if _mousebutton(1) then
IF (_mousex>x and _mousey>y AND _mousex<x+w AND _mousey<y+h) THEN IF (_mousex>x and _mousey>y AND _mousex<x+w AND _mousey<y+h) THEN
relativeX=_mousex-x relativeX=_mousex-x
cursor=(relativeX\8)+1 cursor=(relativeX\8)+1
' Constrain cursor to text boundaries
if cursor<1 then cursor=1 if cursor<1 then cursor=1
if cursor>len(text)+1 then cursor=len(text)+1 if cursor>len(text)+1 then cursor=len(text)+1
else else
done=-1 ' Clicked outside, exit focus done=-1 ' Clicked outside, exit focus
end if end if
end if end if
drawtextinput x,y,w,h,text,cursor
_limit 60 _limit 60
_display _display
loop until done loop until done
@ -80,39 +70,29 @@ sub drawtextinput (x as integer, y as integer, w as integer, h as integer, text
dim outtext as string dim outtext as string
dim charWidth as integer:charWidth = 8 dim charWidth as integer:charWidth = 8
dim cursorX as integer,textX as integer,textY as integer dim cursorX as integer,textX as integer,textY as integer
if state>0 then if state>0 then
color backgroundcolor1 color backgroundcolor1
else else
color backgroundcolor2 color backgroundcolor2
end if end if
line(x,y)-(x+w,y+h),,bf line(x,y)-(x+w,y+h),,bf
if state>0 then if state>0 then
color highlightcolor color highlightcolor
ELSE ELSE
color textcolor color textcolor
end if end if
line (x, y)-(x + w, y + h), , B line(x,y)-(x+w,y+h),,b
_printmode _keepbackground _printmode _keepbackground
outtext=right$(text,min(w/charWidth,len(text))) outtext=right$(text,min(w/charWidth,len(text)))
textX=2+x textX=2+x
textY=1+y+h/2-8 textY=1+y+h/2-8
_printstring(textX,textY),outtext _printstring(textX,textY),outtext
' --- Cursor Logic ---
if state>0 then if state>0 then
' Calculate cursor position relative to the visible text
' We use (TIMER * 2) to make it blink
if int(timer*2) mod 2=0 then if int(timer*2) mod 2=0 then
' state is the cursor index (1-based)
' We need to find where that character is relative to our clipped outtext
dim relativeCursor as integer dim relativeCursor as integer
relativeCursor=state-(len(text)-len(outtext)) relativeCursor=state-(len(text)-len(outtext))
' Only draw if the cursor is actually within the visible box
if relativeCursor>=1 and relativeCursor<=len(outtext)+1 then if relativeCursor>=1 and relativeCursor<=len(outtext)+1 then
cursorX=textX+(relativeCursor-1)*charWidth cursorX=textX+(relativeCursor-1)*charWidth
' Draw a vertical line for the cursor
line(cursorX,textY)-(cursorX,textY+14),highlightcolor line(cursorX,textY)-(cursorX,textY+14),highlightcolor
end if end if
end if end if