/* 
 * tclWinCEmain.c --
 *
 *	This file contains the main entry point for tclsh on Windows CE.
 *	It is adapted with minor modifications from Rainer Keuchel's
 *	celib-based w32console package, w32console.h file.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: Exp $
 */

#ifndef W32CONSOLE_H
#define W32CONSOLE_H 1

#include <windows.h>
#include <celib.h>
#include <stdio-palmsize.h>

#define BLACK     0
#define WHITE     1
#define BLUE      2 
#define RED       3
#define GREEN     4
#define LIGHTGRAY 5
#define DARKGRAY  6
#define CYAN      7
#define BLINK     8

#define _NOCURSOR     0
#define _NORMALCURSOR 1
#define _SOLIDCURSOR  2

#define MAXPATH 255

struct _Window {
    unsigned short *buf;
    int cx, cy, cwidth, cheight;
    int curcx, curcy;
    int ctype;
    int fg, bg;
    HANDLE hwnd;
    HFONT hFont;
    TEXTMETRIC tm;
    int nCharWidth;
    int nCharHeight;
    int linemode;
    int echo;
    PFILE *inbuf;
    struct _Window *parent;
};

typedef struct _Window Window;

struct text_info {
    unsigned char winleft;
    unsigned char wintop;
    unsigned char winright;
    unsigned char winbottom;
    unsigned char attribute;
    unsigned char normattr;
    unsigned char currmode;
    unsigned char screenheight;
    unsigned char screenwidth;
    unsigned char curx;
    unsigned char cury;
};

int setcursortype(int type);
int gettextinfo(struct text_info *ti);
int textcolor(int c);
int textbackground(int c);
int gotoxy(int x, int y);
int textattr(int attr);
int clrscr();
int gettext(int x, int y, int width, int height, void *buf);
int puttext(int x, int y, int width, int height, void *buf);
int window(int x, int y, int width, int height);

int cgetch();
int cgetche();
int cputs(const char *s);
int cprintf(const char *fmt, ...);
int cputch(int c);
char *cgets(char *s);

int console_start();
HFONT console_create_font();

Window *window_create(Window *this, Window *parent, int, int, int, int);
void window_delete(Window *this);
int window_gotoxy(Window *this, int x, int y);
void window_setcursortype(Window *this, int type);
int window_output(Window *this, const char *s);
void window_handle_timer(Window *this, HWND hwnd);
void window_handle_paint(Window *this, HWND hwnd);
void window_clearscreen(Window *this);
void window_scroll(Window *w, int n);

void window_update_cursor(Window *this, int flag);
void window_update_row(Window *this, int row);

#endif
