[mjk] 2005-10-17: Consio is a small console library for Windows. I created it, so I can make small textbased menus and catch single keystrokes and not always use Tk for creating user interfaces. It's also handy for asking passwords from user and not echo them back to the screen. The library is written in C and has been compiled with Cygwin tools under Cygwin environment using MinGW libraries and headers (so there are no dependencies to the Cygwin). The source code and binary are available here: [http://www.iki.fi/mjk/files/Consio.zip]. The whole package is released under the MIT license. Here's a screenshot: [http://www.iki.fi/mjk/img/tcl/Consio.jpg] The library is pretty skimpy (well, it's version 0.1 at the moment, so don't expect too much), but it already implements the following commands: Consio::clrscr Clears screen (console buffer). Consio::gotoxy x y Sets a new cursor location to (x;y). Consio::getch Waits for single key press. Consio::getche Waits for single key press and echoes it back to the console. Consio::putch chr Inserts a character to the cursor location. Consio::kbhit checks if there are any keystokes waiting in the input buffer. This function doesn't block or remove anything from the buffer. The function will return 1 if there are keystrokes waiting in the input buffer. Otherwise returns 0. Consio::textattr foreground background Sets foreground and background color. Available color attributes for both foreground and background color are: black blue green cyan red magenta brown lightgray darkgray lightblue lightgreen lightcyan lightred lightmagenta yellow white Consio::cputs ?-nonewline? string Prints string to standard output. If -nonewline is specified, then then the newline will not be printed at the end of the line. Consio::cgets Reads keystrokes from the console until Enter key is pressed. Linefeed or newline characters are not included in the result. Consio::cgetse Reads keystrokes from the console and echoes them back until the Enter key is pressed. Linefeed or newline characters are not included in the results. ---- At the moment, this library has been tested only under Windows XP. All feedback is welcome and I would appreciate it greatly if people would tell me, how the library works under different flavors of Windows. The feedback can be appended to this page or sent directly to me (e-mail address is included in the package). [jmn] 2005-10-18 Nice work - thanks for sharing. It works fine on my old Windows NT & 2000 server boxes. A consequence of course of using ReadConsole instead of lower level Console API functions such as ReadConsoleInput; is that Consio as it stands doesn't catch certain keys such as arrows, delete, end etc.. Perhaps 'press any key' in the demo should be qualified a little - otherwise the old joke about lusers hunting for the key marked 'any' just isn't as funny ;) [LES]: this is very nice, and seems to work in my Windows 98. I couldn't make '''getch''' and '''getche''' work, but I suspect I just did something wrong. ---- [[ [Category Package] ]]