00001 /*-------------------------------------------------------------------- 00002 * vtty.h 00003 * 00004 */ 00005 00006 #ifndef VTTY_H 00007 #define VTTY_H 00008 00009 #include "vwidget.h" 00010 #include "vtcl.h" 00011 #include "vpipe.h" 00012 00013 class vnode; 00014 class binding; 00015 00016 /* text styles */ 00017 00018 enum text_style { 00019 BOLD_BEGIN = 1, 00020 BOLD_END = 2, 00021 ITALIC_BEGIN = 4, 00022 ITALIC_END = 8 00023 }; 00024 00025 enum detail_kind { 00026 PRINT_BRIEF = 0, 00027 PRINT_FULL 00028 }; 00029 00030 typedef void (*print_fn)(class vtty *text, vnode *object, int depth, 00031 detail_kind detail, void *client_data); 00032 00033 /* 00034 * text widget 00035 */ 00036 00037 class vtty : public vwidget { 00038 00039 protected: 00040 vpipe *text_pipe; // text pipe 00041 00042 public: 00043 vtty(vwidget *par); 00044 ~vtty(void); 00045 virtual void destroy(void); 00046 virtual int kind(void) { return WIDGET_TTY; } 00047 00048 /* text I/O */ 00049 fstream& fout(void) { return text_pipe->fout();} 00050 virtual void update(void) = 0; 00051 virtual void clear(void) = 0; 00052 00053 /* attributes */ 00054 virtual void tag_style(text_style style) = 0; 00055 virtual void *tag_begin(vnode *obj) = 0; 00056 virtual void *tag_begin(vnode *obj, print_fn fn, int d, 00057 void *client_data) = 0; 00058 virtual void tag_end(vnode *obj) = 0; 00059 00060 /* viewing */ 00061 virtual void view(int row, int col) = 0; 00062 00063 private: 00064 /* override stupid defaults; do not implement */ 00065 vtty &operator=(const vtty&); 00066 vtty(const vtty&); 00067 }; 00068 00069 #endif