Changes

Jump to: navigation, search

IOL Functions oop344 20112

8,325 bytes added, 11:19, 19 July 2011
no edit summary
{{OOP344 Index | 20112}}
 
For the assignments in OOP344 this semester, you will work collaboratively
in groups of 4 or 5 and submit your completed assignments as a group.
</table>
<font color="#ff0000"><b>UNDER NO CIRCUMSTANCES DOES THE FUNCTION CHANGE ANY POSITIONON THE SCREEN OUTSIDE OF THE FIELD</b></font><b></b>. *IsTextEditor::* [Section #1] IsTextEditor and *offset :*: If IsTextEditor is true, then the function is being used to edit textone line at a time. In this case, shifting a line to the left or right should not only cause the line being edited to be shifted, but also the rest of the lines in the text. To do this, iol_edit( ) should let the calling function know that a shift has occured. Since shifting essentially means modifying "*offset" when "IsTextEditor" is true, and that there are times when you find that "*offset" needs to be modified, you should terminate the function afterwards. With termination, the function should return the terminating key. Note that at the beginning of the execution of iol_edit( ), validating *offset may require the value of *offset to change. If so, make sure to correct the offset and then terminate the function before any editing happens returning thedefault value of key.* [Section #2]:# The iol_edit( ) function always displays blanks in any the part of the field that is not occupied by the data in the string.:# UNDER NO CIRCUMSTANCES DOES THE FUNCTION CHANGE ANY POSITION ON THE SCREEN OUTSIDE OF THE FIELD.*[Section #3] IsTextEditor and ESCAPE:# When "IsTextEditor" is true and the ESCAPE KEY is pressed, the function simply terminates (returning the ESCAPE key), but the editing is NOT to be undone.:# If the dynamic memory allocation fails, quit the function returning -1.*[Section #4] Others:# Any normal printable key is simply placed into the string according to the rules outlined in the discussion of the INSERT key above (The keys from the space character to the tilde character in the ASCII table are considered "printable").:# Like most C library functions, your iol_edit( ) may assume that it is thecalling program's responsibility is to ensure that the array is large enoughto handle the specified number of characters, and that the starting screenposition provides enough room (on the screen) for the field.  Selection Editor:===void iol_displayflag(-----)===<big><pre>void iol_displayflag(const char* format, int row, int col, int status)</pre></big>This function allows the user to display a checkbox at row and col on the screen. the checkbox will be checked or unchecked based on the value of the "status" parameter (non-zero for checked 0 for unchecked). The checkbox will be always shown using 3 characters (two surrounding characters and one character in the middle as the checkmark). If the status argument is zero, then instead of the check-mark a space will be printed on the screen. The 3 characters held in the "format" array: format[0] and format[2] are the surrounding characters and format[1] is the check-mark. const char* format is used to specify the character used for the checkbox, so for example if the format argument is "[X]", then an unchecked checkbox will be<big><pre>[ ]</pre></big>and a checked checkbox will be<big><pre>[X]</pre></big> After the checkbox is displayed, the cursor is always placed under the check-mark (in centre). ===int iol_flag(-----)===<big><pre>int iol_flag(const char* format, int row, int col, int* status, int radio)</pre></big> iol_flag( ) allows the user to make a single true/false selection. "status" points to the status of the selection and can be zero or non-zero. If "*status" is initially set to anything other than zero, iol_flag( ) correctsthe value to hold 1. "format" holds the shape of the checkbox as in the iol_displayflag() function. iol_flag( ) begins the selection by displaying the checkbox according to its"*status" (Remember that the value of "*status" is corrected before the editingbegins). Then the function waits for the user input. * If the user enters any of the printable keys (' ' < key <= '~') excluding the space key, it should be ignored (no action taken). If the user enters any of the function keys, the function is terminated returning that key.* If the user input is a SPACE:#If the "radio" parameter is true, then the "*status" is set to one, the checkbox is displayed, and the function is terminated returning the keycode for the space character.#If the "radio" parameter is false, then the value of "*status" is toggled (changing from 0 to 1 or 1 to 0), the checkbox is displayed, and the function terminated returning the space key. ===void iol_displayMenuItem(----)===<big><pre>void iol_displayMenuItem(const char* format, const char* menuItem, int row, int col, int len, int status)</pre></big>Allows the user to display a menu-item at row and col on the screen with a width of len. The menu-item will be surrounded by either format characters (when "status" is zero) or by spaces (when "status" is non-zero). The menuItem argument will be always shown surrounded by two characters. * If "status" is zero, then a space, followed by the menuItem, followed by another space will be shown at row and col on the screen. If the length of the menuItem is less than (len - 2), then enough spaces will be printed to make up the difference; making the entire field (len - 2) characters. For example:<big><pre>"Hello"</pre></big>with 10 as len will be displayed as:<big><pre>" Hello "</pre></big> * If "status" is non-zero, then format[0], followed by the menuItem, followed by format[1] will be shown at row and col on the screen.If the length of the menuItem is less than (len - 2), then enough spaces will be printed to make up the difference; making the entire field (len - 2) characters. For example: <big><pre>"[Hello]"</pre></big>with 10 as len and "[]" as format chars, will be printed as :<big><pre>"[Hello ]"</pre></big>After the Menu item is displayed, the cursor is always placed under the firstcharacter of menutItem. (position row and col + 1)  ===int iol_menuItem(----)===<big><pre>int iol_menuItem(const char* format, const char* menuItem, int row, int col, int len, int* status)</pre></big> iol_menuItem( ) allows the user to make a single item selection. "*status" points to the status of the selection (zero or non-zero). If "*status" is initially set to anything but zero, iol_menuItem( ) corrects the valueso that it is set to one. "*format" holds the shape of the selection indicator as outlined in theiol_displayMenuItem( ) function. iol_menuItem( ) begins the selection by displaying the menu item according to its"*status" using iol_displayMenuItem( )(Remember that the value of "*status" is corrected before the editing begins).The function waits for the user input. * If the user presses any of the printable keys (' ' < key <= '~') excluding the space key,then no action is taken and the function waits for the user to press another key.* If the user presses any of the non-ASCII keys, the function is terminatedreturning that key.* If the user presses the SPACE key, then the *status is set to one, the menu itemis displayed, and the function is terminated returning the ASCII value of space character. Submission Instructions:These functions are to be declared in a file named iol.halong with the symbolic key codes mentioned above. Thefunctions are to be defined in a file named iol.c.They must compile and work properly in both the MS-DOSenvironment (using the Visual Studio 2010 C/C++ compiler) and the UNIX (on Matrix)environment (using GNU C/C++ compiler). At most onlyone or two lines of iol.h should need to be modified whenchanging from one environment to the other. Whichever terminal program (ssh only) you are using mustbe capable of handling all of the keypresses properly(note that many do not!!).It is highly recommended that you use putty as your ssh client.See the "PuTTY" link on my webpage, under the "resources" folder. Submission Instructions:A main( ) program will be released shortly before the duedate to test that you have written your functions correctly.You are encouraged to write your own test code in themeantime however. If you wait for the assignment main( ) tobe released before you start testing your code in detail,you will likely not have enough time to finish this assignment.  Late Submission Penalty:1 letter grade per week. Due Date: Thursday June 16, 2011 @ 11:59:59 p.m.This assignment is worth 5% of your final grade in OOP344 this semester.GOOD LUCK!

Navigation menu