Open main menu

CDOT Wiki β

Changes

OOP344 Assignment One

318 bytes added, 19:20, 10 January 2010
no edit summary
[[OOP344]] - [[OOP344 Student List]] - [[OOP344 Teams]] - [[OOP344 Assignment One]] - [[OOP344 Assignment Two]] - [[OOP344 IRC Schedules 20093 |OOP344 IRC Schedules]]<br />
- [[OOP344 Student Resources]]<br />
As your first assignment this semester, you are to write a multi-platform direct terminal library and later use that library to create a text editor. Assignment One is done individually! Each student must complete and hand her/his own work, no collaboration permitted for this part.
==Console Input Output Library ==
Note that the conditions of termination are changed if '''“IsTextEditor”''' flag is true (non-zero). See '''“IsTextEditor”''' section for detail.
The function returns an int identifying the key that was pressed to exit. (This function uses the same key codes as [[#io_getch() | io_getch()]])
The function takes no action if the user tries to enter too many characters (if, for example, the string is full in insert mode, or the cursor is positioned after the last character of a full string in overstrike mode). However if cursor reaches the end of the field and the string is not full then after inserting the character string will be scrolled to left, positioning the cursor right after the last character in the string.
====void io_displayflag(..........)====
<big>void io_displayflag(const char '''*format''', int '''row''', int '''col''', int '''status''');</big>
Allows the user to display a <u>checkbox </u> at '''row ''' and '''col ''' on the screen. Depending on the value of '''status'''; being zero or non-zero, the checkbox will be checked or unchecked respectively.
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 surrounding characters and format[1] is the check-mark.
The '''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>
====int io_flag(..........)====
<big>int io_flag(const char '''*format''', int '''row''', int '''col''', int'''* status''', int '''radio''');</big>
io_flag() allows the user to make a single true/false selection. '''"status" ''' points to the status of the selection, that can be zero or non-zero. If '''"*status" ''' is initially set to anything but zero, io_flag() corrects value to one. '''"format" ''' holds the shape of the checkbox as io_displayflag() function.
io_flag() begins the selection by displaying the checkbox according to its '''“*status”'''. (Remember that the value of '''"*status" ''' is corrected before the editing begins). Then the function waits for the user input.
*If the user input is any of the printable keys (' ' < key <= '~') excluding space, it should be ignored (no action taken). If the user input is any of the function keys, the function is terminated returning the key.
*If the user input is SPACE:
**If '''“radio” ''' is true, then the '''"*status "''' is set to one, checkbox is displayed and function is terminated returning space.**If '''“radio” ''' is false, then the value of '''"*status "''' is toggled between 0 and 1, the checkbox is displayed and function is exited returning space.
====void io_displayMenuItem(..........)====
<big>void io_displayMenuItem(const char '''*format''', const char '''*menuItem''', int '''row''', int '''col''', int '''len''', int '''status''');</big>
Allows the user to display a menu-item at '''row ''' and '''col ''' on the screen with width of '''len'''. Depending on the value of '''status'''; being zero or non-zero, the menu-item will be surrounded by '''format '''characters or space respectively.
The '''menuItem ''' argument will be always shown surrounded by two characters.* <u>If status is zero</u>, then at '''row ''' and '''col ''' a <u>space </u> will be shown, then the '''menuItem ''' followed by another <u>space</u>. If the length of '''menuItem ''' is less than (len-2), then enough spaces will be printed up to make the length (len-2).
<pre>"Hello"</pre> with 10 as len will be printed as : <pre>" Hello "</pre>
====int io_menuItem(..........)====
<big>int io_menuItem(const char '''*format''', const char '''*menuItem''', int '''row''', int '''col''', int '''len''', int'''* status''');</big>
io_menuItem() allows the user to make a single item selection. '''"*status" ''' points to the status of the selection, that can be zero or non-zero. If '''"*status" ''' is initially set to anything but zero, io_menuItem() corrects value to one. '''"*format" ''' holds the shape of the selection indicator as io_displayMenuItem() function.
io_menuItem() begins the selection by displaying the menu item according to its '''“*status” ''' using [[#void_io_displayMenuItem.28...........29|io_displayMenuItem()]]. (Remember that the value of '''"*status" ''' is corrected before the editing begins). Then the function waits for the user input.
*If the user input is any of the printable keys (' ' < key <= '~') excluding space, it should be ignored (no action taken). If the user input is any of the function keys, the function is terminated returning the key.