- Utility to facilitate screen I/O
- Requires:
- easyCurses.class
- ucAnswer.class
- ucError.class
- - currently creates a window 80 characters by 24 lines
- The JavaCurses 'library' makes the use of ASCII based graphics slightly easier.
- JavaCurses is basically a class redefinition of the major UNIX-C curses routines.
- Includes:
- -constructors
- -maxX, maxY (lower-right extent of window)
- -clearWin (set to all blanks)
- -moveTo (move the WINDOW itself)
- -NEXT & PREV functions (get next/prev X or Y with wrap and get next/prev POINT in given direction with wrap)
- - PRINT char/int/string at current cursor location
- - PUT given char at specified X,Y in window
- - PEEK what is character at specified X,Y location?
- - getInput read char/string from current cursor location
- - PROMPT - print prompt at bottom left of window and retrieve single character from user
- NOTES:
- 1. SCREEN origin is (0,0) { TOP LEFT corner of this Xwindow}
- 2. X refers to width (it is the cols)
- 3. Y refers to height (it is the lines)
- 4. YOU are responsible for making sure you don't reference a point outside your defined window
- 5. maxX() tells us how many columns are in the window
- maxY() tells us how many lines are in the window
- ********** the class easyCurses *************************************
- Constructor
- =========================
- The constructor is overloaded by two functions:
- easyCurses()
- easyCurses(Color C)
- The first constructor creates an 80 X 24 window..
- The second constructor also creates an 80 X 24 window but allows you to specify a background colour.
-
- void clearWin(); erase everything in the window
- ACCESS METHODS:
- ===================
- int maxX() { return Nchars; } // tell me max # of columns
- int maxY() { return Nlines; } // tell me max # of lines
- MOVE METHODS
- ================
- Move JUST the cursor (doesn't print anything)
Currently, BOTH functions do the same thing and NEITHER check the values of X and Y
- void moveTo(int x, int y);
- void moveCursor( int x, int y);
- NEXT METHODS
- ================
- NEXT values based on any X,Y and dimensions of WINDOW
- THESE DO NOT CHANGE THEIR ARGUMENTS
- int nextX(int x); get the next X value with wrap
- int nextY(int y); get the next Y value with wrap
- int prevX(int x); get the previous X value with wrap
- int prevY(int y); get the previous Y value with wrap
- OUTPUT METHODS
- ===================
-
- Print at the current cursor location [single character, a string, or a number]
- void print(char letter);
- void print(String str);
- void print(int number);
- put a character in the window at specified location this time x,y is relative to top left corner of window
- leaves cursor at char just printed
- void put(int x, int y, char letter);
- INPUT METHODS
- =================
- find out which character is at the given location
- leaves cursor where it was before call
- char peek( int x, int y );
-
- reads characters typed by user
- reads from current cursor location
- char getInput();
- int getInputCode();
- Both will wait until the user hits one key and stores it into character.
- .
- The latter will take keyboard input (such as arrow keys).