\documentclass[11pt]{article} \begin{document} \title{\Huge Console\\[5pt] \Large a Win32 library for stream-based applications} \author{Jan Wielemaker} \maketitle \begin{abstract} This library is a brief documentation of the package console.dll, defining a Win32 library for Unix applications that are basically {\em stdio} based, but also requires access to Windows graphics. The library defines a `console-window' with scroll-back, resizing, cut-and-paste and command-line editing including history. It has been developed for SWI-Prolog. \end{abstract} \section{Simple usage} This section describes the most basic functions for communicating with the console.dll library. First of all, the user is requested to define the WinMain() function, which will call the libraries initialisation. The library will then call the main-function of the applications and provide functions for reading and writing to the console. \subsection{The main sketeton} \begin{code} int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { return rlc_main(hInstance, hPrevInstance, lpszCmdLine, nCmdShow, applmain, LoadIcon(hInstance, "APPL_Icon")); } \end{code} \func{applmain} is the name of a function that will be called using the normal C-main argument conventions: \begin{code} int applmain(int argc, char **argv) { } \end{code} The argument vector {\em argv} is vector of \type{char *} containing the arguments, followed by a \const{NULL} pointer. If \func{applmain} returns, the system will close down the console and call \func{exit()} using the return value of \func{applmain}. \subsection{Reading and writing the console} This function defines the basic IO functions provided. \begin{description} \cfunction{int}{rlc_write}{char *data, int size} Writes data to the console, and updates the window (flush). It returns the number of bytes processed. The characters from \arg{data} are handed to \func{rlc_putchar()} and thus interpreted as {\sc ansi} escape sequences. The semantics is deliberately almost the same as the normal \func{write()} call to make it easy to connect \end{description} \end{document}