                Implementing A Casefix Tool.


	There are many ways to implement a casefix tool in various kinds of apps. and some choices about which casefix functions and modes to make available to the users of your app. For instance, one mode of casefix, wackify, is almost to silly to include in libcasefix and is only included for the sake of thoroughness.

	Every app has its own way of doing things but the developer of libcasefix imagines that some apps will do things in a certain way. The suggestions in this paper are to be taken only as a few of the possibilities. You of course can implement a casefix tool in any manner you wish. Feel free.


	To actuate a casefix tool, a mode must be selected. Also two of the modes have a parameter (an argument string). Keeping this in mind and giving the end user the maximum choice, I suggest this implementation.
	\
	
	An app can have the casefix enabled by default, but if it is not enabled by default a selection in a menu, tools would be apropos, should say casefix tool. Upon clicking on that menu item or at the first activation of casefix if it is enabled by default, the "settings" dialog should appear. To get ahead of myself, subsequent clicking on the casefix tool menu item should display a submenu with two possible selections, change settings, which would pop up the settings dialog and disable casefix tool. The settings dialog should display 7 mutually exclusive buttons that correspond to the 7 modes described in the casefixarray, casenreplacearray and casenreplacestring function pages in the casefix Programmer's Reference Guide and the last two buttons should have a input field associated with them that is greyed or blacked out until the respective button is selected. Each button also should have a brief description of the mode it represents. Also a informational panel should be in the dialog, and should  have a statement such as "Please select a casefix mode" until a button has been selected. There should be three other larger buttons at the bottom, help (we plan to make a prototype text help file for use or as a model for your use), cancel, and OK. If cancel is selected you  can Disable the casefix tool and reset the casefix tool menu item to its original state.
	
	At the top of the dialog it should display a text message should display something like this:
	---------------------------------------------------------------
	The casefix tool will modify the text you select, according to the settings below when you press <hot key combination>.
	------------------------------------------------------

	Each of the mode buttons should be associated with an integer 1 to 7 and it should be saved until the settings are changed or until the casefix tool is disabled; this integer will be inserted in the int mode parameter when the casefixarray, casenreplacearray or casenreplacestring function is called. We imahine that casenreplacearray will be the function propably apropos for use in your app.
	
	If custom mode, mode six is selected, its parameter field should show itself and the info panel should display something like this:
	--------------------------------------------------------------
	For each word in the selection, for each character in the word, the casefix tool checks the character at the same position in the casing template string. The casefix tool uses the following code to indicate how each character should be cased:
	 
	 	U or u - character should be upper case
	 	L or l - character should be lower case
	   	     = - leave character unchanged
 
	So a template string, say "Uu=lL" would, for every word, capitalizes the 1st and 2nd charters and lower cases the 4th and 5th character, and leave the 3rd character unchanged. All characters in a word thats position is past the end of the template string, are left unchanged. All non-alphanumeric characters act as word seperaters.
	--------------------------------------------------------------------
	 And when the OK button is pushed, it is a good idea to run the string through valid_template_check(char * templatestring) and if it returns OK, the template string should be saved until the settings are changed or until the casefix tool is disabled. The template string will be inserted in the char * argstring parameter when the casefixarray, casenreplacearray or casenreplacestring function is called. If valid_template_check(char * templatestring) comes back invalid, The text in the info panel should be either be prepended or appended with a highlighted invalid casing template error message.
 
	If prepsentences mode, mode seven is selected, its parameter field should show itself and the info panel should display something like this:
	----------------------------------------------------------------Upon reaching the 1st alphanumeric character after the beginning of your selection or a "sentence delimiter", the casefix tool capitalizes the first character of the alphanumeric block (or word) if it is an alphabetic character; there after it lower cases all alphabetic characters until it reaches a "sentence delimiter", Sentence delimiting characters can be specified. The default sentence delimiters are: . - periods, ? - question marks, and ! - exclamation points.
	-------------------------------------------------------------
	The sentence delimiter string should be saved until the settings are changed or until the casefix tool is disabled; This string will be inserted in the int argstring parameter when the casefixarray or the casefixstring function is called.
	
	So, the user has made a selection, and pressed the hot key combination. I imagine that in most cases casenreplacearray will be the function to use. The pointer to the beginning of the selection will be inserted in the char * selectedchararray parameter when the casefixarray function is called. You now need to calculate the size (since libcasefix currently only does 7 and 8 bit characters (chars=bytes); subtract the pointer to the beginning of the selection from the pointer to the end of the selection, which will give you the size of the array to be processed. We need this number for 2 things: it will be inserted in the int size parameter when the casefixarray function is called. And the last thing before the call, create a reception char array of int size. insert the pointer to the reception array into the char * undochararray parameter and call casenreplacearray. Of course, these parameters are what you need to do a "redo", so if your apps does "redos", save this info.
	
	Now we check the returned char *, if it is a null char pointer there's been an error. There shouldn't be an error and if ypu called casefixarray, the pointer returned should point to the processed array, the same as the pointer to the reception array, char * output. This array will be a drop in replacement for the user select text. If you called casenreplacearray, the replacement has already been made and undochararray will point to a copy of the original text.
	
	Doing an undo is easily done as long as you have selectedchararray, undochararray and size intact.
	
	Viola
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	ta daa.
