Open main menu

CDOT Wiki β

Changes

OOP344 Assignment One

176 bytes added, 10:18, 1 October 2009
Line Editor: int io_edit(........)
# Set the "*curpos" so that cursor stands at the last position of the field if it exceeds fieldlen.
# If "*offset" is greater than the length of the string, set the "*offset" so the “last character of str” is hidden right before the first space in the field.
# After the above, if cursor is past last character of “str” set "*curpos" so the cursor stands right after the last character of "str".
The cursor is never allowed to move before the start of the field, more than one position past the last character in the string, or after the end of the field.
'''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. The only exception is when upon the beginning of the execution of io_edit, when validating *offset, make sure to correct the offset before returning the default value of key.
''when IsTextEditor is true, and Escape is hit do not abort the editing but simply terminate the function returning the Escape key.''