Up: Classes   [Index]


Win32TerminalStream

Win32TerminalStream Class

The Win32TerminalStream class provides keyboard input capabilities for Win32 cmd.exe consoles. It also provides basic output formatting capabilities using DJGPP’s conio.h functions. This class does not provide curses-style output buffering.

This class is not strictly a stream, and is likely to remain limited to displays in the cmd.exe window until Ctalk can implement a genuine fork(3) system call for non-POSIX systems.

Win32TerminalStream simulates raw terminal I/O using BDOS and C library function calls. If the program needs to handle extended keys like cursor and keypad keys, it should open the TerminalStream input queue (with the openInputQueue method) and read input events. See TerminalStream.

At present, Ctalk recognizes the following input event classes. In Win32TerminalStream class, the getCh method generates a KBDCUR input events for all extended keys.

KBDCHAR        # ASCII Characters
KBDCUR         # Extended keys (first character read returns 0).

For examples of how to read characters from the keyboard, see the program listings in the ANSITerminalStream class section of the manual. See ANSITerminalStream.

Instance Variables

queueInput

True if queueing input events. The current state of the keyboard’s modifier keys. Set by the biosKey and getShiftState methods, below.

Instance Methods

Waits for a key and returns the scan code of a BIOS Int 16h, function 0 call. Also sets the shift state in the receiver’s shiftState instance variable. See the getShiftState method, below.

cGetStr (void)

Returns a String object that contains input typed by the user. The input is echoed to the console.

clear (void)

Clears the terminal window and moves the cursor to the upper left-hand corner.

cPutStr (char *str

Prints str to the console at the current cursor position.

cusorPos (int x, inty)

Positions the cursor at character position x, y. The upper left-hand corner of the screen is row 1, column 1. This is a synonym for gotoXY, below.

getCh (void)

Essentially a wrapper for the BDOS character input without echo function. This method handles C-c, C-d, and C-z by exiting the application.

getShiftState (void)

Get the state of the keyboard’s modifier keys with by calling BIOS Int 0x16, function 12h. Stores the result in the receiver’s shiftState instance variable.

gotoXY (int x, inty)

Positions the cursor at character position x, y. The upper left-hand corner of the screen is row 1, column 1.

openInputQueue (void)

Begin queueing input events. See InputEvent.

printOn (char *fmt, ...)

Print the formatted output to the receiver’s output stream.

screenColor (char *fgcolor, char*bgcolor)

Sets the window’s foreground and background colors for following writes using cPutStr, above. The arguments are class String, and may have the following values.

black
blue
green
cyan
red
magenta
brown
lightgray
darkgray
lightblue
lightgreen
lightcyan
lightred
yellow
white

Up: Classes   [Index]