main:
' The next two lines can be removed to use this library with other programs.
LINE INPUT "Input 1 for debug mode with variable display, any other to keep debug off. "; a$
' Place the routine that will use this library above and/or ConsoleInput.CursorAppearanceide this loop...
'=============================CONSOLE INPUT LIBRARY===========================
STATIC ConsoleInput_prompt$
(), entry$
(), ConsoleInput_entryrow
() AS INTEGER
' User Defined Variable Types--------------------------------------------------------
MarginTop
AS INTEGER ' Margin top (Number of spaces from the top to display the first prompt.) PromptMarginLeft
AS INTEGER ' Margin left. The column to begin displaying prompts. Must be within screen width including maximum length of response. PromptSpacing
AS INTEGER ' The vertical row spacing between prompts. 1 to (n). ResponseLength
AS INTEGER ' Maximum length of the reply to prompt. Must be within the screen width. MyPalette
AS INTEGER ' Only use to modify standard screen colors. -1 means this option is turned off. ColorTextForeground
AS INTEGER ' Foreground text color (0 - 15) ColorTextBackground
AS INTEGER ' Background text color (0 - 15) ColorHighlightForeground
AS INTEGER ' Foreground highlight text color (0 - 15) ColorHighlightBackground
AS INTEGER ' Background highlight text color (0 - 15) CursorAppearance
AS INTEGER ' Default is 7 for text insert and 30 for text overwrite. Insert key changes mode. ' ------------------------------------------------------------------------------------
PromptLength
AS INTEGER ' Automatically determined by library function. PromptsDisplayed
AS INTEGER ' Automatically determined by library function. ResponsemarginLeft
AS INTEGER ' Automatically determined by library function. ResponseMarginRight
AS INTEGER ' Automatically determined by library function.
ConsoleInput_Data:
' User Defined Prompts Go Here. Leave the DATA EOF.--------------------------------
DATA "Example Prompt 1: ","Example Prompt 2: ","Example Prompt 3: " ' ---------------------------------------------------------------------------------
' User Defined Prompts Go Here. Keep DATA EOF.-------------------------------------
ConsoleInput.MarginTop = 5
ConsoleInput.PromptMarginLeft = 10
ConsoleInput.PromptSpacing = 2 'Number of blank rows, less 1, between prompts. Do not set lower than 1.
ConsoleInput.ResponseLength = 50
ConsoleInput_MyPalette = 63
ConsoleInput.ColorTextForeground = 0
ConsoleInput.ColorTextBackground = 7
ConsoleInput.ColorHighlightForeground = 7
ConsoleInput.ColorHighlightBackground = 1
ConsoleInput.CursorAppearance = 7 'Cursor vertical height for default ConsoleInput.CursorAppearanceert text mode.
' ---------------------------------------------------------------------------------
IF ConsoleInput_MyPalette
>= 0 THEN PALETTE ConsoleInput.ColorTextBackground
, ConsoleInput_MyPalette
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
CALL ConsoleInputGetPrompts
(ConsoleInput_entryrow
(), ConsoleInput_prompt$
())
DIM entry$
(ConsoleInput.PromptsDisplayed
) 'Text entry array. LOCATE , , 1, 7, ConsoleInput.CursorAppearance
UserInputSetup = -1
CALL ConsoleInputResponse
(ConsoleInput_entryrow
(), entry$
())
SUB ConsoleInputGetPrompts
(ConsoleInput_entryrow
() AS INTEGER, ConsoleInput_prompt$
())
' Get the number of prompts to assign to ConsoleInput_prompt$() array.
ConsoleInput.PromptsDisplayed = 0
IF LEN(ConsoleInput_Data$
) > ConsoleInput.PromptLength
THEN ConsoleInput.PromptLength
= LEN(ConsoleInput_Data$
) ConsoleInput.PromptsDisplayed = ConsoleInput.PromptsDisplayed + 1
REDIM ConsoleInput_prompt$
(ConsoleInput.PromptsDisplayed
) REDIM ConsoleInput_prompt$
(ConsoleInput.PromptsDisplayed
) 'Prompt array. REDIM ConsoleInput_entryrow
(ConsoleInput.PromptsDisplayed
) AS INTEGER 'Tracks row location of each prompt.
ConsoleInput.ResponsemarginLeft = ConsoleInput.PromptMarginLeft + ConsoleInput.PromptLength
ConsoleInput.ResponseMarginRight = ConsoleInput.ResponsemarginLeft + ConsoleInput.ResponseLength
ConsoleInput_i = 0
ConsoleInput_prompt$(ConsoleInput_i) = ConsoleInput_Data$
ConsoleInput_i = ConsoleInput_i + 1
ConsoleInput.xx = ConsoleInput.ResponsemarginLeft
ConsoleInput.yy = ConsoleInput.MarginTop
FOR ConsoleInput_i
= 0 TO ConsoleInput.PromptsDisplayed
- 1 LOCATE ConsoleInput.yy
, ConsoleInput.PromptMarginLeft
PRINT ConsoleInput_prompt$
(ConsoleInput_i
);
ConsoleInput_entryrow(ConsoleInput_i) = ConsoleInput.yy
ConsoleInput.yy = ConsoleInput.yy + ConsoleInput.PromptSpacing
LOCATE ConsoleInput.MarginTop
, ConsoleInput.ResponsemarginLeft
ConsoleInput.xx = ConsoleInput.ResponsemarginLeft
ConsoleInput.yy = ConsoleInput.MarginTop
SUB ConsoleInputCopyText
(ConsoleInput_xntry$
, entry$
())
IF ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1 < ConsoleInput.hmrk
THEN ConsoleInput_m2 = ConsoleInput.hmrk
ConsoleInput_m1 = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft + 1
ConsoleInput_m1 = ConsoleInput.hmrk
ConsoleInput_m2 = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft + 1
ConsoleInput_xntry$
= MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput_m1
, ConsoleInput_m2
- ConsoleInput_m1
)
SUB ConsoleInputReplace
(entry$
())
ConsoleInput_j
= LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
IF ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1 < ConsoleInput.hmrk
THEN ConsoleInput_m2 = ConsoleInput.hmrk
ConsoleInput_m1 = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft
ConsoleInput_m1 = ConsoleInput.hmrk - 1
ConsoleInput_m2 = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft + 1
entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
) = MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), 1, ConsoleInput_m1
) + MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput_m2
) LOCATE ConsoleInput.yy
, ConsoleInput.ResponsemarginLeft
PRINT entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
);
PRINT STRING$(ConsoleInput_j
- LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)), 32);
IF ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1 > ConsoleInput.hmrk
THEN ConsoleInput.xx = ConsoleInput.hmrk - 1 + ConsoleInput.ResponsemarginLeft
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.hmrk = 0
ConsoleInput.hl = 0
ConsoleInput.dir = 0
SUB ConsoleInputResponse
(ConsoleInput_entryrow
() AS INTEGER, entry$
())
IF ConsoleInput.ctrl
THEN ConsoleInput.ctrl
= 0 IF ConsoleInput.shift
< 0 THEN ConsoleInput.shift
= 0 ConsoleInput_i
= PEEK(&H417) MOD 16 ConsoleInput.shift = -1
ConsoleInput.ctrl = -1
ConsoleInput_oldyy = ConsoleInput.yy
IF ConsoleInput.hl
AND ConsoleInput.shift
= 0 AND ConsoleInput.hmrk
= 0 THEN ConsoleInput.hl = 0 ' Disable ConsoleInput.hl so character value isn't printed after a shift / release event without highlighting.
CALL ConsoleInputMouse
(ConsoleInput_entryrow
(), entry$
(), ConsoleInput_ch$
)
IF ConsoleInput_ch$
<> "" THEN LOCATE ConsoleInput.yy
, ConsoleInput.ResponsemarginLeft
COLOR ConsoleInput.ColorHighlightForeground
, ConsoleInput.ColorHighlightBackground
PRINT entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
);
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
ConsoleInput.hmrk = 1
ConsoleInput.hl = -1
ConsoleInput.dir
= LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) ConsoleInput.xx = ConsoleInput.ResponsemarginLeft + ConsoleInput.dir
LOCATE ConsoleInput.yy
, ConsoleInput.xx
CALL ConsoleInputCopyText
(ConsoleInput_xntry$
, entry$
())
CALL ConsoleInputCopyText
(ConsoleInput_xntry$
, entry$
()) CALL ConsoleInputReplace
(entry$
())
IF ConsoleInput_xntry$
<> "" THEN CALL ConsoleInputReplace
(entry$
()) ConsoleInput_m1 = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft
ConsoleInput_m2 = ConsoleInput_m1 + 1
IF LEN(ConsoleInput_xntry$
) + LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) - (ConsoleInput_m2
- ConsoleInput_m1
) <= ConsoleInput.ResponseLength
- 1 THEN entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
) = MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), 1, ConsoleInput_m1
) + ConsoleInput_xntry$
+ MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput_m2
) LOCATE ConsoleInput.yy
, ConsoleInput.ResponsemarginLeft
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
PRINT entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
);
ConsoleInput.xx
= ConsoleInput.xx
+ LEN(ConsoleInput_xntry$
) LOCATE ConsoleInput.yy
, ConsoleInput.xx
BEEP ' Contents too large to paste. ConsoleInput_ch$
= CHR$(0) CALL ConsoleInputReplace
(entry$
()) IF ConsoleInput.xx
> ConsoleInput.ResponsemarginLeft
THEN ConsoleInput.xx = ConsoleInput.xx - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 2);
" ";
entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
) = MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), 1, ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
) + MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 2) LOCATE ConsoleInput.yy
, ConsoleInput.xx
CALL ConsoleInputCopyText
(ConsoleInput_xntry$
, entry$
()) CALL ConsoleInputReplace
(entry$
()) ConsoleInput_ch$
= CHR$(0) CALL ConsoleInputReplace
(entry$
()) IF LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) > 0 AND ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
<= LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) THEN PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 2);
" ";
entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
) = MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), 1, ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
) + MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 2) LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput_ch$
= CHR$(0) IF ConsoleInput.yy
> ConsoleInput.MarginTop
THEN ConsoleInput.yy = ConsoleInput.yy - ConsoleInput.PromptSpacing
ConsoleInput.xx = ConsoleInput.ResponsemarginLeft
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput_ch$
= CHR$(0) IF (ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
+ 1 < ConsoleInput.PromptsDisplayed
THEN ConsoleInput.yy = ConsoleInput.yy + ConsoleInput.PromptSpacing
ConsoleInput.xx = ConsoleInput.ResponsemarginLeft
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput_ch$
= CHR$(0) IF ConsoleInput.xx
> ConsoleInput.ResponsemarginLeft
THEN ConsoleInput.hmrk = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft + 1
ConsoleInput.hl = -1
ConsoleInput.xx = ConsoleInput.xx - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorHighlightForeground
, ConsoleInput.ColorHighlightBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1) ConsoleInput.dir = ConsoleInput.dir - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.xx = ConsoleInput.xx - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1) ConsoleInput.dir = ConsoleInput.dir - 1
ConsoleInput.hmrk = 0
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.xx = ConsoleInput.xx - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput_ch$
= CHR$(0) IF ConsoleInput.xx
< ConsoleInput.ResponseMarginRight
- 1 AND ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
< LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) THEN ConsoleInput.hmrk = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft + 1
ConsoleInput.hl = -1
COLOR ConsoleInput.ColorHighlightForeground
, ConsoleInput.ColorHighlightBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1) ConsoleInput.xx = ConsoleInput.xx + 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.dir = ConsoleInput.dir + 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1) ConsoleInput.xx = ConsoleInput.xx + 1
ConsoleInput.dir = ConsoleInput.dir + 1
ConsoleInput.hmrk = 0
ConsoleInput.hl = 0
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.xx = ConsoleInput.xx + 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput_ch$
= CHR$(0) IF ConsoleInput.xx
> ConsoleInput.ResponsemarginLeft
THEN WHILE ConsoleInput.xx
> ConsoleInput.ResponsemarginLeft
ConsoleInput.hmrk = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft + 1
' ConsoleInput.hl is already set.
ConsoleInput.xx = ConsoleInput.xx - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorHighlightForeground
, ConsoleInput.ColorHighlightBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1);
ConsoleInput.dir = ConsoleInput.dir - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.xx = ConsoleInput.xx - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1);
ConsoleInput.dir = ConsoleInput.dir - 1
ConsoleInput.hmrk = 0
ConsoleInput.hl = 0
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.xx = ConsoleInput.ResponsemarginLeft
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput_ch$
= CHR$(0) IF ConsoleInput.xx
< ConsoleInput.ResponseMarginRight
- 1 THEN WHILE ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
< LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) ConsoleInput.hmrk = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft + 1
ConsoleInput.hl = -1
COLOR ConsoleInput.ColorHighlightForeground
, ConsoleInput.ColorHighlightBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1);
ConsoleInput.xx = ConsoleInput.xx + 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.dir = ConsoleInput.dir + 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1);
ConsoleInput.xx = ConsoleInput.xx + 1
ConsoleInput.dir = ConsoleInput.dir + 1
ConsoleInput.hmrk = 0
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.xx
= ConsoleInput.ResponsemarginLeft
+ LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput_ch$
= CHR$(0)
ConsoleInput_ch$
= CHR$(0) IF ConsoleInput.CursorAppearance
= 7 THEN ConsoleInput.CursorAppearance
= 30 ELSE ConsoleInput.CursorAppearance
= 7 LOCATE , , 1, 7, ConsoleInput.CursorAppearance
CALL ConsoleInputReplace
(entry$
()) IF ConsoleInput.CursorAppearance
= 30 THEN IF ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
< ConsoleInput.ResponseLength
- 1 THEN MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1) = ConsoleInput_ch$
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.xx = ConsoleInput.xx + 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
IF LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) < ConsoleInput.ResponseLength
- 1 THEN PRINT ConsoleInput_ch$
+ MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1);
entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
) = MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), 1, ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
) + ConsoleInput_ch$
+ MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1) ConsoleInput.xx = ConsoleInput.xx + 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
IF ConsoleInput.hl
= 0 AND ConsoleInput.dir
<> 0 THEN ConsoleInput.hl = -1 ' When ConsoleInput.dir <> 0 the first character has been highlighted.
IF ConsoleInput_ch$
<> "" THEN IF ConsoleInput.hl
AND ConsoleInput.shift
= 0 AND LCASE$(ConsoleInput_ch$
) <> "x" AND ConsoleInput.ctrl
= 0 AND ConsoleInput_ch$
<> CHR$(8) AND ConsoleInput_ch$
<> CHR$(0) + "S" THEN ' ROutine to remove highlighting from text.
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
LOCATE ConsoleInput_oldyy
, ConsoleInput.ResponsemarginLeft
PRINT entry$
((ConsoleInput_oldyy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
);
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput.hmrk = 0
ConsoleInput.hl = 0
ConsoleInput.dir = 0
ConsoleInput_ch$ = ""
SUB ConsoleInputMouse
(ConsoleInput_entryrow
() AS INTEGER, entry$
(), ConsoleInput_ch$
)
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
PRINT " oldmx"; ConsoleInput_oldmx;
" oldmy"; ConsoleInput_oldmy;
" mx"; ConsoleInput_mx;
" my"; ConsoleInput_my;
" xx"; ConsoleInput.xx;
" yy"; ConsoleInput.yy;
" lb"; ConsoleInput_lb;
" lbdn"; ConsoleInput_lbdn;
" " PRINT " shift"; ConsoleInput.shift;
" drag"; ConsoleInput.drag;
" mhl"; mhl;
" hmrk"; ConsoleInput.hmrk;
" dir"; ConsoleInput.dir;
" dblclk"; ConsoleInput_doubleclick;
" " PRINT " mx"; ConsoleInput_mx
- ConsoleInput.ResponsemarginLeft
+ 1;
" my";
(ConsoleInput_my
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing;
" xx"; ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1;
" yy";
(ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing;
" hl"; ConsoleInput.hl;
" Response Margin"; ConsoleInput.ResponsemarginLeft;
" ";
LOCATE ConsoleInput.yy
, ConsoleInput.xx
IF ConsoleInput_lb
AND ConsoleInput.hl
AND ConsoleInput.shift
= 0 AND ConsoleInput.drag
= 0 AND ConsoleInput_mhl
= 0 THEN ' Allows highlighting caused by mouse click to be removed in parent sub. ConsoleInput_ch$
= CHR$(0)
IF ConsoleInput.shift
AND ConsoleInput_lb
AND ConsoleInput.drag
= 0 OR ConsoleInput_mhl
THEN IF ConsoleInput_mhl
= 0 THEN ' Shift + click highlighting. IF ConsoleInput_my
= ConsoleInput.yy
AND ConsoleInput_mx
<> ConsoleInput.xx
AND ConsoleInput_mx
>= ConsoleInput.ResponsemarginLeft
AND ConsoleInput_mx
- ConsoleInput.ResponsemarginLeft
<= LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) THEN ConsoleInput_mhl = ConsoleInput_mx - ConsoleInput.ResponsemarginLeft + 1
ELSE ' Terminal point reached, end highlighting. IF ConsoleInput_mhl
= ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1 THEN ConsoleInput_mhl
= 0: ConsoleInput.drag
= 0:
EXIT SUB
IF LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) THEN IF ConsoleInput_lbdn
AND ConsoleInput.xx
<> ConsoleInput_mx
AND ConsoleInput.shift
= 0 OR ConsoleInput_mhl
THEN ' Combined drag and shift + click highlighting. IF ConsoleInput_my
= ConsoleInput.yy
THEN ' Restrict to active text line. IF ConsoleInput_lb
OR ConsoleInput_mhl
THEN IF ConsoleInput.xx
> ConsoleInput_mx
THEN ConsoleInput.drag = -1
ConsoleInput.drag = 1
GOSUB mouseConsoleInput.drag
ConsoleInput.drag = 0
IF ConsoleInput_debug
THEN COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground:
LOCATE 2, 1:
PRINT "left button down " IF ConsoleInput_lbdn
= 0 THEN ConsoleInput_lbdn
= -1 IF ConsoleInput_my
= ConsoleInput.yy
THEN IF ConsoleInput_mx
>= ConsoleInput.ResponsemarginLeft
AND ConsoleInput_mx
- ConsoleInput.ResponsemarginLeft
<= LEN(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
)) THEN IF ConsoleInput.drag
= 0 AND ConsoleInput.shift
= 0 THEN ConsoleInput.yy
= ConsoleInput_my
' Prevents changing rows if a ConsoleInput.drag is in progress. ConsoleInput.xx = ConsoleInput_mx
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ConsoleInput_oldmx = ConsoleInput_mx: ConsoleInput_oldmy = ConsoleInput_my
FOR ConsoleInput_i
= 0 TO ConsoleInput.PromptsDisplayed
- 1 IF ConsoleInput_my
= ConsoleInput_entryrow
(ConsoleInput_i
) THEN EXIT FOR
IF ConsoleInput_my
= ConsoleInput_entryrow
(ConsoleInput_i
) AND ConsoleInput.drag
= 0 THEN IF ConsoleInput_mx
>= ConsoleInput.PromptMarginLeft
AND ConsoleInput_mx
- ConsoleInput.ResponsemarginLeft
<= ConsoleInput.ResponseLength
THEN IF ConsoleInput_mx
- ConsoleInput.ResponsemarginLeft
> 0 AND ConsoleInput_mx
- ConsoleInput.ResponsemarginLeft
<= LEN(entry$
(ConsoleInput_i
)) THEN ConsoleInput.yy = ConsoleInput_my: ConsoleInput.xx = ConsoleInput_mx
ConsoleInput.yy = ConsoleInput_my: ConsoleInput.xx = ConsoleInput.ResponsemarginLeft
LOCATE ConsoleInput.yy
, ConsoleInput.xx
IF ConsoleInput_debug
THEN COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground:
LOCATE 2, 1:
PRINT "left button released" ConsoleInput_doubleclick = ConsoleInput_doubleclick + 1
ConsoleInput_lbdn = 0
ConsoleInput.drag = 0
IF ConsoleInput_doubleclick
= 1 THEN IF ABS(ConsoleInput_z1
- TIMER) > .33 THEN ConsoleInput_doubleclick
= 0
IF ConsoleInput_doubleclick
= 2 THEN ' Any double click events go here...
ConsoleInput_doubleclick = 0
LOCATE ConsoleInput.yy
, ConsoleInput.xx
mouseConsoleInput.drag:
IF ConsoleInput.dir
<= 0 THEN ' highlight to left ConsoleInput.hmrk = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft + 1
' Do not emulate shift here.
ConsoleInput.hl = -1
ConsoleInput.xx = ConsoleInput.xx - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorHighlightForeground
, ConsoleInput.ColorHighlightBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1) ConsoleInput.dir = ConsoleInput.dir - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
ELSE ' unhighlight to left ConsoleInput.xx = ConsoleInput.xx - 1
ConsoleInput.dir = ConsoleInput.dir - 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1) ConsoleInput.hmrk = 0
ConsoleInput.hl = 0
ConsoleInput.shift = 0
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorHighlightForeground
, ConsoleInput.ColorHighlightBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1) ConsoleInput.hmrk = ConsoleInput.xx - ConsoleInput.ResponsemarginLeft + 1
ConsoleInput.hl = -1
' Do not emulate shift here.
ConsoleInput.xx = ConsoleInput.xx + 1
ConsoleInput.dir = ConsoleInput.dir + 1
LOCATE ConsoleInput.yy
, ConsoleInput.xx
COLOR ConsoleInput.ColorTextForeground
, ConsoleInput.ColorTextBackground
PRINT MID$(entry$
((ConsoleInput.yy
- ConsoleInput.MarginTop
) \ ConsoleInput.PromptSpacing
), ConsoleInput.xx
- ConsoleInput.ResponsemarginLeft
+ 1, 1) ConsoleInput.xx = ConsoleInput.xx + 1
ConsoleInput.dir = ConsoleInput.dir + 1
ConsoleInput.hmrk = 0
ConsoleInput.hl = 0
ConsoleInput.shift = 0
LOCATE ConsoleInput.yy
, ConsoleInput.xx