00001
00002
00003
00004
00005
00006
00007
00008
00009
00015 #include <windows.h>
00016 #include <stdlib.h>
00017 #include <malloc.h>
00018 #include <memory.h>
00019 #include <tchar.h>
00020
00021 class WinConsole {
00022
00023 char *text;
00024 int *lineIndexTable;
00025
00026 int maxLines, maxChars;
00027 int nLines, topLine, curLine;
00028 int curLineLen, curLinePos;
00029
00030
00031 int disLineCount, disLine, disLineNum, disLineOff;
00032 int disWidth, disHeight;
00033 int fontWidth, fontHeight;
00034 int xBorder, yBorder;
00035 HWND hWnd;
00036
00037 void printLine(HDC hDC, char *line, int ypos);
00038 int getDisplayLineCount(int disWidth);
00039 int getDisplayLineNum(int lineNum, int disWidth);
00040 char *getLine(int i){
00041 if(i<0 || i>=nLines) return "";
00042 else return &text[lineIndexTable[(topLine+i)%maxLines]];
00043 }
00044 public:
00045 void deltaResize(int &dw, int &dh);
00046 void addLine(char *line);
00047 void print(char *str);
00048 int lineCount(){ return nLines; }
00049 void setDisplaySize(int width, int height){ disWidth = width; disHeight = height; }
00050 void updateDisplay();
00051 void init(HWND hWnd);
00052 int wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00053 WinConsole();
00054 };
00055