#ifndef ikterm_h_included
#define ikterm_h_included

#include "ikextern.h"

typedef struct _K_CLIENT_PAINT {
    unsigned short*  textBuffer;
    cell_video_attr_t* attrBuffer;
    vt_char_attr_t* effectBuffer;
    vt_cell_attr_t* cellAttrBuffer;
    unsigned short* lineAttr;
    int             len;
    BOOL            cursorVisible;
    POINT           cursorPt;

    unsigned long   beg;            // for vertical scrollbar
    unsigned long   top;
    unsigned long   scrolltop;
    unsigned long   end; 
    unsigned long   maxWidth;
    int             page;
    int             page_length;
    int             height;
} K_CLIENT_PAINT;

struct vscrn_struct;
struct videoline_struct;
class IKTerm 
{
public:
    IKTerm( BYTE whichbuffer, K_CLIENT_PAINT* );
    ~IKTerm();
    BOOL getDrawInfo();
    BOOL getDrawInfo(BYTE vscrn_number);
    BOOL getDrawInfo(BYTE vscrn_number, bool smoothScroll);

    bool getSmoothScrollDrawInfo();

    BOOL newKeyboardEvent( UINT chCharCode, LONG lKeyData, UINT keyDown, UINT sysKey );
    BOOL keyboardEvent( UINT chCharCode, LONG lKeyData, UINT keyDown );
    BOOL virtkeyEvent( UINT virtkey, LONG lKeyData, UINT keyDown );
    void mouseEvent( HWND hwnd, UINT msg, WPARAM wParam, int x, int y );
    BOOL getCursorPos();

protected:
    DWORD getControlKeyState();

private:
    BYTE vnum;
    K_CLIENT_PAINT* kcp;
    INPUT_RECORD inpEvt;

    int x, y;
    int xs, ys, c, xo, yo, xho;
    vscrn_struct* vbuf;
    videoline_struct* line;
    int cursor_offset;
    unsigned short *textBuffer;
    cell_video_attr_t *attrBuffer;
    vt_char_attr_t *effectBuffer;
    unsigned short *lineAttr;
    vt_cell_attr_t *cellAttrBuffer;
    int incnt;
    vt_char_attr_t vt_char_attrs;
    vt_cell_attr_t cell_attrs;
    int mouseCaptured;
};

long getMaxDim();
void getMaxSizes( int* column, int* row );
void getDimensions( BYTE vnum, int* w, int* h );

#endif
