bsp
|
00001 #ifndef _CONSOLE_H_ 00002 #define _CONSOLE_H_ 00003 00004 #define IDC_INPUT 100 00005 #define IDC_DISPLAY 101 00006 00007 class BSPConsole; 00008 class WConInput; 00009 00010 typedef struct conhist_s 00011 { 00012 char *line; 00013 conhist_s *next; 00014 conhist_s *prev; 00015 } conhist_t; 00016 00017 class ConsoleHistory 00018 { 00019 public: 00020 conhist_t *head; //the list 00021 conhist_t *tail; //last item in list 00022 conhist_t *current; //current nav position 00023 int count; 00024 int maxsize; 00025 char *activebuf; //copy of users active buffer, item 'before' head 00026 00027 ConsoleHistory(int size = 100); 00028 ~ConsoleHistory(); 00029 00030 bool add(char *line); //add a line, set current == head 00031 char *next(); //move to next item, return line 00032 char *prev(char *active); //move to prev item, return line. if cur=head, set activebuf 00033 void clear(); //remove all items and reset 00034 void trim(); //adjust list to fit within maxsize 00035 void setsize(int size); //set max size and trim 00036 }; 00037 class WConDisplay : public WEdit 00038 { 00039 public: 00040 WConDisplay(HWND parent,int id,char *text,int cx,int cy, int width,int height); 00041 LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam); 00042 BSPConsole *con; 00043 }; 00044 class WConInput : public WEdit 00045 { 00046 public: 00047 WConInput(HWND parent,int id,char *text,int cx,int cy, int width,int height); 00048 LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam); 00049 BSPConsole *con; 00050 }; 00051 00052 class BSPConsole : public TCWindow, public WindowPlacement 00053 { 00054 public: 00055 friend class WConInput; 00056 friend class WConDisplay; 00057 BSPConsole(HWND parent, char *caption); 00058 ~BSPConsole(); 00059 LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam); 00060 bool CanClose(); 00061 WConDisplay *display; 00062 WConInput *input; 00063 ConsoleHistory *history; 00064 int textwidth; //number of char columns visible 00065 00066 00067 //WindowPlacement 00068 HWND WP_GetHwnd(); 00069 const char *WP_WindowName(); 00070 00071 void WriteV(char *text, va_list args); 00072 void Writef(char *text, ...); 00073 void Write(char *text); 00074 void ScrollEnd(); 00075 void Scroll(int lines); 00076 void PageUp(); 00077 void PageDown(); 00078 void ClearScreen(); 00079 void DebugCommands(char *cmd); 00080 void ShowHelp(char *args); 00081 void ShowHelpItem(char *args); 00082 void ShowGroups(char *args); 00083 private: 00084 void process_buffer(); 00085 void display_columns(list<char*>& list); 00086 void tab_complete(); 00087 HFONT font; 00088 HBRUSH bgbrush; 00089 }; 00090 00091 #endif //_CONSOLE_H_