
Open hyper text facility for HyperHelp
<rAmiga-gadget3:	if (HyperOpen("HyperSample","HyperSample.tbl",0)) {
						putmsg("Hyper text loaded")
						equateNum(n93,0)
					} >

Close hyper text facility
<rAmiga-gadget4: HyperClose >

Get word input and lookup hyper word, going into hyper text mode
<rAmiga-gadget1:
	if (!hyperUp) { putMsg("Must open hyper text") returnFalse }
	putmsg("Input hyper word/phrase to look up:")
	freeBuf(buf54)
	inputString(buf54)
	updateDisplay
	runKey(virtual-gadget2)
>

Get hyper word that was clicked, go into hyper text mode & find it
<rAmiga-buttondown:
	if (!hyperUp) { putMsg("Must open hyper text") returnFalse }
	runKey(virtual-gadget1)
	runKey(virtual-gadget2)
>

Capture hyper word or phrase
<virtual-gadget1:
	movecursor(curfile,mouseloc)
	if (!is(curfile,sword)) movecursor(curfile,sword)
	while (!is(curfile,"<")
				& !is(curfile,eline)
					& !is(curfile,">")
						& movecursor(curfile,schar)) nothing
	freebuf(buf54)
	if (is(curfile,"<")) { .. copy the hyper phrase
		movecursor(curfile,echar)
		equateNum(n52,0)
		while (nothing) {
			copychar(curfile,n53)
			movecursor(curfile,echar)
			if (eqnum(n53,">")) goto label(0)
			insertchar(buf54,n53)
			incNum(n52)
			if (geNum(n52,17)) goto label(0)
		}
		label(0)
	} else {			  .. copy just the word
		movecursor(curfile,mouseloc)
		if (!is(curfile,sword)) movecursor(curfile,sword)
		insertrgn(buf54,efile,curfile,word)
	}
>

Forbid tiny window
<virtual-menuDown: 
    if (!inTiny) return
    toggle(toTiny)
    refreshDisplay >

Hyper lookup mode  .. <hyper word> is in buf54, index is in n93
<virtual-gadget2:
    runKey(virtual-menuDown)
    if (gtNum(0,n93)) equateNum(n93,0)
	equateNum(n92,curfile)
	if (!hyper(buf53,buf54,n93,0)) {	.. find word starting from n93
		freebuf(buf54)  				.. find word starting from top of table
		if (!hyper(buf53,buf54,0,0)) return
	}
	if (!eqNum(curFile,buf53) & !gotoSplit(buf53)) {
		if (!splitWindow(buf53,12)) {
			putMsg("Close a split window so can bring up hyper text")
			return
		}
	}
	refreshdisplay
label(98)
	putMsg("rAmiga-mouse or F1-F9=select  Arrows=cursor  F6=history  ESC/closeBox=quit")

    runKey(virtual-menuDown)
	while (mouseDown) inputKey(n54)
	getKeyVal(macroNum,inputChar)
    runKey(virtual-menuDown)
	if (eqNum(inputChar,10)) {
		equateLoc(curfile,mouseloc,atcursor)
		runkey(virtual-gadget1)
		goto label(96)
	}
    runKey(virtual-menuDown)
	switch(macroNum) {
		case(normal-closeBox)
		case(normal-esc) {
			gotoSplit(buf[n92])
			splitWindow(buf53,0)	  .. close it if made it
			freeBuf(buf54)
			freeBuf(buf53)
			putmsg(" ")
			return
		}
		case(normal-buttonDown) {					.. scroll, place cursor
            runKey(virtual-menuDown)
			moveCursor(curFile,mouseLoc)
			updateDisplay
			mouseXY(n0,n1)
			equateNum(n4,0)
			if (mouseDown) while (not inputWaiting) {
                runKey(virtual-menuDown)
				trackMouse
				mouseXY(n2,n3)
				sub(n3,n3,n1)
				div(n3,n3,5)
				if (!eqNum(n3,0)) {
				  vscroll(n3)
				  updateDisplay
				  equateNum(n4,1)
				}
			}
            runKey(virtual-menuDown)
			if (eqNum(n4,1)) refreshdisplay
			goto label(98)
		}
		case(rAmiga-buttonDown) {
			runKey(virtual-gadget1)
label(96)
			if (gtNum(0,n93)) equateNum(n93,0)
			if (eqNum(0,n93)) {
label(97)						.. try from top of table
				if (!hyper(buf52,buf54,n93,0)) goto label(98)
			} else {			.. try algorithm
				if (..!hyper(buf52,buf54,n93,1)
                    ..&
                    !hyper(buf52,buf54,n93,2)) goto label(97)
			}
		}
		case(normal-f1) {
			freeBuf(buf54)
			equateNum(n93,0)			.. set index to 0 for top of tree
			if (!hyper(buf52,buf54,n93,0))    .. goto index word (top of tree)
				goto label(98)
		}
		case(normal-f2) {
			freebuf(buf54)
			if (!hyper(buf52,buf54,n93,1))    .. goto parent of n93
				goto label(98)
		}
		case(normal-f3) {
			freebuf(buf54)
			if (!hyper(buf52,buf54,n93,2))    .. goto child of n93
				goto label(98)
		}
		case(normal-f4) {
			freebuf(buf54)
			if (!hyper(buf52,buf54,n93,3))     .. goto next sibling of n93
				goto label(98)
		}
		case(normal-f5) {
			freebuf(buf54)
			if (!hyper(buf52,buf54,n93,4))     .. goto prev sibling of n93
				goto label(98)
		}
		case(normal-f6) {
			freebuf(buf54)
			if (!hyper(buf52,buf54,n93,5))     .. goto last lookup
				goto label(98)
		}
		case(normal-f7) {				.. get hyper word input
	        putmsg("Input hyper word/phrase to look up:")
        	freeBuf(buf54)
            runKey(virtual-menuDown)
        	inputString(buf54)
            runKey(virtual-menuDown)
        	updateDisplay
			goto label(96)
		}
		case(normal-f8) {				.. get hyper word of next index value
			incNum(n93)
			freebuf(buf54)
			if (!hyper(buf52,buf54,n93,0)) {
				equateNum(n93,0)
				goto label(98)
			}
		}
		case(normal-f9) {				.. get hyper word of prev index value
			if (gtnum(n93,0)) decNum(n93)
			freebuf(buf54)
			if (!hyper(buf52,buf54,n93,0))
				goto label(98)
		}
		case(normal-uparrow) {
			movecursor(curfile,upline)
			updatedisplay
			goto label(98)
		}
		case(normal-downarrow) {
			movecursor(curfile,downline)
			updatedisplay
			goto label(98)
		}
		case(normal-leftarrow) {
			movecursor(curfile,sWord)
			updatedisplay
			goto label(98)
		}
		case(normal-rightarrow) {
			movecursor(curfile,eWord)
			updatedisplay
			goto label(98)
		}
		default { goto label(98) }
	}
    runKey(virtual-menuDown)
	swapbuf(buf52,buf53)
	refreshdisplay
	goto label(98)
>

Set grep (/search/replace/) string
<lAmiga-f7:
	putMsg("Input grep string:")
	getGrep(buf49)
	movecursor(buf49,sfile)
	movecursor(buf49,echar)
	inputString(buf49)
	setGrep(buf49)
	runKey(lAmiga-f9) >

Called by grep cmds to perform grep based on n54 flag
<virtual-f10:	if (!grep(curFile,invert,n54)) {
					putMsg("Search failed")
					returnFalse
				} else putMsg(" ") >

Grep search forward
<lAmiga-f9: equateNum(n54,1)
			runKey(virtual-f10)
			>

Grep search backward
<rAmiga-f9:  equateNum(n54,-1)
			 runKey(virtual-f10)
			 >

Grep search & replace forward
<lAmiga-f10: equateNum(n54,2)
			runKey(virtual-f10)
			>

Grep search & replace backward
<rAmiga-f10:  equateNum(n54,-2)
			 runKey(virtual-f10)
			 >

Goto next bookmark
<shft-gadget1:
    runKey(virtual-gadget4) .. fill buf60 with mark names if empty
	incNum(n94)
	if (gtNum(n94,7)) equateNum(n94,0)
	runKey(virtual-gadget3) >

Goto previous bookmark
<shft-gadget2:
    runKey(virtual-gadget4) .. fill buf60 with mark names if empty
	decNum(n94)
	if (gtNum(0,n94)) equateNum(n94,7)
	runKey(virtual-gadget3) >

Store bookmark at cursor
<shft-gadget3:
    runKey(virtual-gadget4) .. fill buf60 with mark names if empty

    while(mouseDown) inputKey(n54)
    inputKey(n54)

    .. get new bookmark name
    moveCursor(buf60,sFile)
    do (n54,0,n94) moveCursor(buf60,eLine)
    moveCursor(buf60,sLine)
    
    freeBuf(buf53)
    insertRgn(buf53,eFile,buf60,line)
    putMsg("Enter bookmark name:")
    inputString(buf53)
    fileSize(buf53,n54)
    if (eqNum(n54,0)) {
        insertRgn(buf53,eFile,"BookMark-",all)
        toWord(buf53,n94)
    }
    clearRgn(buf60,line)
    moveCursor(buf53,sFile)
    insertRgn(buf60,atCursor,buf53,line)
    
    freebuf(buf54)
    insertrgn(buf54,atcursor,"Mark = ",all)
    insertRgn(buf54,eFile,buf53,line)
    putmsg(buf54)

	switch(n94) {
		case (0) { equateLoc(curFile,locC,atCursor)  }
		case (1) { equateLoc(curFile,locD,atCursor)  }
		case (2) { equateLoc(curFile,locE,atCursor)  }
		case (3) { equateLoc(curFile,locF,atCursor)  }
		case (4) { equateLoc(curFile,locG,atCursor)  }
		case (5) { equateLoc(curFile,locH,atCursor)  }
		case (6) { equateLoc(curFile,locI,atCursor)  }
		case (7) { equateLoc(curFile,locJ,atCursor)  }
	}
	incNum(n94)
	if (gtNum(n94,7)) equateNum(n94,0)
>

Used by bookmark cmds to move the cursor
<virtual-gadget3:
    
    moveCursor(buf60,sFile)
    do (n54,0,n94) moveCursor(buf60,eLine)
    moveCursor(buf60,sLine)
    freebuf(buf54)
    insertRgn(buf54,eFile,buf60,line)
    putmsg(buf54)
    
	switch(n94) {
		case (0) { moveCursor(curFile,locC)  }
		case (1) { moveCursor(curFile,locD)  }
		case (2) { moveCursor(curFile,locE)  }
		case (3) { moveCursor(curFile,locF)  }
		case (4) { moveCursor(curFile,locG)  }
		case (5) { moveCursor(curFile,locH)  }
		case (6) { moveCursor(curFile,locI)  }
		case (7) { moveCursor(curFile,locJ)  }
	} >

Reset all bookmarks to sFile
<shft-gadget4:
    putmsg("Bookmarks reset")
    freeBuf(buf60)
    runKey(virtual-gadget4) .. fill buf60 with mark names if empty
    equateLoc(curfile,locC,sFile)
    equateLoc(curfile,locD,eFile)
    equateLoc(curfile,locE,sHilite)
    equateLoc(curfile,locF,eHilite)
    equateLoc(curfile,locG,sInvert)
    equateLoc(curfile,locH,eInvert)
    equateLoc(curfile,locI,locA)
    equateLoc(curfile,locJ,locB)
    equateNum(n94,0)
>

Put dummy bookmark names in buf60
<virtual-gadget4:
    if (!isEmpty(buf60)) return     .. use the names already in buf60
    insertRgn(buf60,eFile,
"Start of File
End of File
Start of Hilite
End of Hilite
Start of Invert
End of Invert
locA
locB
",all)
>
