Changes

Jump to: navigation, search

BIOF 20101 (AS1) - OOP344

1,267 bytes removed, 13:47, 24 February 2010
m
Due date - deleted comma from due date
  (just a copy from last semester, Under Construction){{OOP344 Index}}
As your first assignment this semester, you are to write a multi-platform Set of Basic Input Output Functions (BIOF) for direct terminal interaction and later use the BIOF to create a text editor. Assignment One , like the main project is done collaboratively and is divided in two parts;
* Complex Functions
Each student must complete at least ?? one of Simple Functions individually and commit it to the repository and take part in completion of at least ?? Complex Functions.
= Basic Input Output Function Set V1.1=
V1.1: added '''"int readonly"''' flag to the arguments of bio_edit() function.
== Due date ==
Due date: ???Feb 25 @ 23:59 <big> biomain.c V0.8 is released svn://zenit.senecac.on.ca/oop344/trunk/biomain.c</big>
== File Names ==
Save your work in biof.h for the header file and biof.c for the source of the library.<br/>
The test main will be is released as bioftestbiomain.c;<big> svn://zenit.senecac.on.ca/oop344/trunk/biomain.c<br /></big>
The functions in BIOF all share the same prefix '''''bio'''''.
 
The working sample of the biomain.c is on matrix.
login to your matrix account using putty and make sure you set your Terminal/Keyboard to Xterm R6.
 
then type:
<big>
~fardad.soleimanloo/biof
</big>
 
the biomain.c should run.
== Simple Functions ==
Displays the null-terminated string pointed to by s starting at the current cursor position. This 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, this function has undefined results. This function does not flush any output buffer.
== Complex Functions ==
=== void bio_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 bio_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.  
== Line and Selection Editor ==
=== Line Editor: int bio_edit(........) ===
<big>int bio_edit(char* '''str''', int '''row''', int '''col''', <br />
int '''fieldlen''', int '''maxdatalen''', int '''*insertmode''', int '''*offset''',<br />
int '''*curpos''', int '''IsTextEditor''', int '''ReadOnly''')</big>
Allows the user to perform full screen editing of the null-terminated string pointed to by '''"str"'''. The parameter '''"row"''' identifies the row of the screen for the field (0 is the top row), while '''"col"''' indicates the starting column of the field (0 is the left-most column). The parameter '''"maxdatalen"''' specifies the maximum length of the string'''"str"'''. The parameter '''"fieldlen"''' specifies the length of the field in which editing is to be performed (visible area of '''“str”'''). The pointer '''"offset"''' points to an integer, holding the index of the first character of '''"str"''', shown in the field. The pointer'''"curpos"''' points to an integer holding the position of the cursor in the field (0 is the first position). '''"insertmode"''' is a pointer pointing to an integer flag, that is true (1) for insert mode being on, or false (0) for insert mode being off.<br />
NOTE: Following corrections should be done to '''"*curpos"''' and '''"*offset"''' in case they hold invalid values before editing begins:
# Set If '''"*curpos"''' exceeds the value of fieldlen, correct the '''"*curpos"''' so that cursor stands at the last position of inside 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. (See[[OOP344 Assignment OneBIO 20101#IsTextEditor:|IsTextEditor]] for more)# After the above, if cursor is past the last character of '''“str”''' set '''"*curpos"''' so the cursor stands right after the last character of "str".
The cursor is never allowed to : 1- move before the start of the field, 2- more than one position past the last character in the string, or 3- after the end of the field.
<u>Editing is terminated by pressing ENTER, TAB, UP, DOWN, PGUP, PGDN or any of the function keys (F1 to F12)</u>. Pressing <u>ESCAPE will terminate the bio_edit(), and abort editing</u>; '''"str"'''will contain orinally passed data when leaving function.
Note that the conditions of termination are changed if '''“IsTextEditor”''' flag is true (non-zero). See '''“IsTextEditor”''' section for detail.
 
If '''"ReadOnly"''' has a true value (non-zero) then any attempt to change the content of '''"str"''' should end the function and return the key . Note that all other keys should work. (Function and Non-ASCII keys). This make the '''bio_edit()''' funciton "read only", but still user can scroll the text to left or right and etc....
The function returns an int identifying the key that was pressed to exit. (This function uses the same key codes as bio_getch())
* HOME – move cursor to the beginning of the string. Scroll all the way to right if necessary. (i.e. if there is hidden data at the beginning)
* END - go to the end of the data in the string, i.e. just past the last character in the string. Scroll all the way to left if necessary.
* INSERT - toggle Insert/Overstrike mode<br />In Insert mode, printable characters are inserted into the string, moving the remainder of the string to the right to make room. In Overstrike mode, printable characters overwrite existing characters (if any). Note that if you are past the end of the string, printable characters are appended to the string (as long as the string isn't full) regardless of the mode. Also note that, regardless of the mode, the cursor advances as printable characters are typed into the string. Finally, if the cursor is at the end of the field, instead of moving to right, the characters are shifted to left.
* 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. If'''CIO_TAB_SIZE''' spaces cannot be inserted into the string for any reason then the inputted tab should be ignored. (See below for more about '''IsTextEditor''' flag)* ESCAPE - Terminates the bio_edit(), and abort editing; '''"str"'''will contain originally passed data when leaving function. (See[[OOP344 BIO 20101#IsTextEditor:|IsTextEditor]] for exception)* INSERT - toggle Insert/Overstrike mode<br />In Insert mode, printable characters are inserted into the string, moving the remainder of the string to the right to make room. In Overstrike mode, printable characters overwrite existing characters (if any). Note that if you are past the end of the string, printable characters are appended to the string (as long as the string isn't full) regardless of the mode. Also note that, regardless of the mode, the cursor advances as printable characters are typed into the string. Finally, if the cursor is at the end of the field, instead of moving to right, the characters are shifted to left.
==== 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, bio_edit should let the calling function take care of shifting instead of doing it by itselfknow that a shift has happened. 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 insteadafterwards. With termination, the function should return the terminating key.
The only exception is when upon Note that at the beginning of the execution of bio_edit, when 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 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.''
==== void bio_displayflag(..........) ====
<big>void bio_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 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>
After the checkbox is displayed, the cursor is always place under the check-mark (in centre).
==== int bio_flag(..........) ====
<big>int bio_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, bio_flag() corrects value to one. '''"format"''' holds the shape of the checkbox as bio_displayflag() function.
<big>void bio_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>
* If status is non-zero, then at row and col format[0] will be shown then the menuItem and finally format[1].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 and <code>"[]"</code> as format chars, will be printed as :<pre>"[Hello ]"</pre>
After the Menu item is displayed, the cursor is always placed under the first character of mentItemmenutItem. (position row and col+1)
==== int bio_menuItem(..........) ====
<big>int bio_menuItem(const char '''*format''', const char '''*menuItem''', int '''row''', int'''col''', int '''len''', int '''*status''');</big>
io_menuItembio_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, bio_menuItem() corrects value to one. '''"*format"''' holds the shape of the selection indicator as bio_displayMenuItem() function.
io_menuItembio_menuItem() begins the selection by displaying the menu item according to its '''“*status”'''using [[#void io displayMenuItem.28...........29|io_displayMenuItembio_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), and wait the user to input again. * If the user input is any of the function non-ASCII keys, the function is terminated returning the key.* If the user input is SPACE, then the *status is set to one, menu item is displayed and function is terminated returning the ASCII value of spacecharacter.
== Platforms ==
Say the installation is done in '''X:\Borland\BCC55''' <br />
Create a file called '''bcc32.cfg''' in '''X:\Borland\BCC55\Bin''' and add the following two lines to it:
<prebig -I"X:\Borland\Bcc55\include" -L"X:\Borland\Bcc55\lib" </prebig>
Create another file called '''ilink32.cfg''' in '''X:\Borland\BCC55\Bin''' and add the following line to it:
<prebig -L"X:\Borland\Bcc55\lib" </prebig>
Then add '''X:\Borland\BCC55\Bin''' to the system path:<br />
Vista:
Compile your code as:
<prebig > bcc32 as1testerbiomain.c ciolbiof.c</big>
</pre>You must restart your computer for changes to take affect!
'''Happy Compiling!'''
To compile using gcc issue the following command:<br />
<prebig> gcc as1testerbiomain.c ciolbiof.c -lncurses</prebig>
or
<prebig> cc as1testerbiomain.c ciolbiof.c -lncurses</prebig>
'''Also make sure you use [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html Putty]for your telnet client and set the Temminal/keyboard / function keys to Xterm R6'''
 
Here are [http://pastebin.ca/1603333 the key codes] for linux if you use putty with above settings
=== Mac OS C++ ===
Mac OS, being a Unix base operating system, supports curses library. So if you follow the case study in the book (the one written for AIX)it should work on Mac too.<br />
<big>I will leave this platform as an option cc biomain. If you like to get some bonus marks, you can implement it. But not doing it will not cost you anythingc biof.c -lcurses</big>
== How to submit your assignment ==
Close to the due date of the assignment, I will release[https://cs.senecac.on.ca/~fardad.soleimanloo/oop344/notes/AS1/as1tester.c a tester] program called'''"a1testerbiomain.c"'''. This program uses your functions and does series of tests. Each test will use your functions to produce an output or perform an action. If all the output is produced or the action is performed as stated in the tester program, you can submit through email branch the trunk to be evaluated.To submit your program after you tested it and made sure it can be submitted, you have to do the following: * Compile your program with as1tester.c on matrix and call the executable "as1"* Copy tags under as1 into root of your matrix account. (home directory)* Give your root account execute access Then send me an email to public ($chmod 711 .)* Give your assignment one executable "as1", read and execute access to public ($chmod 755 checkout as1)* Move the code to windows and test mark it on borland and VCC and make sure it works correctly* Set the platform to BCC (windows + Borland C compiler)* Compress '''ciol.h''' and '''ciol.c''' into ciol.zip (no other compression utilities accepted)** Select the two files by holding the control key and and clicking on them** Right click on '''ciol.c''' form the opened menu select '''Send latest commit to'''** In '''Send to''' menu select '''Compressed (zipped) folder'''** This will create '''ciol.zip''' as1 in tags indicates the same directory* Attach '''ciol.zip''' to an email to me to: [mailto:fardad.soleimanloo@senecac.on.ca?subject=OOP344AS1 fardad.soleimanloo@senecac.on.ca] '''only from your Seneca email'''* Make sure the subject is set to '''OOP344AS1''' === [https://cs.senecac.on.ca/~fardad.soleimanloo/oop344/notes/AS1/as1tester.c as1tester.c V1.2] === [https://cs.senecac.on.ca/~fardad.soleimanloo/oop344/notes/AS1/as1tester.c as1tester.c V1.2] is released Version 1.1 (removed warnings) Version 1.2 (corrected typo message in 9.3 from curpos supposed time of submission and has to be 6, to curpos supposed to be 5) The program tests the functions written for assignment one and makes sure they are as bug free as possible. The program may (very possibly) have bugs. If you find any, I'll appreciate if you[http://zenit.senecac.on.ca/~chris.tyler/planet/ blog] about it and also send an email to[mailto:fardad.soleimanloo@senecac.on.ca?subject=OOP344_AS1_BUG me]. (But if you find a bug, make sure it is a bug and not a problem with your assignment) To make sure you can get help if you face unsolvable problems in your assignment, I am extending before the assignment[http://zenit.senecac.on.ca/wiki/index.php/OOP344_Assignment_One#Due_date due date] to Wed. Oct 14 23:59. As usual I will be in the office on Tuesday, check my[https://cs.senecac.on.ca/~fardad.soleimanloo/timetable/FardadTimeTable.html Schedule] on my[https://cs.senecac.on.ca/~fardad.soleimanloo/ Seneca Website] for office hourstime.
=== Late Submission Penalty ===
10% Per day (Saturday and Sunday) counted as oneday.
1
edit

Navigation menu