mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-06-29 11:40:38 +00:00
Simplifies and unifies Input Boxes (new FUNCTION ideinputbox$).
This commit is contained in:
parent
5d735e1ce0
commit
741eefd322
|
@ -5593,7 +5593,8 @@ FUNCTION ide2 (ignore)
|
||||||
|
|
||||||
IF menu$(m, s) = "Modify #COMMAND$..." THEN
|
IF menu$(m, s) = "Modify #COMMAND$..." THEN
|
||||||
PCOPY 2, 0
|
PCOPY 2, 0
|
||||||
retval = idemodifycommandbox
|
ModifyCOMMAND$ = " " + ideinputbox$("Modify COMMAND$", "#Enter text for COMMAND$", _TRIM$(ModifyCOMMAND$), "", 60, 0)
|
||||||
|
IF _TRIM$(ModifyCOMMAND$) = "" THEN ModifyCOMMAND$ = ""
|
||||||
'retval is ignored
|
'retval is ignored
|
||||||
PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt
|
PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt
|
||||||
GOTO ideloop
|
GOTO ideloop
|
||||||
|
@ -7361,7 +7362,7 @@ SUB ideinsline (i, text$)
|
||||||
iden = iden + 1
|
iden = iden + 1
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
SUB idenewsf (sf AS STRING)
|
FUNCTION ideinputbox$(title$, caption$, initialvalue$, validinput$, boxwidth, maxlength)
|
||||||
|
|
||||||
|
|
||||||
'-------- generic dialog box header --------
|
'-------- generic dialog box header --------
|
||||||
|
@ -7377,7 +7378,143 @@ SUB idenewsf (sf AS STRING)
|
||||||
|
|
||||||
'-------- init --------
|
'-------- init --------
|
||||||
|
|
||||||
'built initial name if word selected
|
i = 0
|
||||||
|
|
||||||
|
idepar p, boxwidth, 5, title$
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
PrevFocus = 1
|
||||||
|
o(i).typ = 1
|
||||||
|
o(i).y = 2
|
||||||
|
o(i).nam = idenewtxt(caption$)
|
||||||
|
o(i).txt = idenewtxt(initialvalue$)
|
||||||
|
IF LEN(initialvalue$) > 0 THEN o(i).issel = -1
|
||||||
|
o(i).sx1 = 0
|
||||||
|
o(i).v1 = LEN(initialvalue$)
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
o(i).typ = 3
|
||||||
|
o(i).y = 5
|
||||||
|
o(i).txt = idenewtxt("#OK" + sep + "#Cancel")
|
||||||
|
o(i).dft = 1
|
||||||
|
'-------- end of init --------
|
||||||
|
|
||||||
|
'-------- generic init --------
|
||||||
|
FOR i = 1 TO 100: o(i).par = p: NEXT 'set parent info of objects
|
||||||
|
'-------- end of generic init --------
|
||||||
|
|
||||||
|
DO 'main loop
|
||||||
|
|
||||||
|
|
||||||
|
'-------- generic display dialog box & objects --------
|
||||||
|
idedrawpar p
|
||||||
|
f = 1: cx = 0: cy = 0
|
||||||
|
FOR i = 1 TO 100
|
||||||
|
IF o(i).typ THEN
|
||||||
|
|
||||||
|
'prepare object
|
||||||
|
o(i).foc = focus - f 'focus offset
|
||||||
|
o(i).cx = 0: o(i).cy = 0
|
||||||
|
idedrawobj o(i), f 'display object
|
||||||
|
IF o(i).cx THEN cx = o(i).cx: cy = o(i).cy
|
||||||
|
END IF
|
||||||
|
NEXT i
|
||||||
|
lastfocus = f - 1
|
||||||
|
'-------- end of generic display dialog box & objects --------
|
||||||
|
|
||||||
|
'-------- custom display changes --------
|
||||||
|
'-------- end of custom display changes --------
|
||||||
|
|
||||||
|
'update visual page and cursor position
|
||||||
|
PCOPY 1, 0
|
||||||
|
IF cx THEN SCREEN , , 0, 0: LOCATE cy, cx, 1: SCREEN , , 1, 0
|
||||||
|
|
||||||
|
'-------- read input --------
|
||||||
|
change = 0
|
||||||
|
DO
|
||||||
|
GetInput
|
||||||
|
IF mWHEEL THEN change = 1
|
||||||
|
IF KB THEN change = 1
|
||||||
|
IF mCLICK THEN mousedown = 1: change = 1
|
||||||
|
IF mRELEASE THEN mouseup = 1: change = 1
|
||||||
|
IF mB THEN change = 1
|
||||||
|
alt = KALT: IF alt <> oldalt THEN change = 1
|
||||||
|
oldalt = alt
|
||||||
|
_LIMIT 100
|
||||||
|
LOOP UNTIL change
|
||||||
|
IF alt AND NOT KCTRL THEN idehl = 1 ELSE idehl = 0
|
||||||
|
'convert "alt+letter" scancode to letter's ASCII character
|
||||||
|
altletter$ = ""
|
||||||
|
IF alt AND NOT KCTRL THEN
|
||||||
|
IF LEN(K$) = 1 THEN
|
||||||
|
k = ASC(UCASE$(K$))
|
||||||
|
IF k >= 65 AND k <= 90 THEN altletter$ = CHR$(k)
|
||||||
|
END IF
|
||||||
|
END IF
|
||||||
|
SCREEN , , 0, 0: LOCATE , , 0: SCREEN , , 1, 0
|
||||||
|
'-------- end of read input --------
|
||||||
|
|
||||||
|
'-------- generic input response --------
|
||||||
|
info = 0
|
||||||
|
IF K$ = "" THEN K$ = CHR$(255)
|
||||||
|
IF KSHIFT = 0 AND K$ = CHR$(9) THEN focus = focus + 1
|
||||||
|
IF (KSHIFT AND K$ = CHR$(9)) OR (INSTR(_OS$, "MAC") AND K$ = CHR$(25)) THEN focus = focus - 1: K$ = ""
|
||||||
|
IF focus < 1 THEN focus = lastfocus
|
||||||
|
IF focus > lastfocus THEN focus = 1
|
||||||
|
f = 1
|
||||||
|
FOR i = 1 TO 100
|
||||||
|
t = o(i).typ
|
||||||
|
IF t THEN
|
||||||
|
focusoffset = focus - f
|
||||||
|
ideobjupdate o(i), focus, f, focusoffset, K$, altletter$, mB, mousedown, mouseup, mX, mY, info, mWHEEL
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
|
'-------- end of generic input response --------
|
||||||
|
|
||||||
|
'specific post controls
|
||||||
|
IF focus <> PrevFocus THEN
|
||||||
|
'Always start with TextBox values selected upon getting focus
|
||||||
|
PrevFocus = focus
|
||||||
|
IF focus = 1 THEN
|
||||||
|
o(focus).v1 = LEN(idetxt(o(focus).txt))
|
||||||
|
IF o(focus).v1 > 0 THEN o(focus).issel = -1
|
||||||
|
o(focus).sx1 = 0
|
||||||
|
END IF
|
||||||
|
END IF
|
||||||
|
|
||||||
|
IF LEN(validinput$) THEN
|
||||||
|
a$ = idetxt(o(1).txt)
|
||||||
|
tempA$ = ""
|
||||||
|
FOR i = 1 TO LEN(a$)
|
||||||
|
IF INSTR(validinput$, MID$(a$, i, 1)) > 0 THEN
|
||||||
|
tempA$ = tempA$ + MID$(a$, i, 1)
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
|
idetxt(o(1).txt) = tempA$
|
||||||
|
END IF
|
||||||
|
|
||||||
|
IF maxlength THEN
|
||||||
|
idetxt(o(1).txt) = LEFT$(idetxt(o(1).txt), maxlength)
|
||||||
|
END IF
|
||||||
|
|
||||||
|
IF K$ = CHR$(27) OR (focus = 3 AND info <> 0) THEN
|
||||||
|
EXIT FUNCTION
|
||||||
|
END IF
|
||||||
|
|
||||||
|
IF K$ = CHR$(13) OR (focus = 2 AND info <> 0) THEN
|
||||||
|
ideinputbox$ = idetxt(o(1).txt)
|
||||||
|
EXIT FUNCTION
|
||||||
|
END IF
|
||||||
|
'end of custom controls
|
||||||
|
|
||||||
|
mousedown = 0
|
||||||
|
mouseup = 0
|
||||||
|
LOOP
|
||||||
|
|
||||||
|
END FUNCTION
|
||||||
|
|
||||||
|
SUB idenewsf (sf AS STRING)
|
||||||
|
'build initial name if word selected
|
||||||
IF ideselect THEN
|
IF ideselect THEN
|
||||||
IF ideselecty1 = idecy THEN 'single line selected
|
IF ideselecty1 = idecy THEN 'single line selected
|
||||||
a$ = idegetline(idecy)
|
a$ = idegetline(idecy)
|
||||||
|
@ -7390,282 +7527,34 @@ SUB idenewsf (sf AS STRING)
|
||||||
END IF
|
END IF
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
i = 0
|
newSF$ = ideinputbox$("New " + sf$, "#Name", a2$, "", 60, 40)
|
||||||
|
|
||||||
idepar p, 60, 5, "New " + sf$
|
|
||||||
|
|
||||||
i = i + 1
|
|
||||||
PrevFocus = 1
|
|
||||||
o(i).typ = 1
|
|
||||||
o(i).y = 2
|
|
||||||
o(i).nam = idenewtxt("#Name")
|
|
||||||
o(i).txt = idenewtxt(a2$)
|
|
||||||
IF LEN(a2$) > 0 THEN o(i).issel = -1
|
|
||||||
o(i).sx1 = 0
|
|
||||||
o(i).v1 = LEN(a2$)
|
|
||||||
|
|
||||||
i = i + 1
|
|
||||||
o(i).typ = 3
|
|
||||||
o(i).y = 5
|
|
||||||
o(i).txt = idenewtxt("#OK" + sep + "#Cancel")
|
|
||||||
o(i).dft = 1
|
|
||||||
'-------- end of init --------
|
|
||||||
|
|
||||||
'-------- generic init --------
|
|
||||||
FOR i = 1 TO 100: o(i).par = p: NEXT 'set parent info of objects
|
|
||||||
'-------- end of generic init --------
|
|
||||||
|
|
||||||
DO 'main loop
|
|
||||||
|
|
||||||
|
|
||||||
'-------- generic display dialog box & objects --------
|
|
||||||
idedrawpar p
|
|
||||||
f = 1: cx = 0: cy = 0
|
|
||||||
FOR i = 1 TO 100
|
|
||||||
IF o(i).typ THEN
|
|
||||||
|
|
||||||
'prepare object
|
|
||||||
o(i).foc = focus - f 'focus offset
|
|
||||||
o(i).cx = 0: o(i).cy = 0
|
|
||||||
idedrawobj o(i), f 'display object
|
|
||||||
IF o(i).cx THEN cx = o(i).cx: cy = o(i).cy
|
|
||||||
END IF
|
|
||||||
NEXT i
|
|
||||||
lastfocus = f - 1
|
|
||||||
'-------- end of generic display dialog box & objects --------
|
|
||||||
|
|
||||||
'-------- custom display changes --------
|
|
||||||
'-------- end of custom display changes --------
|
|
||||||
|
|
||||||
'update visual page and cursor position
|
|
||||||
PCOPY 1, 0
|
|
||||||
IF cx THEN SCREEN , , 0, 0: LOCATE cy, cx, 1: SCREEN , , 1, 0
|
|
||||||
|
|
||||||
'-------- read input --------
|
|
||||||
change = 0
|
|
||||||
DO
|
|
||||||
GetInput
|
|
||||||
IF mWHEEL THEN change = 1
|
|
||||||
IF KB THEN change = 1
|
|
||||||
IF mCLICK THEN mousedown = 1: change = 1
|
|
||||||
IF mRELEASE THEN mouseup = 1: change = 1
|
|
||||||
IF mB THEN change = 1
|
|
||||||
alt = KALT: IF alt <> oldalt THEN change = 1
|
|
||||||
oldalt = alt
|
|
||||||
_LIMIT 100
|
|
||||||
LOOP UNTIL change
|
|
||||||
IF alt AND NOT KCTRL THEN idehl = 1 ELSE idehl = 0
|
|
||||||
'convert "alt+letter" scancode to letter's ASCII character
|
|
||||||
altletter$ = ""
|
|
||||||
IF alt AND NOT KCTRL THEN
|
|
||||||
IF LEN(K$) = 1 THEN
|
|
||||||
k = ASC(UCASE$(K$))
|
|
||||||
IF k >= 65 AND k <= 90 THEN altletter$ = CHR$(k)
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
SCREEN , , 0, 0: LOCATE , , 0: SCREEN , , 1, 0
|
|
||||||
'-------- end of read input --------
|
|
||||||
|
|
||||||
'-------- generic input response --------
|
|
||||||
info = 0
|
|
||||||
IF K$ = "" THEN K$ = CHR$(255)
|
|
||||||
IF KSHIFT = 0 AND K$ = CHR$(9) THEN focus = focus + 1
|
|
||||||
IF (KSHIFT AND K$ = CHR$(9)) OR (INSTR(_OS$, "MAC") AND K$ = CHR$(25)) THEN focus = focus - 1: K$ = ""
|
|
||||||
IF focus < 1 THEN focus = lastfocus
|
|
||||||
IF focus > lastfocus THEN focus = 1
|
|
||||||
f = 1
|
|
||||||
FOR i = 1 TO 100
|
|
||||||
t = o(i).typ
|
|
||||||
IF t THEN
|
|
||||||
focusoffset = focus - f
|
|
||||||
ideobjupdate o(i), focus, f, focusoffset, K$, altletter$, mB, mousedown, mouseup, mX, mY, info, mWHEEL
|
|
||||||
END IF
|
|
||||||
NEXT
|
|
||||||
'-------- end of generic input response --------
|
|
||||||
|
|
||||||
'specific post controls
|
|
||||||
IF focus <> PrevFocus THEN
|
|
||||||
'Always start with TextBox values selected upon getting focus
|
|
||||||
PrevFocus = focus
|
|
||||||
IF focus = 1 THEN
|
|
||||||
o(focus).v1 = LEN(idetxt(o(focus).txt))
|
|
||||||
IF o(focus).v1 > 0 THEN o(focus).issel = -1
|
|
||||||
o(focus).sx1 = 0
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
|
|
||||||
IF K$ = CHR$(27) OR (focus = 3 AND info <> 0) THEN
|
|
||||||
EXIT SUB
|
|
||||||
END IF
|
|
||||||
|
|
||||||
IF K$ = CHR$(13) OR (focus = 2 AND info <> 0) THEN
|
|
||||||
y = iden
|
|
||||||
y = y + 1: idesetline y, ""
|
|
||||||
y = y + 1: idesetline y, sf$ + " " + idetxt(o(1).txt)
|
|
||||||
idesy = y
|
|
||||||
y = y + 1: idesetline y, ""
|
|
||||||
idecy = y
|
|
||||||
y = y + 1: idesetline y, "END " + sf$
|
|
||||||
idecx = 1: idesx = 1
|
|
||||||
idechangemade = 1
|
|
||||||
EXIT SUB
|
|
||||||
END IF
|
|
||||||
|
|
||||||
'end of custom controls
|
|
||||||
|
|
||||||
mousedown = 0
|
|
||||||
mouseup = 0
|
|
||||||
LOOP
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IF LEN(newSF$) THEN
|
||||||
|
y = iden
|
||||||
|
y = y + 1: idesetline y, ""
|
||||||
|
y = y + 1: idesetline y, sf$ + " " + newSF$
|
||||||
|
idesy = y
|
||||||
|
y = y + 1: idesetline y, ""
|
||||||
|
idecy = y
|
||||||
|
y = y + 1: idesetline y, "END " + sf$
|
||||||
|
idecx = 1: idesx = 1
|
||||||
|
idechangemade = 1
|
||||||
|
END IF
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
FUNCTION idenewfolder$(thispath$)
|
FUNCTION idenewfolder$(thispath$)
|
||||||
|
newfolder$ = ideinputbox$("New Folder", "#Name", "", "", 60, 0)
|
||||||
|
|
||||||
|
IF LEN(newfolder$) THEN
|
||||||
'-------- generic dialog box header --------
|
IF _DIREXISTS(thispath$ + idepathsep$ + newfolder$) THEN
|
||||||
PCOPY 3, 0
|
idenewfolder$ = newfolder$
|
||||||
PCOPY 0, 2
|
|
||||||
PCOPY 0, 1
|
|
||||||
SCREEN , , 1, 0
|
|
||||||
focus = 1
|
|
||||||
DIM p AS idedbptype
|
|
||||||
DIM o(1 TO 100) AS idedbotype
|
|
||||||
DIM sep AS STRING * 1
|
|
||||||
sep = CHR$(0)
|
|
||||||
'-------- end of generic dialog box header --------
|
|
||||||
|
|
||||||
'-------- init --------
|
|
||||||
|
|
||||||
i = 0
|
|
||||||
|
|
||||||
idepar p, 60, 5, "New Folder"
|
|
||||||
|
|
||||||
i = i + 1
|
|
||||||
PrevFocus = 1
|
|
||||||
o(i).typ = 1
|
|
||||||
o(i).y = 2
|
|
||||||
o(i).nam = idenewtxt("#Name")
|
|
||||||
o(i).txt = idenewtxt(a2$)
|
|
||||||
IF LEN(a2$) > 0 THEN o(i).issel = -1
|
|
||||||
o(i).sx1 = 0
|
|
||||||
o(i).v1 = LEN(a2$)
|
|
||||||
|
|
||||||
i = i + 1
|
|
||||||
o(i).typ = 3
|
|
||||||
o(i).y = 5
|
|
||||||
o(i).txt = idenewtxt("#OK" + sep + "#Cancel")
|
|
||||||
o(i).dft = 1
|
|
||||||
'-------- end of init --------
|
|
||||||
|
|
||||||
'-------- generic init --------
|
|
||||||
FOR i = 1 TO 100: o(i).par = p: NEXT 'set parent info of objects
|
|
||||||
'-------- end of generic init --------
|
|
||||||
|
|
||||||
DO 'main loop
|
|
||||||
|
|
||||||
|
|
||||||
'-------- generic display dialog box & objects --------
|
|
||||||
idedrawpar p
|
|
||||||
f = 1: cx = 0: cy = 0
|
|
||||||
FOR i = 1 TO 100
|
|
||||||
IF o(i).typ THEN
|
|
||||||
|
|
||||||
'prepare object
|
|
||||||
o(i).foc = focus - f 'focus offset
|
|
||||||
o(i).cx = 0: o(i).cy = 0
|
|
||||||
idedrawobj o(i), f 'display object
|
|
||||||
IF o(i).cx THEN cx = o(i).cx: cy = o(i).cy
|
|
||||||
END IF
|
|
||||||
NEXT i
|
|
||||||
lastfocus = f - 1
|
|
||||||
'-------- end of generic display dialog box & objects --------
|
|
||||||
|
|
||||||
'-------- custom display changes --------
|
|
||||||
'-------- end of custom display changes --------
|
|
||||||
|
|
||||||
'update visual page and cursor position
|
|
||||||
PCOPY 1, 0
|
|
||||||
IF cx THEN SCREEN , , 0, 0: LOCATE cy, cx, 1: SCREEN , , 1, 0
|
|
||||||
|
|
||||||
'-------- read input --------
|
|
||||||
change = 0
|
|
||||||
DO
|
|
||||||
GetInput
|
|
||||||
IF mWHEEL THEN change = 1
|
|
||||||
IF KB THEN change = 1
|
|
||||||
IF mCLICK THEN mousedown = 1: change = 1
|
|
||||||
IF mRELEASE THEN mouseup = 1: change = 1
|
|
||||||
IF mB THEN change = 1
|
|
||||||
alt = KALT: IF alt <> oldalt THEN change = 1
|
|
||||||
oldalt = alt
|
|
||||||
_LIMIT 100
|
|
||||||
LOOP UNTIL change
|
|
||||||
IF alt AND NOT KCTRL THEN idehl = 1 ELSE idehl = 0
|
|
||||||
'convert "alt+letter" scancode to letter's ASCII character
|
|
||||||
altletter$ = ""
|
|
||||||
IF alt AND NOT KCTRL THEN
|
|
||||||
IF LEN(K$) = 1 THEN
|
|
||||||
k = ASC(UCASE$(K$))
|
|
||||||
IF k >= 65 AND k <= 90 THEN altletter$ = CHR$(k)
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
SCREEN , , 0, 0: LOCATE , , 0: SCREEN , , 1, 0
|
|
||||||
'-------- end of read input --------
|
|
||||||
|
|
||||||
'-------- generic input response --------
|
|
||||||
info = 0
|
|
||||||
IF K$ = "" THEN K$ = CHR$(255)
|
|
||||||
IF KSHIFT = 0 AND K$ = CHR$(9) THEN focus = focus + 1
|
|
||||||
IF (KSHIFT AND K$ = CHR$(9)) OR (INSTR(_OS$, "MAC") AND K$ = CHR$(25)) THEN focus = focus - 1: K$ = ""
|
|
||||||
IF focus < 1 THEN focus = lastfocus
|
|
||||||
IF focus > lastfocus THEN focus = 1
|
|
||||||
f = 1
|
|
||||||
FOR i = 1 TO 100
|
|
||||||
t = o(i).typ
|
|
||||||
IF t THEN
|
|
||||||
focusoffset = focus - f
|
|
||||||
ideobjupdate o(i), focus, f, focusoffset, K$, altletter$, mB, mousedown, mouseup, mX, mY, info, mWHEEL
|
|
||||||
END IF
|
|
||||||
NEXT
|
|
||||||
'-------- end of generic input response --------
|
|
||||||
|
|
||||||
'specific post controls
|
|
||||||
IF focus <> PrevFocus THEN
|
|
||||||
'Always start with TextBox values selected upon getting focus
|
|
||||||
PrevFocus = focus
|
|
||||||
IF focus = 1 THEN
|
|
||||||
o(focus).v1 = LEN(idetxt(o(focus).txt))
|
|
||||||
IF o(focus).v1 > 0 THEN o(focus).issel = -1
|
|
||||||
o(focus).sx1 = 0
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
|
|
||||||
IF K$ = CHR$(27) OR (focus = 3 AND info <> 0) THEN
|
|
||||||
EXIT SUB
|
EXIT SUB
|
||||||
END IF
|
END IF
|
||||||
|
ideerror = 5
|
||||||
IF K$ = CHR$(13) OR (focus = 2 AND info <> 0) THEN
|
MKDIR thispath$ + idepathsep$ + newfolder$
|
||||||
IF _DIREXISTS(thispath$ + idepathsep$ + idetxt(o(1).txt)) THEN
|
ideerror = 1
|
||||||
idenewfolder$ = idetxt(o(1).txt)
|
idenewfolder$ = newfolder$
|
||||||
EXIT SUB
|
END IF
|
||||||
END IF
|
|
||||||
ideerror = 5
|
|
||||||
MKDIR thispath$ + idepathsep$ + idetxt(o(1).txt)
|
|
||||||
ideerror = 1
|
|
||||||
idenewfolder$ = idetxt(o(1).txt)
|
|
||||||
EXIT SUB
|
|
||||||
END IF
|
|
||||||
|
|
||||||
'end of custom controls
|
|
||||||
|
|
||||||
mousedown = 0
|
|
||||||
mouseup = 0
|
|
||||||
LOOP
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
|
|
||||||
|
@ -10760,298 +10649,18 @@ FUNCTION idebackupbox
|
||||||
LOOP
|
LOOP
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FUNCTION idemodifycommandbox
|
|
||||||
'-------- generic dialog box header --------
|
|
||||||
PCOPY 0, 2
|
|
||||||
PCOPY 0, 1
|
|
||||||
SCREEN , , 1, 0
|
|
||||||
focus = 1
|
|
||||||
DIM p AS idedbptype
|
|
||||||
DIM o(1 TO 100) AS idedbotype
|
|
||||||
DIM sep AS STRING * 1
|
|
||||||
sep = CHR$(0)
|
|
||||||
'-------- end of generic dialog box header --------
|
|
||||||
|
|
||||||
'-------- init --------
|
|
||||||
i = 0
|
|
||||||
idepar p, 65, 5, "Modify COMMAND$"
|
|
||||||
|
|
||||||
a2$ = ModifyCOMMAND$
|
|
||||||
IF LEN(a2$) > 0 THEN a2$ = MID$(a2$, 2)
|
|
||||||
i = i + 1
|
|
||||||
PrevFocus = 1
|
|
||||||
o(i).typ = 1
|
|
||||||
o(i).y = 2
|
|
||||||
o(i).nam = idenewtxt("#Enter text for COMMAND$")
|
|
||||||
o(i).txt = idenewtxt(a2$)
|
|
||||||
o(i).v1 = LEN(a2$)
|
|
||||||
IF o(i).v1 > 0 THEN
|
|
||||||
o(i).issel = -1
|
|
||||||
o(i).sx1 = 0
|
|
||||||
END IF
|
|
||||||
|
|
||||||
i = i + 1
|
|
||||||
o(i).typ = 3
|
|
||||||
o(i).y = 5
|
|
||||||
o(i).txt = idenewtxt("#OK" + sep + "#Cancel")
|
|
||||||
o(i).dft = 1
|
|
||||||
'-------- end of init --------
|
|
||||||
|
|
||||||
'-------- generic init --------
|
|
||||||
FOR i = 1 TO 100: o(i).par = p: NEXT 'set parent info of objects
|
|
||||||
'-------- end of generic init --------
|
|
||||||
|
|
||||||
DO 'main loop
|
|
||||||
|
|
||||||
|
|
||||||
'-------- generic display dialog box & objects --------
|
|
||||||
idedrawpar p
|
|
||||||
f = 1: cx = 0: cy = 0
|
|
||||||
FOR i = 1 TO 100
|
|
||||||
IF o(i).typ THEN
|
|
||||||
|
|
||||||
'prepare object
|
|
||||||
o(i).foc = focus - f 'focus offset
|
|
||||||
o(i).cx = 0: o(i).cy = 0
|
|
||||||
idedrawobj o(i), f 'display object
|
|
||||||
IF o(i).cx THEN cx = o(i).cx: cy = o(i).cy
|
|
||||||
END IF
|
|
||||||
NEXT i
|
|
||||||
lastfocus = f - 1
|
|
||||||
'-------- end of generic display dialog box & objects --------
|
|
||||||
|
|
||||||
'-------- custom display changes --------
|
|
||||||
'-------- end of custom display changes --------
|
|
||||||
|
|
||||||
'update visual page and cursor position
|
|
||||||
PCOPY 1, 0
|
|
||||||
IF cx THEN SCREEN , , 0, 0: LOCATE cy, cx, 1: SCREEN , , 1, 0
|
|
||||||
|
|
||||||
'-------- read input --------
|
|
||||||
change = 0
|
|
||||||
DO
|
|
||||||
GetInput
|
|
||||||
IF mWHEEL THEN change = 1
|
|
||||||
IF KB THEN change = 1
|
|
||||||
IF mCLICK THEN mousedown = 1: change = 1
|
|
||||||
IF mRELEASE THEN mouseup = 1: change = 1
|
|
||||||
IF mB THEN change = 1
|
|
||||||
alt = KALT: IF alt <> oldalt THEN change = 1
|
|
||||||
oldalt = alt
|
|
||||||
_LIMIT 100
|
|
||||||
LOOP UNTIL change
|
|
||||||
IF alt AND NOT KCTRL THEN idehl = 1 ELSE idehl = 0
|
|
||||||
'convert "alt+letter" scancode to letter's ASCII character
|
|
||||||
altletter$ = ""
|
|
||||||
IF alt AND NOT KCTRL THEN
|
|
||||||
IF LEN(K$) = 1 THEN
|
|
||||||
k = ASC(UCASE$(K$))
|
|
||||||
IF k >= 65 AND k <= 90 THEN altletter$ = CHR$(k)
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
SCREEN , , 0, 0: LOCATE , , 0: SCREEN , , 1, 0
|
|
||||||
'-------- end of read input --------
|
|
||||||
|
|
||||||
'-------- generic input response --------
|
|
||||||
info = 0
|
|
||||||
IF K$ = "" THEN K$ = CHR$(255)
|
|
||||||
IF KSHIFT = 0 AND K$ = CHR$(9) THEN focus = focus + 1
|
|
||||||
IF (KSHIFT AND K$ = CHR$(9)) OR (INSTR(_OS$, "MAC") AND K$ = CHR$(25)) THEN focus = focus - 1: K$ = ""
|
|
||||||
IF focus < 1 THEN focus = lastfocus
|
|
||||||
IF focus > lastfocus THEN focus = 1
|
|
||||||
f = 1
|
|
||||||
FOR i = 1 TO 100
|
|
||||||
t = o(i).typ
|
|
||||||
IF t THEN
|
|
||||||
focusoffset = focus - f
|
|
||||||
ideobjupdate o(i), focus, f, focusoffset, K$, altletter$, mB, mousedown, mouseup, mX, mY, info, mWHEEL
|
|
||||||
END IF
|
|
||||||
NEXT
|
|
||||||
'-------- end of generic input response --------
|
|
||||||
|
|
||||||
'specific post controls
|
|
||||||
IF focus <> PrevFocus THEN
|
|
||||||
'Always start with TextBox values selected upon getting focus
|
|
||||||
PrevFocus = focus
|
|
||||||
IF focus = 1 THEN
|
|
||||||
o(focus).v1 = LEN(idetxt(o(focus).txt))
|
|
||||||
IF o(focus).v1 > 0 THEN o(focus).issel = -1
|
|
||||||
o(focus).sx1 = 0
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
|
|
||||||
IF K$ = CHR$(27) OR (focus = 3 AND info <> 0) THEN EXIT FUNCTION
|
|
||||||
|
|
||||||
IF K$ = CHR$(13) OR (focus = 2 AND info <> 0) THEN
|
|
||||||
ModifyCOMMAND$ = " " + idetxt(o(1).txt)
|
|
||||||
IF LTRIM$(RTRIM$(ModifyCOMMAND$)) = "" THEN ModifyCOMMAND$ = ""
|
|
||||||
EXIT FUNCTION
|
|
||||||
END IF
|
|
||||||
|
|
||||||
'end of custom controls
|
|
||||||
|
|
||||||
mousedown = 0
|
|
||||||
mouseup = 0
|
|
||||||
LOOP
|
|
||||||
idemodifycommandbox = 0
|
|
||||||
END FUNCTION
|
|
||||||
|
|
||||||
FUNCTION idegotobox
|
FUNCTION idegotobox
|
||||||
'-------- generic dialog box header --------
|
|
||||||
PCOPY 0, 2
|
|
||||||
PCOPY 0, 1
|
|
||||||
SCREEN , , 1, 0
|
|
||||||
focus = 1
|
|
||||||
DIM p AS idedbptype
|
|
||||||
DIM o(1 TO 100) AS idedbotype
|
|
||||||
DIM sep AS STRING * 1
|
|
||||||
sep = CHR$(0)
|
|
||||||
'-------- end of generic dialog box header --------
|
|
||||||
|
|
||||||
'-------- init --------
|
|
||||||
i = 0
|
|
||||||
idepar p, 30, 5, "Go To Line"
|
|
||||||
|
|
||||||
IF idegotobox_LastLineNum > 0 THEN a2$ = str2$(idegotobox_LastLineNum) ELSE a2$ = ""
|
IF idegotobox_LastLineNum > 0 THEN a2$ = str2$(idegotobox_LastLineNum) ELSE a2$ = ""
|
||||||
i = i + 1
|
v$ = ideinputbox$("Go To Line", "#Line", a2$, "0123456789", 30, 8)
|
||||||
PrevFocus = 1
|
IF v$ = "" THEN EXIT FUNCTION
|
||||||
o(i).typ = 1
|
|
||||||
o(i).y = 2
|
|
||||||
o(i).nam = idenewtxt("#Line")
|
|
||||||
o(i).txt = idenewtxt(a2$)
|
|
||||||
o(i).v1 = LEN(a2$)
|
|
||||||
IF o(i).v1 > 0 THEN
|
|
||||||
o(i).issel = -1
|
|
||||||
o(i).sx1 = 0
|
|
||||||
END IF
|
|
||||||
|
|
||||||
i = i + 1
|
v& = VAL(v$)
|
||||||
o(i).typ = 3
|
IF v& < 1 THEN v& = 1
|
||||||
o(i).y = 5
|
IF v& > iden THEN v& = iden
|
||||||
o(i).txt = idenewtxt("#OK" + sep + "#Cancel")
|
idegotobox_LastLineNum = v&
|
||||||
o(i).dft = 1
|
AddQuickNavHistory idecy
|
||||||
'-------- end of init --------
|
idecy = v&
|
||||||
|
ideselect = 0
|
||||||
'-------- generic init --------
|
|
||||||
FOR i = 1 TO 100: o(i).par = p: NEXT 'set parent info of objects
|
|
||||||
'-------- end of generic init --------
|
|
||||||
|
|
||||||
DO 'main loop
|
|
||||||
|
|
||||||
|
|
||||||
'-------- generic display dialog box & objects --------
|
|
||||||
idedrawpar p
|
|
||||||
f = 1: cx = 0: cy = 0
|
|
||||||
FOR i = 1 TO 100
|
|
||||||
IF o(i).typ THEN
|
|
||||||
|
|
||||||
'prepare object
|
|
||||||
o(i).foc = focus - f 'focus offset
|
|
||||||
o(i).cx = 0: o(i).cy = 0
|
|
||||||
idedrawobj o(i), f 'display object
|
|
||||||
IF o(i).cx THEN cx = o(i).cx: cy = o(i).cy
|
|
||||||
END IF
|
|
||||||
NEXT i
|
|
||||||
lastfocus = f - 1
|
|
||||||
'-------- end of generic display dialog box & objects --------
|
|
||||||
|
|
||||||
'-------- custom display changes --------
|
|
||||||
'-------- end of custom display changes --------
|
|
||||||
|
|
||||||
'update visual page and cursor position
|
|
||||||
PCOPY 1, 0
|
|
||||||
IF cx THEN SCREEN , , 0, 0: LOCATE cy, cx, 1: SCREEN , , 1, 0
|
|
||||||
|
|
||||||
'-------- read input --------
|
|
||||||
change = 0
|
|
||||||
DO
|
|
||||||
GetInput
|
|
||||||
IF mWHEEL THEN change = 1
|
|
||||||
IF KB THEN change = 1
|
|
||||||
IF mCLICK THEN mousedown = 1: change = 1
|
|
||||||
IF mRELEASE THEN mouseup = 1: change = 1
|
|
||||||
IF mB THEN change = 1
|
|
||||||
alt = KALT: IF alt <> oldalt THEN change = 1
|
|
||||||
oldalt = alt
|
|
||||||
_LIMIT 100
|
|
||||||
LOOP UNTIL change
|
|
||||||
IF alt AND NOT KCTRL THEN idehl = 1 ELSE idehl = 0
|
|
||||||
'convert "alt+letter" scancode to letter's ASCII character
|
|
||||||
altletter$ = ""
|
|
||||||
IF alt AND NOT KCTRL THEN
|
|
||||||
IF LEN(K$) = 1 THEN
|
|
||||||
k = ASC(UCASE$(K$))
|
|
||||||
IF k >= 65 AND k <= 90 THEN altletter$ = CHR$(k)
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
SCREEN , , 0, 0: LOCATE , , 0: SCREEN , , 1, 0
|
|
||||||
'-------- end of read input --------
|
|
||||||
|
|
||||||
'-------- generic input response --------
|
|
||||||
info = 0
|
|
||||||
IF K$ = "" THEN K$ = CHR$(255)
|
|
||||||
IF KSHIFT = 0 AND K$ = CHR$(9) THEN focus = focus + 1
|
|
||||||
IF (KSHIFT AND K$ = CHR$(9)) OR (INSTR(_OS$, "MAC") AND K$ = CHR$(25)) THEN focus = focus - 1: K$ = ""
|
|
||||||
IF focus < 1 THEN focus = lastfocus
|
|
||||||
IF focus > lastfocus THEN focus = 1
|
|
||||||
f = 1
|
|
||||||
FOR i = 1 TO 100
|
|
||||||
t = o(i).typ
|
|
||||||
IF t THEN
|
|
||||||
focusoffset = focus - f
|
|
||||||
ideobjupdate o(i), focus, f, focusoffset, K$, altletter$, mB, mousedown, mouseup, mX, mY, info, mWHEEL
|
|
||||||
END IF
|
|
||||||
NEXT
|
|
||||||
'-------- end of generic input response --------
|
|
||||||
|
|
||||||
'specific post controls
|
|
||||||
IF focus <> PrevFocus THEN
|
|
||||||
'Always start with TextBox values selected upon getting focus
|
|
||||||
PrevFocus = focus
|
|
||||||
IF focus = 1 THEN
|
|
||||||
o(focus).v1 = LEN(idetxt(o(focus).txt))
|
|
||||||
IF o(focus).v1 > 0 THEN o(focus).issel = -1
|
|
||||||
o(focus).sx1 = 0
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
|
|
||||||
a$ = idetxt(o(1).txt)
|
|
||||||
IF LEN(a$) > 8 THEN a$ = LEFT$(a$, 8) '8 character limit
|
|
||||||
FOR i = 1 TO LEN(a$)
|
|
||||||
a = ASC(a$, i)
|
|
||||||
IF i = 2 AND ASC(a$, 1) = 48 THEN a$ = "0": EXIT FOR
|
|
||||||
IF a < 48 OR a > 57 THEN a$ = LEFT$(a$, i - 1): EXIT FOR
|
|
||||||
NEXT
|
|
||||||
IF focus <> 1 THEN
|
|
||||||
a = VAL(a$)
|
|
||||||
IF a < 1 THEN a$ = "1"
|
|
||||||
END IF
|
|
||||||
idetxt(o(1).txt) = a$
|
|
||||||
|
|
||||||
IF K$ = CHR$(27) OR (focus = 3 AND info <> 0) THEN EXIT FUNCTION
|
|
||||||
|
|
||||||
IF K$ = CHR$(13) OR (focus = 2 AND info <> 0) THEN
|
|
||||||
v$ = idetxt(o(1).txt)
|
|
||||||
v& = VAL(v$)
|
|
||||||
IF v& < 1 THEN v& = 1
|
|
||||||
IF v& > iden THEN v& = iden
|
|
||||||
idegotobox_LastLineNum = v&
|
|
||||||
AddQuickNavHistory idecy
|
|
||||||
idecy = v&
|
|
||||||
ideselect = 0
|
|
||||||
EXIT FUNCTION
|
|
||||||
END IF
|
|
||||||
|
|
||||||
'end of custom controls
|
|
||||||
|
|
||||||
mousedown = 0
|
|
||||||
mouseup = 0
|
|
||||||
LOOP
|
|
||||||
|
|
||||||
idegotobox = 0
|
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue