======== SPELLING CMDS ======

Start spell-checking mode by loading in the dictionary table.
<rAmiga-u:
    if (!spellerUp 
        & !startSpell(
            "s:Udtable",
            "s:Udict",1)) {
                putMsg("No memory or dictionary not found")
                returnFalse
    }
    putMsg("Speller is up") >

Find first misspelled word, starting at cursor.  Abort with Amiga-ESC.
<rAmiga-c:
    if (not spellerUp) {
        putMsg("Speller not up")
        returnFalse
    }
    putMsg(" ")
    while (not spell(buf54,curFile)) runKey(virtual-z) >

Click word in msg line (buf54), select word to replace word before cursor.
<virtual-z:
    if (isEmpty(buf54)) return
    insertRgn(buf54,efile," ***",all)
    putMsg(buf54)
    vscroll(atCursor)
    updateDisplay
    getKeyVal(n3,n4)
    if (eqNum(n3,normal-esc)) abort
    mousexy(n1,n2)
    while (inputKey(n54)) nothing
    if (mouseDown) while (not inputWaiting) {
        if (not mouseDown) goto label(0)
        inputKey(n54)
    }
    label(0)
    if (geNum(n3,normal-gadget1) & geNum(normal-gadget4,n3) 
                                 & gtNum(n2,10) & gtNum(20,n2)) {
        div(n1,n1,8)
        incNum(n1)
        moveCursor(buf54,sfile)
        moveCursor(buf54,eword)
        locToIndex(buf54,n54,atcursor)
        if (gtNum(n1,n54)) {
            indexToLoc(buf54,atCursor,n1)
            if (is(buf54,alpha)) {
                movecursor(buf54,eword)
                movecursor(buf54,sword)
                movecursor(curfile,sword)
                if (is(curfile,upperCase)) toUpper(buf54)
                clearRgn(curfile,word)
                insertrgn(curfile,atcursor,buf54,word)
            }
        }
    }
    putMsg(" ")
    freeBuf(buf54)
    while (inputKey(n54)) nothing
    if (mouseDown) while (not inputWaiting) {
        if (not mouseDown) return
        inputKey(n54)
    }
>

Spell-check from cursor fwd.  Mark bad words with "@".
<rAmiga-m:
    if (not runKey(rAmiga-u)) returnFalse
    putMsg("Spell checking ... abort with Amiga-ESC")
    while (not spell(" ",curFile)) insertChar(curFile,"@") >

Force file saving to finish so buffer is unlocked
<104: while (getStackSize(n99,n99,n98) & gtNum(n98,0)) delay(5) >

Load supplemental dictionary & spell from cursor fwd.  Add to supplement.
<rAmiga-l:
    if (not runKey(rAmiga-u)) returnFalse
    equateNum(n54,curFile)
    putMsg("Dict supplement to use (pmESC = UdSupplement)")
    freebuf(buf54)
    equateNum(n99,0)
    if (inputString(buf54))  {
       if (not loadFile(buf54)) goto label(3)
    } else {
label(3)
        if (not loadFile("UdSupplement")) {
            if (not newFile) {
                putMsg("Close a file for me!")
                returnFalse
            }
            setFileName(curfile,"UdSupplement")
        }
    }
    putMsg("Spell checking ... abort with Amiga-ESC")
    if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
label(0)
    while (not spell(" ",buf[n54])) {
        moveCursor(buf[n54],sWord)
        freeBuf(buf54)
        insertRgn(buf54,eFile,buf[n54],word)
        moveCursor(buf[n54],eWord)
        moveCursor(buf54,sFile)
        if (not is(buf54,"'") & not is(buf54,alpha)) goto label(0)
        moveCursor(buf54,eFile)
        putMsg(buf54)                              .. remove for faster speed
        insertChar(buf54,eLine)
        moveCursor(curFile,eFile)
label(4)             .. could remove this block but it helps hugely in speed.
        setSearch(buf54)
        if (search(curFile,locA,locB,-1)) {
            if (is(curFile,sWord)) goto label(0)
            moveCursor(curFile,sWord)
            goto label(4)
        }
        moveCursor(buf54,sChar)
        clearChar(buf54)                                      .. remove eline
        
        ..  this sect for speed
        moveCursor(buf54,sFile)
        copyChar(buf54,n47)                          .. copy 1st char of word
        freeBuf(buf52)
        insertChar(buf52,eLine)                      .. load in eline-1stchar
        insertChar(buf52,n47)
        moveCursor(curFile,eFile)                .. search for starting place
        setSearch(buf52)
        search(curfile,locA,locB,-1)
        moveCursor(curFile,eWord)                 .. move fwd, so sWord works
        if (is(curFile,sFile)) goto label(1)
        while (nothing) {
            moveCursor(curFile,sWord)
            freeBuf(buf53)
            insertRgn(buf53,eFile,curFile,word)
            stringComp(n53,buf54,buf53,1)                      .. ignore case
            if (eqNum(n53,0)) goto label(0)             .. found it, continue
            if (gtNum(n53,0)) {
 label(1)
                moveCursor(curFile,eWord)
                moveCursor(curFile,eChar)
 label(2)
                insertRgn(curFile,atCursor,buf54,all)
                insertChar(curFile,eLine)
                updateDisplay                      .. remove for faster speed
                incNum(n99)
                if (gtNum(n99,19)) {
                    fileSize(curFile,n99)             .. force buffer packing
                    equateNum(n99,0)
                }
                goto label(0)
            }
            if (is(curFile,sFile)) goto label(2)
        }
    }
    moveCursor(curFile,sFile)
    putMsg("These words weren't in dictionary")
    .. stopSpell                               .. use if want speller removed
    >

Merge dict supplement with dict-files.  dict.A-Z must be in Current Directory.
<rAmiga-d:
    if (isEmpty(curFile)) returnFalse
    moveCursor(curFile,sFile)
    freeBuf(buf52)
    freeBuf(buf54)
    insertRgn(buf54,eFile,"dh0:spell/private/dict. ",all)
    if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
    equateNum(n50,0)
    while (nothing) {
        moveCursor(curFile,eWord)
        moveCursor(curFile,sWord)
        freeBuf(buf53)
        if (not insertRgn(buf53,eFile,curFile,word)) {
label(6)    if (getFlag(buf52,changed)) saveFile(buf52)
            runKey(104)                             .. force save to complete
            goto label(0)
        }
        moveCursor(buf53,sFile)
        toUpper(buf53)
        copyChar(buf53,n54)                    .. copy 1st letter of word A-Z
        toLower(buf53)
        if (eqNum(n54,39)) equateNum(n54,65)             .. apost becomes 'A'
        else {
            if (gtNum(n54,90)) goto label(1)                   .. must be A-Z
            if (gtNum(65,n54)) goto label(1)
        }
        moveCursor(buf54,eFile)
        moveCursor(buf54,sChar)
        swapChar(buf54,n54)                          .. make it "dict.A" etc.
        
        if (not eqNum(n54,n50)) {
            if (not eqNum(n50,0)
                & getFlag(buf52,changed)) saveFile(buf52)
            runKey(104)                             .. force save to complete
            clearRgn(buf52,all)
            fileSize(buf52,n49)                        .. make it pack buffer
            if (not insertFile(buf52,eFile,buf54)) {
                putMsg("Can't find dict.A-Z!")
                returnFalse
            }
            setFileName(buf52,buf54)
            if (getFlag(buf52,changed)) flipFlag(buf52,changed)
            equateNum(n50,n54)                            .. save dict-letter
        }
        .. put word in dict.
        moveCursor(buf53,eFile)
        putMsg(buf53)
        insertChar(buf53,eLine)
        moveCursor(buf52,eFile)
label(2)
        setSearch(buf53)
        if (search(buf52,locA,locB,-1)) {
            if (is(buf52,sWord)) goto label(1)
            goto label(2)                               .. continue searching
        }
        .. didn't find it.  Do the slow scan & insert the word.
        moveCursor(buf53,eFile)
        moveCursor(buf53,sChar)
        clearChar(buf53)                                      .. remove eLine
        moveCursor(buf52,eFile)
        equateNum(n49,1)
label(4)
        while (nothing) {
            if (eqNum(n49,1)) do(n48,1,40) moveCursor(buf52,sWord)
            moveCursor(buf52,sWord)
            freeBuf(buf51)
            insertRgn(buf51,eFile,buf52,word)
            stringComp(n53,buf53,buf51,1)                      .. ignore case
            if (eqNum(n53,0)) goto label(1)             .. found it, continue
            if (gtNum(n53,0)) {
                if (eqNum(n49,1)) goto label(5)
                moveCursor(buf52,eWord)
                moveCursor(buf52,eChar)
label(3)
                insertRgn(buf52,atCursor,buf53,all)
                insertChar(buf52,eLine)
                goto label(1)
            }
            if (is(buf52,sFile)) {
                if (eqNum(n49,1)) {
label(5)
                    equateNum(n49,0)
                    do (n48,1,41) moveCursor(buf52,eWord)
                    goto label(4)
                }
                goto label(3)
            }
        }

label(1) .. next word
        moveCursor(curFile,eLine)
        moveCursor(curFile,eChar)
        updateDisplay
        if (is(curFile,eFile)) goto label(6)
    }
label(0)
    putMsg("Done.  Run Udbuild to rebuild working dict & table")
    freeBuf(buf52)
>

Remove words from dict-files.  dict.A-Z must be in Current Directory.
<rAmiga-e:
    if (isEmpty(curFile)) returnFalse
    moveCursor(curFile,sFile)
    freeBuf(buf52)
    freeBuf(buf54)
    insertRgn(buf54,eFile,"dicts/dict. ",all)
    if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
    equateNum(n50,0)
    while (nothing) {
        moveCursor(curFile,eWord)
        moveCursor(curFile,sWord)
        freeBuf(buf53)
        if (not insertRgn(buf53,eFile,curFile,word)) {
label(6)
                if (getFlag(buf52,changed)) saveFile(buf52)
                runKey(104)                         .. force save to complete
                goto label(0)
        }
        moveCursor(buf53,sFile)
        toUpper(buf53)
        copyChar(buf53,n54)                    .. copy 1st letter of word A-Z
        toLower(buf53)
        if (eqNum(n54,"'")) equateNum(n54,"A")           .. apost becomes 'A'
        else {
            if (gtNum(n54,"Z")) goto label(1)                  .. must be A-Z
            if (gtNum(65,n54)) goto label(1)
        }
        moveCursor(buf54,eFile)
        moveCursor(buf54,sChar)
        swapChar(buf54,n54)                          .. make it "dict.A" etc.
        
        if (not eqNum(n54,n50)) {
            if (not eqNum(n50,0) & getFlag(buf52,changed)) saveFile(buf52)
            runKey(104)                             .. force save to complete
            clearRgn(buf52,all)
            fileSize(buf52,n49)                        .. make it pack buffer
            if (not insertFile(buf52,eFile,buf54)) {
                putMsg("Can't find dict.A-Z!")
                returnFalse
            }
            setFileName(buf52,buf54)
            if (getFlag(buf52,changed)) flipFlag(buf52,changed)
            equateNum(n50,n54)                            .. save dict-letter
        }
        .. remove word from dict.
        moveCursor(buf53,eFile)
        putMsg(buf53)
        insertChar(buf53,eLine)
        moveCursor(buf52,eFile)
label(2)
        setSearch(buf53)
        if (search(buf52,locA,locB,-1)) {
            if (is(buf52,sWord)) {
                clearRgn(buf52,loc)
                goto label(1)                                    .. next word
            }
            goto label(2)                               .. continue searching
        }

label(1) .. next word
        moveCursor(curFile,eLine)
        moveCursor(curFile,eChar)
        if (is(curFile,eFile)) goto label(6)
        updateDisplay
    }
label(0)
    putMsg("Done.  Run Udbuild to rebuild working dict & table")
    freeBuf(buf52)
>

Stop spell-checking mode.  (Frees up about 12k of memory.)
<rAmiga-f: if (spellerUp) { stopSpell putMsg("Speller removed") } >

========== Split Windows =========

Remove current split window
<lAmiga-0: splitWindow(curFile,0)>

Split window to show current file
<lAmiga-c: splitWindow(curFile,splitSize)>

Split window to show Undo buffer
<lAmiga-1: splitWindow(buf45,splitSize)>

Split window to show search buffer
<lAmiga-2: splitWindow(buf49,splitSize)>

Split window to show replace buffer
<lAmiga-3: splitWindow(buf48,splitSize)>

Split window to show copied-hilite buffer
<lAmiga-4: splitWindow(buf47,splitSize)>

Split window to show copied-invert buffer
<lAmiga-5: splitWindow(buf46,splitSize)>

Split window to show copied-columnar buffer
<lAmiga-6: splitWindow(buf37,splitSize)>

Split window to show directory names
<lAmiga-7: splitWindow(buf38,splitSize) >

Set split window size
<lAmiga-8:
    putMsg("# lines in split window (2 or more):")
    if (inputNum(n54) & geNum(n54,2)) equateNum(splitSize,n54)
    putMsg(" ")>

Switch to next window split
<lAmiga-9: toggle(windowSplit)>

