Changes

Jump to: navigation, search

OOP344 Assignment One

1,907 bytes added, 00:00, 14 September 2009
no edit summary
==Specifications==
You are to write a program that places characters at various positions on a screen using a direct terminal library module. Your library module is named '''''ciolio''''' and contains the following functions:
===void ciol_initio_init(void)===
Initializes the '''ciolio''' routines. Your application calls this function before calling any other '''ciolio''' function and only once before calling '''ciol_doneio_done()'''.===void ciol_doneio_done(void)===
Shuts down the '''ciolio''' routines and ensures that the cursor is not left in the middle of the screen, which may be partly filled with characters. Any application that has called '''ciol_initio_init()''' should call this function before terminating.
==='''int ciol_rowsio_rows(void)'''===
Returns the number of rows on the screen.
==='''int ciol_colsio_cols(void)'''===
Returns the number of columns on the screen.
===void ciol_clrscrio_clrscr(void)===
Clears the screen and leaves the cursor in the upper left-hand corner of the screen.
===void ciol_flushio_flush(void)===
Ensures that any output sent to the screen is displayed on the screen (that is, this function flushes the output buffer).
===int ciol_getchio_getch(void)=== returns the virtual key code identifying the key pressed by the user. This function first displays all output that has been sent to the screen (if any is pending to be displayed), waits for a key to be pressed and returns an int value that uniquely identifies the key pressed. To accommodate platform dependency, define the following symbolic names for the non-ASCII keys in each platform:
*'''UP_KEY''' - the up arrow key value,
You must use platform specific and unique non-ASCII values for the keys, and then you must use these specific symbolic names in your definitions.
 
===void ciol_move(int r, int c)===
 
Positions the cursor at row r and column c, where row 0 is the top row and column 0 is the leftmost column. If either parameter is invalid, your function has undefined results. Your function does not flush any output buffer.
===void ciol_putch(int c)===
 
Displays the character c at the current cursor position and advances the cursor by one position to the right. If the cursor is already at the rightmost column of the screen, the advance is system dependent. This function does not flush any output buffer.
===void ciol_putstr(const char *s)===
 
Displays the null-terminated string pointed to by s starting at the current cursor position. Your function leaves the cursor just after the last character displayed. If the string exceeds in length the available space on the current line of output, your function has undefined results. Your function does not flush any output buffer.
===void ciol_display(const char *str, int row, int col, int len)===
Outputs the null-terminated string pointed to by "str", on the screen starting at row "row" and column "col" on the screen, upto "len" characters. As with ciol_move(), 0 is the top row, and 0 is the leftmost column. If the string is longer than "len", then only "len" characters are displayed, but if it is shorter than "len", then the entire string is displayed left-justified in the field. However, if "len" is 0 or less, then the field length is considered to be the actual length of the string (i.e. the entire string is displayed). Afterwards, the cursor is positioned after the last character of the field. (Note that on systems where output is buffered, this function should not flush the output buffer). The results are undefined if the specified values indicate a field that does not fit on the screen.

Navigation menu