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

Close hyper text facility
<lAmiga-gadget4: HyperClose >

Get word input and lookup hyper word, going into hyper text mode
<lAmiga-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
<lAmiga-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)
    }
>

Hyper lookup mode  .. <hyper word> is in buf54, index is in n93
<virtual-gadget2:
    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("lAmiga-mouse or F1-F9=select  Arrows=cursor  F6=history  ESC=quit")

    while (mouseDown) inputKey(n54)
    getKeyVal(macroNum,inputChar)
    if (eqNum(inputChar,10)) {
        equateLoc(curfile,mouseloc,atcursor)
        runkey(virtual-gadget1)
        goto label(96)
    }
    switch(macroNum) {
        case(normal-esc) {
            gotoSplit(buf[n92])
            splitWindow(buf53,0)      .. close it if made it
            freeBuf(buf54)
            freeBuf(buf53)
            putmsg(" ")
            return
        }
        case(normal-buttonDown) {                   .. done bring down window
            moveCursor(curFile,mouseLoc)
            updateDisplay
            mouseXY(n0,n1)
            equateNum(n4,0)
            if (mouseDown) while (not inputWaiting) {
                trackMouse
                mouseXY(n2,n3)
                sub(n3,n3,n1)
                div(n3,n3,5)
                if (!eqNum(n3,0)) {
                  vscroll(n3) 
                  updateDisplay
                  equateNum(n4,1)
                }
            }
            if (eqNum(n4,1)) refreshdisplay
            goto label(98)
        }
        case(lAmiga-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,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
            if (runKey(lAmiga-gadget1)) 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) }
    }
    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 replace & search forward
<lAmiga-f10: equateNum(n54,2)
            runKey(virtual-f10)
            >

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

Goto next bookmark
<shft-gadget1:
    incNum(n94)
    if (gtNum(n94,7)) equateNum(n94,0)
    runKey(virtual-gadget1)
>

Goto previous bookmark
<shft-gadget2:
    decNum(n94)
    if (gtNum(0,n94)) equateNum(n94,7)
    runKey(virtual-gadget1)
>

Store bookmark at cursor
<shft-gadget3:
    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:
    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)  }
    }
>

