-----------------------------------------------------------------------------
|							  Config!S										|
|		 Copyright (C) 1986-92 Rick Stiles.  All rights reserved.			|
-----------------------------------------------------------------------------

*************************************
N-variables used:
n0-n13  scratch numbers

Buffers used:
buf51-54	scratch buffers
buf37	copied columnar text
buf38	directory names
buf41	swap buf
buf45	UNDO buffer
buf46	invert buf
buf47	hilite buf
buf48	replace text
buf49	search string

*************************************

<defines:
define(N_0 ,n0)
define(N_1 ,n1)
define(N_2 ,n2)
define(N_3 ,n3)
define(N_4 ,n4)
define(N_5 ,n5)
define(N_6 ,n6)
define(N_7 ,n7)
define(N_8 ,n8)
define(N_9 ,n9)
define(N_10 ,n10)
define(N_11 ,n11)
define(N_12 ,n12)
define(N_13 ,n13)
define(B_1 ,buf51)
define(B_2 ,buf52)
define(B_3 ,buf53)
define(B_4 ,buf54)
define(COLUMNAR_BUF ,buf37)
define(DIR_NAMES ,buf38)
define(SWAP_BUF ,buf41)
define(UNDO_BUF ,buf45)
define(INVERT_BUF ,buf46)
define(HILITE_BUF ,buf47)
define(REPLACE_TXT ,buf48)
define(SEARCH_STR ,buf49)

define(Eat_MouseUp_Input ,624)
>


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

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

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(B_4,curFile,SWAP_BUF)) runKey(virtual-z) >

Click word in msg line (B_4), select word to replace word before cursor.
<virtual-z:
	if (isEmpty(B_4)) return
	insertRgn(B_4,efile," ***",all)
	putMsg(B_4)
	vscroll(atCursor)
	updateDisplay
	getKeyVal(N_9,N_6)
	if (eqNum(N_9,normal-esc)) abort
	mousexy(N_7,N_8)
	runKey(Eat_MouseUp_Input)					  .. soak mouseUp
	if (geNum(N_9,normal-gadget1) & geNum(normal-gadget4,N_9)
								 & gtNum(N_8,10) & gtNum(20,N_8)) {
		div(N_7,N_7,8)
		incNum(N_7)
		moveCursor(B_4,sfile)
		moveCursor(B_4,eword)
		locToIndex(B_4,N_4,atcursor)
		if (gtNum(N_7,N_4)) {
			indexToLoc(B_4,atCursor,N_7)
			if (is(B_4,alpha)) {
				movecursor(B_4,eword)
				movecursor(B_4,sword)
				movecursor(curfile,sword)
				if (is(curfile,upperCase)) toUpper(B_4)
				clearRgn(curfile,word)
				insertrgn(curfile,atcursor,B_4,word)
				updateDisplay
			}
		}
	}
	putMsg("")
	freeBuf(B_4)
	runKey(Eat_MouseUp_Input)					  .. soak mouseUp
>

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,SWAP_BUF)) insertChar(curFile,"@") >

Force file saving to finish so buffer is unlocked
<104:
	push(N_9,N_9)
	push(N_9,N_8)
	while (getStackSize(N_9,N_9,N_8) & gtNum(N_8,0)) delay(5)
	pop(N_9,N_8)
	pop(N_9,N_9)
>

Load supplemental dictionary & spell from cursor fwd.  Add to supplement.
<rAmiga-l:
	if (not runKey(rAmiga-u)) returnFalse
	equateNum(N_4,curFile)
	putMsg("Dict supplement to use (pmESC = UdSupplement)")
	freebuf(B_4)
	equateNum(N_10,0)
	if (inputString(B_4))  {
	   if (not loadFile(B_4)) 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[N_4],curFile)) {
		moveCursor(buf[N_4],sWord)
		freeBuf(B_4)
		insertRgn(B_4,eFile,buf[N_4],word)
		moveCursor(buf[N_4],eWord)
		moveCursor(B_4,sFile)
		if (not is(B_4,"'") & not is(B_4,alpha)) goto label(0)
		moveCursor(B_4,eFile)
		putMsg(B_4)							   .. remove for faster speed

		..  this sect for speed
		moveCursor(B_4,sFile)
		copyChar(B_4,N_11) 						 .. copy 1st char of word
		freeBuf(B_2)
		insertChar(B_2,eLine) 					 .. load in eline-1stchar
		insertChar(B_2,N_11)
		moveCursor(curFile,eFile)				 .. search for starting place
		setSearch(B_2)
		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(B_3)
			insertRgn(B_3,eFile,curFile,word)
			stringComp(N_3,B_4,B_3,1)					   .. ignore case
			if (eqNum(N_3,0)) goto label(0) 			.. found it, continue
			if (gtNum(N_3,0)) {
 label(1)
				moveCursor(curFile,eWord)
				moveCursor(curFile,eChar)
 label(2)
				insertRgn(curFile,atCursor,B_4,all)
				insertChar(curFile,eLine)
				updateDisplay					   .. remove for faster speed
				incNum(N_10)
				if (gtNum(N_10,19)) {
					fileSize(curFile,N_10)			  .. force buffer packing
					equateNum(N_10,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(B_2)
	freeBuf(B_4)
	insertRgn(B_4,eFile,"S:dict. ",all)
	if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
	equateNum(N_0,0)
	while (nothing) {
		moveCursor(curFile,eWord)
		moveCursor(curFile,sWord)
		freeBuf(B_3)
		if (not insertRgn(B_3,eFile,curFile,word)) {
label(6)	if (getFlag(B_2,changed)) saveFile(B_2)
			runKey(104) 							.. force save to complete
			goto label(0)
		}
		moveCursor(B_3,sFile)
		toUpper(B_3)
		copyChar(B_3,N_4) 				   .. copy 1st letter of word A-Z
		toLower(B_3)
		if (eqNum(N_4,39)) equateNum(N_4,65)			 .. apost becomes 'A'
		else {
			if (gtNum(N_4,90)) goto label(1)				   .. must be A-Z
			if (gtNum(65,N_4)) goto label(1)
		}
		moveCursor(B_4,eFile)
		moveCursor(B_4,sChar)
		swapChar(B_4,N_4) 						 .. make it "dict.A" etc.

		if (not eqNum(N_4,N_0)) {
			if (not eqNum(N_0,0)
				& getFlag(B_2,changed)) saveFile(B_2)
			runKey(104) 							.. force save to complete
			clearRgn(B_2,all)
			fileSize(B_2,N_12) 					   .. make it pack buffer
			if (not insertFile(B_2,eFile,B_4)) {
				putMsg("Can't find dict.A-Z!")
				returnFalse
			}
			setFileName(B_2,B_4)
			if (getFlag(B_2,changed)) flipFlag(B_2,changed)
			equateNum(N_0,N_4)  						  .. save dict-letter
		}
		.. put word in dict.
		moveCursor(B_3,eFile)
		putMsg(B_3)
		insertChar(B_3,eLine)
		moveCursor(B_2,eFile)
label(2)
		setSearch(B_3)
		if (search(B_2,locA,locB,-1)) {
			if (is(B_2,sWord)) goto label(1)
			goto label(2)								.. continue searching
		}
		.. didn't find it.  Do the slow scan & insert the word.
		moveCursor(B_3,eFile)
		moveCursor(B_3,sChar)
		clearChar(B_3)									  .. remove eLine
		moveCursor(B_2,eFile)
		equateNum(N_12,1)
label(4)
		while (nothing) {
			if (eqNum(N_12,1)) do(N_13,1,40) moveCursor(B_2,sWord)
			moveCursor(B_2,sWord)
			freeBuf(B_1)
			insertRgn(B_1,eFile,B_2,word)
			stringComp(N_3,B_3,B_1,1)					   .. ignore case
			if (eqNum(N_3,0)) goto label(1) 			.. found it, continue
			if (gtNum(N_3,0)) {
				if (eqNum(N_12,1)) goto label(5)
				moveCursor(B_2,eWord)
				moveCursor(B_2,eChar)
label(3)
				insertRgn(B_2,atCursor,B_3,all)
				insertChar(B_2,eLine)
				goto label(1)
			}
			if (is(B_2,sFile)) {
				if (eqNum(N_12,1)) {
label(5)
					equateNum(N_12,0)
					do (N_13,1,41) moveCursor(B_2,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(B_2)
>

Remove words from dict-files.  dict.A-Z must be in Current Directory.
<rAmiga-e:
	if (isEmpty(curFile)) returnFalse
	moveCursor(curFile,sFile)
	freeBuf(B_2)
	freeBuf(B_4)
	insertRgn(B_4,eFile,"S:dict. ",all)
	if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
	equateNum(N_0,0)
	while (nothing) {
		moveCursor(curFile,eWord)
		moveCursor(curFile,sWord)
		freeBuf(B_3)
		if (not insertRgn(B_3,eFile,curFile,word)) {
label(6)
				if (getFlag(B_2,changed)) saveFile(B_2)
				runKey(104) 						.. force save to complete
				goto label(0)
		}
		moveCursor(B_3,sFile)
		toUpper(B_3)
		copyChar(B_3,N_4) 				   .. copy 1st letter of word A-Z
		toLower(B_3)
		if (eqNum(N_4,"'")) equateNum(N_4,"A")  		 .. apost becomes 'A'
		else {
			if (gtNum(N_4,"Z")) goto label(1)				   .. must be A-Z
			if (gtNum(65,N_4)) goto label(1)
		}
		moveCursor(B_4,eFile)
		moveCursor(B_4,sChar)
		swapChar(B_4,N_4) 						 .. make it "dict.A" etc.

		if (not eqNum(N_4,N_0)) {
			if (not eqNum(N_0,0) & getFlag(B_2,changed)) saveFile(B_2)
			runKey(104) 							.. force save to complete
			clearRgn(B_2,all)
			fileSize(B_2,N_12) 					   .. make it pack buffer
			if (not insertFile(B_2,eFile,B_4)) {
				putMsg("Can't find dict.A-Z!")
				returnFalse
			}
			setFileName(B_2,B_4)
			if (getFlag(B_2,changed)) flipFlag(B_2,changed)
			equateNum(N_0,N_4)  						  .. save dict-letter
		}
		.. remove word from dict.
		moveCursor(B_3,eFile)
		putMsg(B_3)
		insertChar(B_3,eLine)
		moveCursor(B_2,eFile)
label(2)
		setSearch(B_3)
		if (search(B_2,locA,locB,-1)) {
			if (is(B_2,sWord)) {
				clearRgn(B_2,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(B_2)
>

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(UNDO_BUF,splitSize)>

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

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

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

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

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

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

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

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

Adjust active split window size with mouse
<lAmiga-=:
	getSplitLines(N_3,N_2)  						 .. see if is upper split
	if (eqNum(N_3,0)) {
		putMsg("Adjust lower splits, not top one")
		returnFalse 								.. don't size main window
	}
	putMsg("Press button, move mouse to set split window size")
	getkey(N_4)
	if (!mouseDown) return
	mouseXY(N_6,N_5)  					.. N_5 = starting mouseY
	equateNum(N_4,curFile)  			.. N_4 = curfile buf#
	equateNum(N_1,0)

label(0)
		if (inputWaiting) goto label(1)
		trackMouse
		mouseXY(N_8,N_9)  					.. N_9 = current mouseY
		getSplitLines(N_3,N_2)  			.. get start & stop
		sub(N_2,N_2,N_3)					.. N_2 = # lines in curfile split
		if (gtNum(N_5,N_9)) { 				.. if starting mouseY>current mouseY
			if (gtNum(N_3,3)) incNum(N_2)	.. if startline>3 inc #lines in split
			else goto label(0)  			.. else goto top of loop
		}
		else if (gtNum(N_9,N_5)) decNum(N_2)  .. if cur mouseY > start mouseY
											.. decrement #lines in split
		else goto label(0)  				.. if mouseY unchanged goto top
		if (!eqNum(N_5,N_9)) {				.. if start mouseY != cur mouseY
			splitWindow(curFile,0)  		.. TERMINATE current split
			if (gtNum(2,N_2)) equateNum(N_2,2) .. min lines = 2
			splitWindow(buf[N_4],N_2)		.. reopen split
			if (eqNum(N_1,0)) { fullRefresh incNum(N_1) }
			updateDisplay
			equateNum(N_5,N_9)				.. start mouseY = cur mouseY
		}
	goto label(0)

	.. return point
label(1)
	editBuf(buf[N_4])
	putmsg("")
	>


<defines: >
