Hints for OOP344 Assignment 1
OOP344 - 20113
ESCAPE KEY:
- - Allocate memory to size of strlen(str).
- -copy the content of str into allocated memory.
- - If ESCAPE is hit, copy the content of allocated memory back to str.
- - Make sure before the function ends, deallocates the allocated memory.
OTHER EXIT KEYS:
- You don't have to individually code every key that exits the editor; all of them apart from ESCAPE use the same code, so just let the cases "drop through" each other.
INSERT KEY:
- You wanna turn on and off Overwrite every time INSERT key is hit.
- INSERT mode is default value. if you press INSERT once, Overwrite Mode will be turn ON and INSERT mode will be turn OFF.
- If you press INSERT again, INSERT mode will be turn ON and Overwrite Mode will be turn OFF
- I dont think there is anything else you should do with INSERT key beside Toggling INSERT MODE and OVERWRITE MODE.
Printable KEY:
// if( key is withing printable character's code){ // if (*instermode){ // do something with str[*strOffset+ *curPosition] // Push all the characters on the right hand of the cursor to the right to make room for new character. // Move the cursor after the new inserted character. // } // else{ // do something else with str(..... // Move the cursor after the new overwrite character // } //}
- For INSERT mode, you'll need to increase the length of the string before you push the characters.
Diagram
Diagram link: http://i282.photobucket.com/albums/kk241/Kamunist/oop_diagram.png
I am not the owner of the diagram above. I just want to explain it.
- The string will initially start at coordination(column,row).
- Offset is an integer that show how many characters are hidden.
- FieldLength is the length of the display box. It decide the maximum number of character you want to display.
- CursorPos is the cursor position within the display box. For example, if your FieldLength is 10, your cursor position can be from 1-10.
- Max str length is used when FieldLength is 0. It decide the length of your str so that it will fit on the screen(with no wrap).
Matrix compiler problem
http://ryandang-cpa.blogspot.com/2011/09/issue-with-matrix-compiler.html
Make sure to #include string.h instead of string or you will have many errors if you have used strlen strcpy etc.
Borland compiler problem
- make sure you follow these instruction to install Borland properly.
- make sure you use the console.cpp,key.h,console.h from /trunk/Console folder.
- In order to compile under borland compiler you need to use the last release 1.3 of the console.
Contributor
Qtdang1
Lpasquale1