'DIM lb, mx, my, mz, mf, oldmx, oldmy AS INTEGER 'Mouse variables
'DIM caps AS INTEGER
'DIM SHARED prompt_column AS INTEGER
'DIM SHARED startpos AS INTEGER
'DIM SHARED vertpos AS INTEGER
'DIM SHARED endpos AS INTEGER
'DIM SHARED xx AS INTEGER: ' Cursor row.
'DIM SHARED yy AS INTEGER: ' Cursor column.
'DIM SHARED yyseparator AS INTEGER
'DIM ii, j, j2, k, m1, m2 AS INTEGER
'DIM ins AS INTEGER
'DIM flag AS INTEGER ' Indicates highlighting in progress.
'DIM dir AS INTEGER ' direction of the highlighting left (-) or right (+).
'DIM hmrk, shift, ctrl AS INTEGER ' hmrk is = -1 when void and when in use, indicates the Position in the text array when highlighting begins.
'DIM entryrow(vmax) AS INTEGER 'Tracks rows where prompts are present.
CONST prompt_length
= 17 ' Length of longest prompt. CONST c1f
= 0:
CONST c1b
= 7 ' Color 1. Foreground and background. CONST c2f
= 7:
CONST c2b
= 1 ' Color 2. Text highlighting CONST vmax
= 4 ' Number of prompts. Must not exceed rows of screen.
DIM entry$
(vmax
) ' AS STRING 'Text entry array.
MAX_SIZE = 36
debug = 0 'Set to zero to turn of, or non-zero to print variables to screen.
prompt_column = 10 'Number of columns to indent prompts.
startpos = prompt_column + prompt_length - 1
vertpos = 5
endpos = startpos + MAX_SIZE
yyseparator = 2 ' # of blank rows - 1 between prompts. Do not set lower than 1.
ins = 7 ' Cursor vertical height.
SetConsoleTitle
CALL setconsole
(c1f
, c1b
)
CALL GetPrompts
(startpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, prompt_column
, entryrow
(), prompt$
())
CALL GetConsoleInput
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, c1f
, c1b
, c2f
, c2b
, prompt_column
, entryrow
(), prompt$
(), entry$
())
title$ = "Pete's Custom Keyboard Input App"
SUB setconsole
(c1f
, c1b
)
SUB GetPrompts
(startpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, prompt_column
, entryrow
(), prompt$
()) xx = startpos
yy = vertpos
prompt$(0) = "Name..........: "
prompt$(1) = "Address.......: "
prompt$(2) = "City/State/Zip: "
prompt$(3) = "Phone.........: "
yy = vertpos
entryrow(ii) = yy
yy = yy + yyseparator
xx = startpos
yy = vertpos
SUB copy
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), xntry$
, hmrk
, flag
, dir
) IF xx
- startpos
+ 1 < hmrk
THEN m2 = hmrk
m1 = xx - startpos + 1
m1 = hmrk
m2 = xx - startpos + 1
xntry$
= MID$(entry$
((yy
- vertpos
) / yyseparator
), m1
, m2
- m1
)
SUB replace
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), hmrk
, flag
, dir
) j
= LEN(entry$
((yy
- vertpos
) / yyseparator
)) IF xx
- startpos
+ 1 < hmrk
THEN m2 = hmrk
m1 = xx - startpos
m1 = hmrk - 1
m2 = xx - startpos + 1
entry$
((yy
- vertpos
) / yyseparator
) = MID$(entry$
((yy
- vertpos
) / yyseparator
), 1, m1
) + MID$(entry$
((yy
- vertpos
) / yyseparator
), m2
) PRINT entry$
((yy
- vertpos
) / yyseparator
);
IF xx
- startpos
+ 1 > hmrk
THEN xx = hmrk - 1 + startpos
hmrk = 0
flag = 0
dir = 0
SUB GetConsoleInput
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, c1f
, c1b
, c2f
, c2b
, prompt_column
, entryrow
(), prompt$
(), entry$
()) STATIC drag
, dir
, flag
, hmrk
, xntry$
shift = -1
ctrl = -1
oldyy = yy
flag = 0 ' Disable flag so character value isn't printed after a shift / release event without highlighting.
flag = 0
CALL mouse
(startpos
, vmax
, xx
, yy
, vertpos
, yyseparator
, hmrk
, dir
, flag
, c1f
, c1b
, c2f
, c2b
, drag
, prompt_column
, MAX_SIZE
, shift
, ch$
, entry$
(), entryrow
())
PRINT entry$
((yy
- vertpos
) / yyseparator
);
hmrk = 1
flag = -1
dir
= LEN(entry$
((yy
- vertpos
) / yyseparator
)) xx = startpos + dir
CALL copy
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), xntry$
, hmrk
, flag
, dir
)
CALL copy
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), xntry$
, hmrk
, flag
, dir
) CALL replace
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), hmrk
, flag
, dir
)
CALL replace
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), hmrk
, flag
, dir
) m1 = xx - startpos
m2 = m1 + 1
IF LEN(xntry$
) + LEN(entry$
((yy
- vertpos
) / yyseparator
)) - (m2
- m1
) <= MAX_SIZE
- 1 THEN entry$
((yy
- vertpos
) / yyseparator
) = MID$(entry$
((yy
- vertpos
) / yyseparator
), 1, m1
) + xntry$
+ MID$(entry$
((yy
- vertpos
) / yyseparator
), m2
) PRINT entry$
((yy
- vertpos
) / yyseparator
);
BEEP ' Contents too large to paste. CALL replace
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), hmrk
, flag
, dir
) xx = xx - 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 2);
" ";
entry$
((yy
- vertpos
) / yyseparator
) = MID$(entry$
((yy
- vertpos
) / yyseparator
), 1, xx
- startpos
) + MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 2) CALL copy
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), xntry$
, hmrk
, flag
, dir
) CALL replace
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), hmrk
, flag
, dir
)
CALL replace
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), hmrk
, flag
, dir
) IF LEN(entry$
((yy
- vertpos
) / yyseparator
)) > 0 AND xx
- startpos
<= LEN(entry$
((yy
- vertpos
) / yyseparator
)) THEN PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 2);
" ";
entry$
((yy
- vertpos
) / yyseparator
) = MID$(entry$
((yy
- vertpos
) / yyseparator
), 1, xx
- startpos
) + MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 2)
yy = yy - yyseparator
xx = startpos
IF (yy
- vertpos
) / yyseparator
+ 1 < vmax
THEN yy = yy + yyseparator
xx = startpos
hmrk = xx - startpos + 1
flag = -1
xx = xx - 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1) dir = dir - 1
xx = xx - 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1) dir = dir - 1
hmrk = 0
xx = xx - 1
IF xx
< endpos
- 1 AND xx
- startpos
< LEN(entry$
((yy
- vertpos
) / yyseparator
)) THEN hmrk = xx - startpos + 1
flag = -1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1) xx = xx + 1
dir = dir + 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1) xx = xx + 1
dir = dir + 1
hmrk = 0
flag = 0
xx = xx + 1
hmrk = xx - startpos + 1
' flag is already set.
xx = xx - 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1);
dir = dir - 1
xx = xx - 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1);
dir = dir - 1
hmrk = 0
flag = 0
xx = startpos
WHILE xx
- startpos
< LEN(entry$
((yy
- vertpos
) / yyseparator
)) hmrk = xx - startpos + 1
flag = -1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1);
xx = xx + 1
dir = dir + 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1);
xx = xx + 1
dir = dir + 1
hmrk = 0
xx
= startpos
+ LEN(entry$
((yy
- vertpos
) / yyseparator
))
HideCursor ins
CALL replace
(startpos
, endpos
, vertpos
, vmax
, yyseparator
, xx
, yy
, ins
, MAX_SIZE
, prompt_column
, entryrow
(), prompt$
(), entry$
(), hmrk
, flag
, dir
) IF xx
- startpos
< MAX_SIZE
- 1 THEN MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1) = ch$
xx = xx + 1
IF LEN(entry$
((yy
- vertpos
) / yyseparator
)) < MAX_SIZE
- 1 THEN PRINT ch$
+ MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1);
entry$
((yy
- vertpos
) / yyseparator
) = MID$(entry$
((yy
- vertpos
) / yyseparator
), 1, xx
- startpos
) + ch$
+ MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1) xx = xx + 1
flag = -1
PRINT entry$
((oldyy
- vertpos
) / yyseparator
);
hmrk = 0
flag = 0
dir = 0
ch$ = ""
SUB mouse
(startpos
, vmax
, xx
, yy
, vertpos
, yyseparator
, hmrk
, dir
, flag
, c1f
, c1b
, c2f
, c2b
, drag
, prompt_column
, MAX_SIZE
, shift
, ch$
, entry$
(), entryrow
())
PRINT " oldmx"; oldmx;
" oldmy"; oldmy;
" mx"; mx;
" my"; my;
" lb"; lb;
" lbdn"; lbdn;
" dblclk"; doubleclick;
" " PRINT " shift"; shift;
" drag"; drag;
" mhl"; mhl;
" hmrk"; hmrk;
" dir"; dir;
" " PRINT " mx"; mx
- startpos
+ 1;
" my";
(my
- vertpos
) / yyseparator;
" xx"; xx
- startpos
+ 1;
" yy";
(yy
- vertpos
) / yyseparator;
" "
IF lb
AND flag
AND drag
= 0 THEN ' Allows highlighting caused by mouse click to be removed in parent sub. shift = 0
IF mhl
= 0 THEN ' Shift + click highlighting. IF my
= yy
AND mx
<> xx
AND mx
>= startpos
AND mx
- startpos
<= LEN(entry$
((yy
- vertpos
) / yyseparator
)) THEN mhl = mx - startpos + 1
ELSE ' Terminal point reached, end highlighting.
IF LEN(entry$
((yy
- vertpos
) / yyseparator
)) THEN IF lbdn
AND xx
<> mx
OR mhl
THEN ' Combined drag and shift + click highlighting. IF mx
>= startpos
AND mx
- startpos
<= LEN(entry$
((yy
- vertpos
) / yyseparator
)) + 1 THEN drag = -1
drag = 1
drag = 0
IF mx
>= startpos
AND mx
- startpos
<= LEN(entry$
((yy
- vertpos
) / yyseparator
)) THEN IF drag
= 0 AND shift
= 0 THEN yy
= my
' Prevents changing rows if a drag is in progress. xx = mx
IF lbdn
= 0 THEN lbdn
= -1: oldmx
= mx: oldmy
= my
IF mx
>= prompt_column
AND mx
- startpos
<= MAX_SIZE
THEN IF mx
- startpos
> 0 AND mx
- startpos
<= LEN(entry$
(ii
)) THEN yy = my: xx = mx
yy = my: xx = startpos
doubleclick = doubleclick + 1
lbdn = 0
drag = 0
mhl = 0
' Any double click events go here...
doubleclick = 0
mousedrag:
IF dir
<= 0 THEN ' highlight to left hmrk = xx - startpos + 1
shift = -2 ' emulated shift key down
flag = -1
xx = xx - 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1) dir = dir - 1
ELSE ' unhighlight to left xx = xx - 1
dir = dir - 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1) hmrk = 0
flag = 0
shift = 0
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1) hmrk = xx - startpos + 1
flag = -1
shift = -2 ' emulated shift key down
xx = xx + 1
dir = dir + 1
PRINT MID$(entry$
((yy
- vertpos
) / yyseparator
), xx
- startpos
+ 1, 1) xx = xx + 1
dir = dir + 1
hmrk = 0
flag = 0
shift = 0