DECLARE SUB CharMap ()
DECLARE SUB DCursor (s%)
DECLARE SUB DEdit ()
DECLARE SUB DFile ()
DECLARE SUB DHelp ()
DECLARE SUB DoCommand (options%)
DECLARE SUB DrawHBar ()
DECLARE SUB DrawWindow ()
DECLARE SUB DrawScrolls (x%, y1%, y2%, s1%, s2%)
DECLARE SUB DSearch ()
DECLARE SUB DSettings ()
DECLARE SUB DTools ()
DECLARE SUB DView ()
DECLARE SUB ErasePage ()
DECLARE SUB ExitProg ()
DECLARE FUNCTION Inputs$ (x%, y%, length%)
DECLARE FUNCTION KeyTrap$ ()
DECLARE SUB LoadProg ()
DECLARE SUB Main ()
DECLARE SUB Menu ()
DECLARE SUB MouseTrap ()
DECLARE SUB MSDOSPrompt ()
DECLARE SUB PutText ()
DECLARE SUB Prompt (question$, answer$)
DECLARE SUB Respond (cmd$)
'60 lines per page
TYPE regstype
ax AS INTEGER
bx AS INTEGER
cx AS INTEGER
dx AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
flags AS INTEGER
END TYPE
DIM SHARED regs AS regstype
DIM SHARED FileName$
DIM SHARED page$(59), pstart%, p%, mex%, mey%, shx%, shy%
DIM SHARED HelpBar$, cmd$, maxselects%, cellstart%, cellwidth%, selects%
DIM SHARED oldcolor%, fsettings%, elapsedtime&, adTextLoc%
DIM SHARED oregscx%, oregsdx%, ScrollTime!
'fsettings: (integer 2 bytes)
'|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0| load fsettings from TMPn0000.myp
'15-1 if changed
'14-Used by TEXT2004 for the scrolling text at the bottom (on or off)
'13-
'12 to 0-lpage% (0 to 8191)
'4095
CONST TRUE = -1
CONST FALSE = 0
CONST waittime% = 60
LoadProg
PutText
Main
DATA "Characters 32 to 126 can be found on the keyboard, but for all the other "
DATA "ASCII characters you press and hold down ALT while typing in their ASCII "
DATA "number. There are 12 of the 256 ASCII characters that you cannot type in "
DATA "Text Editor 2004. All the others are listed here. "
DATA " "
DATA " ÚÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄÂÄ¿ "
DATA " ³"
DATA " ÃÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄ´ "
DATA " ³"
DATA " ÃÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄ´ "
DATA " ³"
DATA " ÃÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄ´ "
DATA " ³"
DATA " ÃÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄ´ "
DATA " ³"
DATA " ÃÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄ´ "
DATA " ³"
DATA " ÃÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄ´ "
DATA " ³"
DATA " ÃÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄÅÄ´ "
DATA " ³"
DATA " ÀÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÁÄÙ "
SUB CharMap
RESTORE
COLOR 3, 1
LOCATE 4, 3
PRINT "Ú"; STRING$(30, "Ä");
COLOR 1, 7
PRINT "Character Map";
COLOR 3, 1
PRINT STRING$(30, "Ä");
COLOR 14, 1
PRINT CHR$(15);
COLOR 3, 1
PRINT "¿";
FOR i% = 0 TO 21
READ page$(i%)
NEXT i%
FOR x% = 0 TO 34'first and 2nd rows of the map
IF (x% < 10 OR x% > 13) AND x% <> 7 AND x% <> 8 AND (x% < 27 OR x% > 31) THEN page$(6) = page$(6) + CHR$(x%) + "³" ELSE page$(6) = page$(6) + " ³"
IF x% < 16 THEN page$(20) = page$(20) + CHR$(240 + x%) + "³" ELSE page$(20) = page$(20) + " ³"
NEXT x%
page$(6) = page$(6) + " ": page$(20) = page$(20) + " "
FOR y% = 1 TO 6'all the other rows of the map
FOR x% = 0 TO 34
page$(y% * 2 + 6) = page$(y% * 2 + 6) + CHR$(y% * 35 + x%) + "³"
NEXT x%
page$(y% * 2 + 6) = page$(y% * 2 + 6) + " "
NEXT y%
regs.ax = 1
CALL interrupt(&H33, regs, regs)
DO
IF SCREEN(25, 2) <> 32 THEN HelpBar$ = STRING$(78, " ")
cmd$ = KeyTrap$
regs.ax = 3
CALL interrupt(&H33, regs, regs)
IF regs.cx > 16 AND regs.cx < 128 AND regs.dx = 160 THEN HelpBar$ = "CHARACTER->This is the character that you have selected. "
IF regs.cx > 160 AND regs.cx < 320 AND regs.dx = 160 THEN HelpBar$ = "ASCII NUMBER->This is the ASCII value of the character you have selected. "
'scrollbars
IF regs.cx = 616 AND regs.dx > 24 AND regs.dx < 168 THEN HelpBar$ = "SCROLLBAR->Use to scroll up or down the page. "
IF (regs.bx AND 1) = 1 AND regs.cx = 616 AND regs.dx = 32 THEN cmd$ = "PAGEUP"
IF (regs.bx AND 1) = 1 AND regs.cx = 616 AND regs.dx = 160 THEN cmd$ = "PAGEDOWN"
IF (regs.bx AND 1) = 1 AND regs.cx = 616 AND regs.dx > 32 AND regs.dx < 160 THEN
spos% = ((regs.dx \ 8) - 6) / 1.6 AND -2
cmd$ = "PAGEDOWN"
END IF
'exit
IF (regs.bx AND 1) = 1 AND regs.cx = 608 AND regs.dx = 24 THEN cmd$ = "ESCAPE"
IF regs.cx = 608 AND regs.dx = 24 THEN HelpBar$ = "EXIT->Click this to close the Character Map. "
'character map
IF regs.cx >= 48 AND regs.cx < 593 AND regs.dx > (9 - spos%) * 8 AND regs.dx < 153 THEN HelpBar$ = "CHARACTER MAP->Click on a character to see its ASCII number. "
IF (regs.bx AND 1) = 1 AND regs.cx > 48 AND regs.cx < 593 AND regs.dx > (9 - spos%) * 8 AND regs.dx < 153 THEN
xpos% = ((regs.cx / 8) \ 2) * 2 - 1
cmd$ = "CLICK"
ypos% = INT(regs.dx / 8 / 2) * 2 - (4 - spos%)
END IF
DrawHBar
LOOP UNTIL cmd$ <> ""
regs.ax = 2
CALL interrupt(&H33, regs, regs)
REM clear KeyBoard buffer------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
LOCATE aypos%, axpos%
COLOR 15, 1
PRINT char$
SELECT CASE cmd$
CASE "PAGEUP"
IF spos% > 0 THEN spos% = spos% - 2
IF ypos% > spos% + 15 THEN ypos% = ypos% - 2
GOTO 110
CASE "PAGEDOWN"
spos% = spos% + 2
IF spos% > 6 THEN spos% = 6
GOTO 110
CASE "UP"
IF ypos% > 6 THEN ypos% = ypos% - 2
CASE "DOWN"
IF ypos% < 20 THEN ypos% = ypos% + 2
IF ypos% > spos% + 15 THEN spos% = spos% + 2: GOTO 110
CASE "LEFT"
IF xpos% > 4 THEN xpos% = xpos% - 2
CASE "RIGHT"
IF xpos% < 71 THEN xpos% = xpos% + 2
CASE "ESCAPE"
DO
regs.ax = 3
CALL interrupt(&H33, regs, regs)
LOOP UNTIL regs.bx = 0
EXIT SUB
END SELECT
GOTO 120
END SUB
SUB DCursor (s%)
DEF SEG = &HB800
IF shx% > 0 THEN
PutText
FOR y% = shy% - pstart% TO mey% - pstart% STEP SGN(mey% - shy%) OR 1
FOR x% = shx% - 1 TO mex% STEP SGN(mex% - shx% + 1) OR 1
POKE ((y% + 2) * 80 + x%) * 2 + 1, 143
NEXT x%, y%
END IF
IF s% = 1 THEN
POKE ((mey% - pstart% + 2) * 80 + mex%) * 2 + 1, oldcolor%
EXIT SUB
END IF
IF selects% = 0 THEN HelpBar$ = "UNDO->Restores the page to how it was when first viewed. "
IF selects% = 1 THEN HelpBar$ = "REDO->Undoes what the UNDO option did. "
IF selects% = 2 THEN HelpBar$ = "COPY->Remembers the selected text so that you can paste it later. "
IF selects% = 3 THEN HelpBar$ = "PASTE->Types in the remembered text. NOTE:Overwrites anything in the way."
IF selects% = 0 THEN HelpBar$ = "NEW FILE->Starts a new file. "
IF selects% = 1 THEN HelpBar$ = "OPEN FILE->Closes all files and opens another file. "
IF selects% = 2 THEN HelpBar$ = "SAVE FILE->Saves the file that is currently being viewed. "
IF selects% = 3 THEN HelpBar$ = "SAVE FILE AS->Saves the file that is being viewed as another name. "
IF selects% = 4 THEN HelpBar$ = "LOAD FILE->Opens another file without closing any already opened. "
IF selects% = 5 THEN HelpBar$ = "CLOSE FILE->Closes the file that is currently being viewed. "
IF selects% = 6 THEN HelpBar$ = "PRINT FILE->Prints the file that is currently being viewed. "
IF selects% = 7 THEN HelpBar$ = "EXIT PROGRAM->Closes all files and exits TEXT EDITOR 2004. "
END SUB
IF selects% = 0 THEN HelpBar$ = "CONTENTS->Displays help on how to use Text Editor 2004. "
IF selects% = 1 THEN HelpBar$ = "TROUBLESHOOTING->Displays a list of known errors and how to avoid them. "
IF selects% = 2 THEN HelpBar$ = "ABOUT->Displays information about Text Editor 2004. "
END SUB
SUB DoCommand (options%)
'A=chr$(document number%+86)
'A.tmp=:
'FileName$
'lpage%
'current page%
'Apagenum.tmp
'SaveTempFile
SELECT CASE options%
CASE 0
GOTO 40
CASE 1
GOTO 50
CASE 2
GOTO 60
CASE 3
GOTO 70
CASE 4
GOTO 80
CASE 5
GOTO 90
CASE 6
GOTO 100
CASE ELSE
EXIT SUB
END SELECT
40 'File Menu Options:
SELECT CASE selects%
CASE 0
file% = file% + 1
ErasePage
CASE 1
'File$ = FileOpen$
'OpenFile File$
'FileName$ = File$
CASE 2
'save file
CASE 3
'save file as
CASE 4
'load file
CASE 5
'close file
CASE 6
'print file
CASE 7
Prompt "Are you sure you want to exit?", answer$
IF answer$ = "N" OR answer$ = "C" THEN EXIT SUB
Prompt "Save changes to these files?", answer$
IF answer$ = "N" THEN ExitProg
IF answer$ = "C" THEN EXIT SUB
'Save Changes
ExitProg
END SELECT
EXIT SUB
50 'Edit menu options
SELECT CASE selects%
CASE 0'Undo
'swap temp page with other page
CASE 1'Redo
'swap temp page with other page after undo has swapped them.
CASE 2'Copy
'copy to text.inf
CASE 3'Paste
'read from text.inf
END SELECT
EXIT SUB
60 'View menu options
SELECT CASE selects%
CASE 0'Page up
'up page
CASE 1'Page down
'down page
CASE 2'Documents
'view documents. Each has letter a to z. Temp file begins with letter.
CASE 3'Readme
'Load ReadMe.txt
END SELECT
EXIT SUB
70 'Search menu options
SELECT CASE selects%
CASE 0'find text
'prompt for search text and look for first match.
CASE 1'find next
'find the next match (and if the search text is null, this does the same as
'the case 0 thing) .
CASE 2'find files
'search for files on the computer.
END SELECT
EXIT SUB
80 'Tools menu options
SELECT CASE selects%
CASE 0'character map
CharMap
CASE 1'MS-DOS shell
MSDOSPrompt
END SELECT
EXIT SUB
90 'Settings menu options
SELECT CASE selects%
CASE 0'Display
CASE 1'other
CASE 2'uninstall text editor
CASE 3'reinstall text editor
END SELECT
EXIT SUB
100 'Help menu options
SELECT CASE selects%
CASE 0'contents
CASE 1'troubleshooting
CASE 2'about
END SELECT
END SUB
SUB DrawHBar
'check for mouse movement
regs.ax = 3
CALL interrupt(&H33, regs, regs)
IF regs.cx <> oregscx% THEN elapsedtime& = TIMER: oregscx% = regs.cx
IF regs.dx <> oregsdx% THEN elapsedtime& = TIMER: oregsdx% = regs.dx
IF (regs.bx AND 3) THEN elapsedtime& = TIMER
IF elapsedtime& + waittime% > TIMER THEN
COLOR 0, 7
LOCATE 25, 2
PRINT HelpBar$;
EXIT SUB
END IF
COLOR 0, 7
AdText$ = STRING$(79, " ") + "Text Editor 2004-Made by James Nathan Belue(ComputerGhost). Go to http://www.computerghost.webhop.net for more software by ComputerGhost. For questions or comments email computerghost@hotmail.com." + STRING$(79, " ")
adTextLoc% = adTextLoc% + 1
LOCATE 25, 2
PRINT MID$(AdText$, adTextLoc%, 79);
IF adTextLoc% = 277 THEN adTextLoc% = 0
timers = TIMER
DO: LOOP UNTIL timers + .1 < TIMER
END SUB
SUB DrawScrolls (x%, y1%, y2%, s1%, s2%)
COLOR 0, 7
'scroll up button
LOCATE y1%, x%
PRINT CHR$(24);
FOR y% = y1% + 1 TO y2% - 1
LOCATE y%, x%
PRINT "°"
NEXT y%
'scroll down button
LOCATE y2%, x%
PRINT CHR$(25);
'scrolling thing
COLOR 7, 0
FOR y% = s1% TO s1% + s2%
LOCATE y%, x%
PRINT "°"
NEXT y%
END SUB
SUB DrawWindow
COLOR 1, 7
PRINT STRING$(32, " "); "TEXT EDITOR 2004"; STRING$(32, " ")
COLOR 7, 1
PRINT " File Edit View Search Tools Settings Help "
COLOR 0, 7
FOR i% = 1 TO 21
COLOR 0, 3
PRINT STRING$(80, " ");
NEXT i%
COLOR 7, 1
PRINT STRING$(80, " ");
LOCATE , 3
PRINT FileName$;
LOCATE , 50
PRINT "PAGE: COLUMN: ROW: ";
COLOR 0, 7
PRINT STRING$(80, " ");
END SUB
IF selects% = 0 THEN HelpBar$ = "FIND TEXT->Searches for text in opened files. "
IF selects% = 1 THEN HelpBar$ = "FIND NEXT->Finds the next time that the text searched for is displayed. "
IF selects% = 2 THEN HelpBar$ = "FIND FILES->Finds files on your computer. "
IF selects% = 0 THEN HelpBar$ = "DISPLAY->Lets you change the colors the text editor uses. "
IF selects% = 1 THEN HelpBar$ = "OTHER->Lets you change settings other than the display. "
IF selects% = 2 THEN HelpBar$ = "UNINSTALL->Uninstalls Text Editor 2004 or makes an installation disk. "
IF selects% = 3 THEN HelpBar$ = "RE-INSTALL->Uninstalls Text Editor 2004, then installs it again. "
END SUB
IF selects% = 0 THEN HelpBar$ = "CHARACTER MAP->Displays a list of all characters that can be typed. "
IF selects% = 1 THEN HelpBar$ = "MS-DOS PROMPT->Pauses the text editor and goes to the Dos Prompt. "
END SUB
IF selects% = 0 THEN HelpBar$ = "PAGE UP->Goes up a page. "
IF selects% = 1 THEN HelpBar$ = "PAGE DOWN->Goes down a page. "
IF selects% = 2 THEN HelpBar$ = "DOCUMENTS->Lists opened documents that you can edit or view. "
IF selects% = 3 THEN HelpBar$ = "README->Loads the Text Editor 2004's Readme file. "
END SUB
SUB ErasePage
FOR i% = 0 TO 59
page$(i%) = STRING$(80, " ")
NEXT i%
END SUB
SUB ExitProg
'kill *.tmp
COLOR 7, 0
CLS
COLOR 15, 9
PRINT "Text Editor 2004"; STRING$(44, " ");
COLOR 10
PRINT "Made by Nathan Belue"
COLOR 8, 0
PRINT "Finished December 31, 2003. Released January 1, 2004"
timers& = TIMER
DO: LOOP UNTIL timers& + 1 < TIMER
END
END SUB
SELECT CASE cmd$
CASE CHR$(13)
Inputs$ = RTRIM$(InputText$)
EXIT FUNCTION
CASE CHR$(8)
IF place% > 1 THEN InputText$ = LEFT$(InputText$, place% - 2) + RIGHT$(InputText$, LEN(InputText$) - place% + 1): place% = place% - 1
IF place% < dstart% + 1 THEN dstart% = dstart% - 1
GOTO 130
CASE CHR$(0) + "S"
IF place% < LEN(InputText$) THEN InputText$ = LEFT$(InputText$, place% - 1) + RIGHT$(InputText$, LEN(InputText$) - place%)
CASE CHR$(0) + "K"
IF place% > 1 THEN place% = place% - 1
IF place% < dstart% + 1 THEN dstart% = dstart% - 1
GOTO 130
CASE CHR$(0) + "M"
IF place% < LEN(InputText$) AND place% < 160 THEN place% = place% + 1
IF place% - dstart% > length% THEN dstart% = dstart% + 1
GOTO 130
CASE CHR$(9)
CASE ELSE
IF LEN(InputText$) < 160 THEN InputText$ = LEFT$(InputText$, place% + (place% > 0)) + cmd$ + RIGHT$(InputText$, LEN(InputText$) - place% - (place% > 0)): place% = place% + 1
END SELECT
IF place% > length% THEN dstart% = place% - length%
GOTO 130
END FUNCTION
FUNCTION KeyTrap$
cmd$ = INKEY$
DEF SEG = &H40
otherkey% = PEEK(&H17)
IF otherkey% AND 8 THEN
WHILE PEEK(&H17) AND 8: WEND
cmd$ = INKEY$
IF cmd$ = "" THEN cmd$ = "ALT"
END IF
IF (otherkey% AND 3) AND shx% = 0 THEN shx% = mex% + 1: shy% = mey%
IF cmd$ <> "" AND cmd$ <> CHR$(0) + "S" AND shx% > 0 AND (otherkey% AND 3) = 0 THEN shx% = 0: shy% = 0: PutText: DCursor 0
IF cmd$ <> "" THEN elapsedtime& = TIMER
SELECT CASE cmd$
CASE IS = CHR$(0) + "I"'page up
KeyTrap$ = "PAGEUP"
CASE IS = CHR$(0) + "Q"'page down
KeyTrap$ = "PAGEDOWN"
CASE IS = CHR$(0) + "H"'up
IF otherkey% AND 4 THEN KeyTrap$ = "SCROLL UP"
KeyTrap$ = "UP"
CASE IS = CHR$(0) + "P"'down
IF otherkey% AND 4 THEN KeyTrap$ = "SCROLL DOWN"
KeyTrap$ = "DOWN"
CASE IS = CHR$(0) + "K"'left
KeyTrap$ = "LEFT"
CASE IS = CHR$(0) + "M"'right
KeyTrap$ = "RIGHT"
CASE IS = CHR$(9)'tab
KeyTrap$ = "TAB"
CASE IS = CHR$(8)'backspace
KeyTrap$ = "BACKSPACE"
CASE IS = CHR$(0) + "S"'delete
KeyTrap$ = "DELETE"
CASE IS = CHR$(27)'Escape
KeyTrap$ = "ESCAPE"
CASE IS = CHR$(13)'enter
KeyTrap$ = "ENTER"
CASE IS = CHR$(7)
CASE IS = CHR$(10)
CASE IS = CHR$(11)
CASE IS = CHR$(12)
CASE IS = CHR$(28)
CASE ELSE
KeyTrap$ = cmd$
END SELECT
END FUNCTION
SUB LoadProg
'SET VARIABLES:
FileName$ = "UNTITLED DOCUMENT"
FOR i% = 0 TO 59'random document... Replace later w/ strings of 80 " "s.
FOR s% = 1 TO 80
page$(i%) = page$(i%) + CHR$(INT(RND * 200) + 56)
NEXT s%, i%
pstart% = 0
p% = 20
oldcolor% = 63'cursor color stuff...
'SET UP SCREEN, MOUSE, ETC.:
SCREEN 0
CLS
VIEW PRINT 1 TO 25
regs.ax = 1'turn on mouse
CALL interrupt(&H33, regs, regs)
DrawWindow'draw the border and stuff for the editor.
END SUB
SUB Main
regs.ax = 1
CALL interrupt(&H33, regs, regs)
DO
cmd$ = KeyTrap$
MouseTrap
DrawHBar
Respond cmd$
'put cursor position at the bottom:
COLOR 7, 1
LOCATE 24, 69
PRINT mex%;
LOCATE , 77
PRINT mey%;
LOOP
regs.ax = 2
CALL interrupt(&H33, regs, regs)
END SUB
SUB Menu
10 PCOPY 0, 1
20 COLOR 7, 0
IF options% = 0 THEN DFile
IF options% = 1 THEN DEdit
IF options% = 2 THEN DView
IF options% = 3 THEN DSearch
IF options% = 4 THEN DTools
IF options% = 5 THEN DSettings
IF options% = 6 THEN DHelp
DrawHBar
IF selects% > maxselects% THEN selects% = 0
IF selects% < 0 THEN selects% = maxselects%
FOR i% = cellstart% TO cellstart% + cellwidth%
DEF SEG = &HB800
POKE ((selects% + 3) * 80 + i% - 1) * 2 + 1, 112
NEXT i%
regs.ax = 1
CALL interrupt(&H33, regs, regs)
DO
cmd$ = KeyTrap$
regs.ax = 3
CALL interrupt(&H33, regs, regs)
'clicking off of the menu
DEF SEG = &HB800
whatever% = PEEK(((regs.dx \ 8) * 80 + regs.cx \ 8) * 2 + 1)
IF (regs.bx AND 1) = 1 AND whatever% = 64 THEN cmd$ = "ESCAPE"
'clicking on a menu option
IF (whatever% = 112 OR whatever% = 7) AND (regs.bx AND 1) = 1 AND regs.dx > 8 THEN
selects% = regs.dx \ 8 - 3
cmd$ = "ENTER"
END IF
'selecting another menu option thing.
IF (regs.bx AND 1) = 1 AND regs.cx < 384 AND regs.dx = 8 THEN options% = regs.cx \ 64: cmd$ = "CLICK"
IF (regs.bx AND 1) = 1 AND regs.dx = 8 AND regs.cx > 568 THEN options% = 6: cmd$ = "CLICK"
LOOP UNTIL cmd$ <> ""
regs.ax = 2
CALL interrupt(&H33, regs, regs)
SELECT CASE cmd$
CASE "UP"
selects% = selects% - 1
GOTO 20
CASE "DOWN"
selects% = selects% + 1
GOTO 20
CASE "LEFT"
IF options% > 0 THEN options% = options% - 1
CASE "RIGHT"
IF options% < 6 THEN options% = options% + 1
CASE "ESCAPE"
PCOPY 1, 0
EXIT SUB
CASE "ENTER"
DoCommand options%
PCOPY 1, 0
PutText
EXIT SUB
END SELECT
PCOPY 1, 0
GOTO 10
END SUB
SUB MouseTrap
COLOR 15, 3
regs.ax = 3
CALL interrupt(&H33, regs, regs)
IF regs.bx AND 1 THEN cmd$ = "CLICK"
IF regs.dx = 184 THEN HelpBar$ = "STATUSBAR->Click to change location or rename a file. "
IF regs.dx = 0 THEN HelpBar$ = "TITLEBAR" + STRING$(71, " ")
IF shx% = 0 AND regs.dx > 8 AND regs.dx < 184 THEN HelpBar$ = "DOCUMENT->View or edit an opened file here. "
DEF SEG = &HB800
IF regs.cx = 632 AND regs.dx > 8 AND regs.dx < 184 THEN
IF shx% = 0 THEN HelpBar$ = "SCROLLBAR->Use to scroll up or down the page. "
regs.ax = 2
CALL interrupt(&H33, regs, regs)
IF PEEK(479) <> 112 THEN DrawScrolls 80, 3, 23, INT(.3167 * pstart%) + 4, 6
regs.ax = 1
CALL interrupt(&H33, regs, regs)
ELSEIF PEEK(479) = 112 THEN
IF shx% = 0 THEN HelpBar$ = STRING$(79, " ")
regs.ax = 2
CALL interrupt(&H33, regs, regs)
FOR i% = pstart% TO p%
LOCATE i% - pstart% + 3, 80
PRINT RIGHT$(page$(i%), 1);
NEXT i%
regs.ax = 1
CALL interrupt(&H33, regs, regs)
END IF
'scroll up button
IF (regs.bx AND 1) = 1 AND regs.cx = 632 AND regs.dx = 16 AND pstart% > 0 AND shx% = 0 AND ScrollTime! + .1 < TIMER THEN
pstart% = pstart% - 1
p% = p% - 1
PutText
ScrollTime! = TIMER
END IF
'scroll down button
IF (regs.bx AND 1) = 1 AND regs.cx = 632 AND regs.dx = 176 AND p% < 59 AND shx% = 0 AND ScrollTime! + .1 < TIMER THEN
pstart% = pstart% + 1
p% = p% + 1
PutText
ScrollTime! = TIMER
END IF
'clicking on the scroll bar thing
IF (regs.bx AND 1) = 1 AND regs.cx = 632 AND regs.dx > 16 AND regs.dx < 176 AND shx% = 0 THEN
pstart% = (regs.dx \ 8 - 3) * 3.1579
IF pstart% > 39 THEN pstart% = 39
p% = pstart% + 20
PutText
END IF
IF regs.dx = 8 THEN HelpBar$ = "MENU BAR->Click on an option to bring down a menu. "
IF regs.dx = 8 AND (regs.bx AND 1) THEN cmd$ = "ALT"
IF (regs.bx AND 1) = 1 AND regs.dx > 8 AND regs.dx < 184 AND regs.cx < 632 THEN
DCursor 1
mex% = regs.cx \ 8
mey% = regs.dx \ 8 - 2 + pstart%
DEF SEG = &H40
IF shx% > 0 AND (PEEK(&H17) AND 3) = 0 THEN shx% = 0: shy% = 0: PutText
END IF
'now if any of the scrolling stuff messed up the mey, pstart, etc.,
'fix it:
IF mey% > p% THEN mey% = p%
IF mey% < pstart% THEN mey% = pstart%
END SUB
SUB MSDOSPrompt
COLOR 7, 0
CLS
COLOR 3, 1
PRINT "Ú"; STRING$(32, "Ä");
COLOR 0, 7
PRINT "MS-DOS Prompt";
COLOR 3, 1
PRINT STRING$(33, "Ä"); "¿"
PRINT "³"; STRING$(78, " "); "³"
PRINT "À"; STRING$(78, "Ä"); "Ù"
COLOR 15
LOCATE 2, 2
PRINT "Type "; CHR$(34);
COLOR 7
PRINT "EXIT";
COLOR 15
PRINT CHR$(34); " to return to Text Editor 2004."
SHELL
END SUB
SUB Prompt (question$, answer$)
COLOR 3, 1
'locate 13
LOCATE 7, 3
PRINT "Ú"; STRING$(73, "Ä");
COLOR 14, 1
PRINT CHR$(15);
COLOR 3, 1
PRINT "¿";
30 regs.ax = 1
CALL interrupt(&H33, regs, regs)
DO
cmd$ = INKEY$
regs.ax = 3
CALL interrupt(&H33, regs, regs)
IF regs.cx = 608 AND regs.dx = 48 THEN click$ = "C"
IF SCREEN(25, 2) <> 32 THEN HelpBar$ = STRING$(78, " ")
IF regs.cx = 608 AND regs.dx = 48 THEN HelpBar$ = "EXIT->Click this to close this dialogue box. "
IF regs.dx = 64 AND regs.cx > 128 AND regs.cx < 160 THEN HelpBar$ = "YES->Select Yes as your answer to the question being asked. ": click$ = "Y"
IF regs.dx = 64 AND (regs.cx = 256 OR regs.cx = 264) THEN HelpBar$ = "NO->Select No as your answer to the question being asked. ": click$ = "N"
IF regs.dx = 64 AND regs.cx > 344 AND regs.cx < 400 THEN HelpBar$ = "CANCEL->Cancel what you did that caused this prompt to appear. ": click$ = "C"
IF regs.dx = 64 AND regs.cx > 464 AND regs.cx < 504 THEN HelpBar$ = "Help->Display help for this dialogue box. ": click$ = "H"
DrawHBar
IF click$ <> "" AND (regs.bx AND 1) THEN cmd$ = click$
LOOP UNTIL cmd$ <> ""
elapsedtime& = TIMER
DO
regs.ax = 3
CALL interrupt(&H33, regs, regs)
LOOP UNTIL regs.bx = 0
regs.ax = 2
CALL interrupt(&H33, regs, regs)
SELECT CASE UCASE$(cmd$)
CASE "Y"
answer$ = "Y"
EXIT SUB
CASE CHR$(13)
answer$ = "Y"
EXIT SUB
CASE "N"
answer$ = "N"
EXIT SUB
CASE "C"
answer$ = "C"
EXIT SUB
CASE "ESCAPE"
answer$ = "C"
EXIT SUB
CASE "H"
answer$ = "H"
EXIT SUB
END SELECT
GOTO 30
END SUB
SUB PutText
COLOR 15, 3
FOR i% = pstart% TO p%
LOCATE i% - pstart% + 3, 1
PRINT page$(i%);
NEXT i%
END SUB
SUB Respond (cmd$)
IF shx% > 0 THEN HelpBar$ = "SELECT TEXT->Click mouse to highlight to mouse pointer or use arrows to select."
IF cmd$ = "" THEN EXIT SUB
regs.ax = 2
CALL interrupt(&H33, regs, regs)
COLOR 15, 3
DCursor 0
SELECT CASE cmd$
CASE "ALT"
Menu
CASE "DOWN"
DCursor 1
mey% = mey% + 1
CASE "UP"
DCursor 1
mey% = mey% - 1
CASE "RIGHT"
DCursor 1
mex% = mex% + 1
CASE "LEFT"
DCursor 1
mex% = mex% - 1
CASE "TAB"
DCursor 1
FOR i% = 0 TO 16
IF mex% < i% * 5 THEN mex% = i% * 5: EXIT FOR
NEXT i%
CASE "BACKSPACE"
page$(mey%) = LEFT$(page$(mey%), mex%) + " " + RIGHT$(page$(mey%), 79 - mex%)
mex% = mex% - 1
PutText
CASE "DELETE"
IF shx% > 0 THEN
x% = mex%
IF x% < shx% THEN SWAP shx%, x%: shx% = shx% + 1: x% = x% - 1
FOR y% = shy% - pstart% TO mey% - pstart% STEP SGN(mey% - shy%) OR 1
page$(y%) = LEFT$(page$(y%), shx% - 1) + STRING$(x% - shx% + 2, " ") + RIGHT$(page$(y%), 79 - x%)
NEXT y%
END IF
page$(mey%) = LEFT$(page$(mey%), mex%) + " " + RIGHT$(page$(mey%), 79 - mex%)
PutText
CASE "CLICK"
CASE ELSE
shx% = 0
page$(mey%) = LEFT$(page$(mey%), mex%) + cmd$ + RIGHT$(page$(mey%), 79 - mex%)
mex% = mex% + 1
PutText
END SELECT
IF mex% = 80 THEN mex% = 0: mey% = mey% + 1
IF mex% = -1 THEN mex% = 79: mey% = mey% - 1
IF mey% = 60 THEN mey% = 59
IF mey% = -1 THEN mey% = 0
IF mey% < pstart% AND shx% = 0 THEN pstart% = mey%: p% = p% - 1: PutText
IF mey% > p% AND shx% = 0 THEN p% = mey%: pstart% = pstart% + 1: PutText
IF mey% < pstart% THEN mey% = pstart%
IF mey% > p% THEN mey% = p%
DCursor 0
regs.ax = 1
CALL interrupt(&H33, regs, regs)
END SUB