Open main menu

CDOT Wiki β

Changes

OOP344 Assignment One

309 bytes added, 08:14, 1 October 2009
Line Editor: int io_edit(........)
* DEL – eat the current character above the cursor and move all subsequent characters one position to the left.
* BACKSPACE - move the rest of the field (including the cursor) one position to the left, eating the previous character.
* TAB:
** if '''IsTextEditor''' is false, TAB will simply terminate the function like a Function key
** if '''IsTextEditor''' is true, TAB will insert CIO_TAB_SIZE number of spaces into the string. '''CIO_TAB_SIZE''' should be a defined "tab size" value in ciol.h. (See below for more about '''IsTextEditor''' flag)
'''IsTextEditor:'''
'''If IsTextEditor:'''is true, then it means that the function is being used to edit a text by editing one line of the text at a time. In this case, shifting a line to the left or right should not only cause the editing line to be shifted, but also the rest of the lines in the text. To do this, io_edit should let the calling function take care of shifting instead of doing it by itself. 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 instead. With termination, the function should return the terminating key.
If IsTextEditor is true, then it means that the function is being used to edit a text by editing one line of the text at a time. In this case, shifting a line to the left or right should not only cause the editing line to be shifted, but also the rest of the lines in the text. To do this, io_edit should let the calling function take care of shifting instead of doing it by itself. 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 instead. With termination, the function should return the terminating key. ''Also when IsTextEditor is true, When and Escape is hit do not abort the editing but simply terminate the function returning the Escape key.''
Any normal printable key is simply placed into the string according to the rules laid out 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".)