# Io Reference

Server / Curses / Curses

|  | Curses allows writing and reading at arbitrary positions on the terminal. You have to call init to set the terminal to curses mode and end to end curses mode. The terminal is not updated until refresh is called. It is a bad idea to use the standard io's read and write methods when the terminal is in curses mode. The Curses primitive was written by Edwin Zacharias. Here's an example that prints Hello at column 5 and row 7;
    Curses init
    Curses move(5, 7) print(\"Hello\")
    Curses refresh
    Curses end
|  | begin Sets the terminal to curses mode. This should be called before any other curses methods. Returns self. cBreak(aString) Disables line buffering and erase/kill character-processing. cBreak should be on for most purposes. Returns self. clear Clears the terminal. Nicer than erase. Returns self. clearToEndOfLine Clears the text from the cursor to the end of the line. Returns self. delete(n) Deletes n characters at the current position. Text to the right is shifted left. n is optional and defaults to 1. Returns self. echo Echoes user input to terminal. Returns self. end Ends curses mode. This should be called before standard io's read and write methods are used. Returs self. get(n) Returns n characters from the terminal. n is optional and defaults to 1. getCh Reads a single-byte character from the terminal associated with the current or specified window. Returns a Number containing the byte. hasColors Returns true if the terminal supports color, false otherwise. height Returns a Number containing the height of the current screen. input(n) Returns user input up to a return, or a maximun of n characters. insert(aString) Inserts the string at the current position on the terminal, pushing existing text to the right. Returns self. move(x, y) Moves the cursor to column y and row x on the terminal. (0, 0) is at the top-left of the terminal. Returns self. noCBreak Allows line buffering and erase/kill character-processing. cBreak should be on for most purposes. Returns self. noEcho Does not echo user input to terminal. Returns self. nodelay(aBoolean) Enables or disables block during read. If aNumber is zero, nodelay is set to be false, otherwise it is set to be true. print(aString) Prints the string to the current position on the terminal, overwriting existing text on the terminal. Returns self. refresh Copies the current buffer to the screen. This must be called to make changes to the screen. Returns self. scroll(num) Scrolls up num lines. num is optional and defaults to 1. Returns self. scrollok(aBoolean) Enables / Disables automatic scrolling. Return self. setBackgroundBlack Sets the background color to black. setBackgroundBlue Sets the background color to blue. setBackgroundCyan Sets the background color to cyan. setBackgroundGreen Sets the background color to green. setBackgroundMagenta Sets the background color to magenta. setBackgroundRed Sets the background color to red. setBackgroundWhite Sets the background color to white. setBackgroundYellow Sets the background color to yellow. setForegroundBlack Sets the foreground color to black. setForegroundBlue Sets the foreground color to blue. setForegroundCyan Sets the foreground color to cyan. setForegroundGreen Sets the foreground color to green. setForegroundMagenta Sets the foreground color to magenta. setForegroundRed Sets the foreground color to red. setForegroundWhite Sets the foreground color to white. setForegroundYellow Sets the foreground color to yellow. setScrollingRegion(top, bottom) Sets the scrolling region; top and bottom are the line numbers of the top and button margin. Returns self. width Returns a Number containing the width of the current screen. writeCharacter(aCharacter) Prints the aCharacter to the current position on the terminal, overwriting existing text on the terminal. Returns self. x Returns the cursor x position. y Returns the cursor y position.