My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
XtermManip.h
Go to the documentation of this file.
1 // $Id: XtermManip.h,v 1.1.1.1 2009/07/06 23:57:27 eml Exp $
2 
3 #ifndef GCP_UTIL_XTERMMANIP_H
4 #define GCP_UTIL_XTERMMANIP_H
5 
16 #include <iostream>
17 #include <map>
18 #include <string>
19 
20 namespace gcp {
21  namespace util {
22 
23  class XtermManip {
24  public:
25 
29  XtermManip();
30 
34  virtual ~XtermManip();
35 
36  struct Option {
37  unsigned key_;
38  std::string str_;
39 
40  Option(unsigned key, std::string str) {
41  key_ = key;
42  str_ = str;
43  }
44  };
45 
46  //------------------------------------------------------------
47  // Color manipulation
48  //------------------------------------------------------------
49 
50  enum ColorKey {
51  C_BLACK,
52  C_RED,
53  C_GREEN,
54  C_YELLOW,
55  C_BLUE,
56  C_MAGENTA,
57  C_CYAN,
58  C_WHITE,
59  C_DEFAULT
60  };
61 
62  std::map<ColorKey, std::string> fg_;
63  std::map<ColorKey, std::string> bg_;
64 
65  std::map<std::string, ColorKey> colorNames_;
66 
67  void setFg(ColorKey key);
68  void setFg(std::string key);
69 
70  void setBg(ColorKey key);
71  void setBg(std::string key);
72 
73  ColorKey getColorKey(std::string name);
74 
75  //------------------------------------------------------------
76  // Text mode manipulation
77  //------------------------------------------------------------
78 
79  enum TextModeKey {
80  TEXT_DEFAULT,
81 
82  TEXT_BOLD,
83  TEXT_NORMAL,
84 
85  TEXT_UNDERLINED,
86  TEXT_NOT_UNDERLINED,
87 
88  TEXT_BLINK,
89  TEXT_STEADY,
90 
91  TEXT_INVERSE,
92  TEXT_POSITIVE,
93 
94  TEXT_INVISIBLE,
95  TEXT_VISIBLE,
96  };
97 
98  std::map<TextModeKey, std::string> textModes_;
99  std::map<std::string, TextModeKey> textModeNames_;
100 
101  void setTextMode(TextModeKey key);
102  void setTextMode(std::string name);
103 
104  TextModeKey getTextModeKey(std::string name);
105 
106  //------------------------------------------------------------
107  // Cursor modes
108  //------------------------------------------------------------
109 
110  enum CursorCntlKey {
111  CURS_GET_POSITION,
112  };
113 
114  void getCursorPosition();
115 
116  void saveCursor();
117  void restoreCursor();
118  void moveCursorUp(unsigned nline);
119  void moveCursorDown(unsigned nline);
120  void clearAbove();
121 
122  private:
123 
124  void initializeOptions();
125  void setRawMode();
126 
127  }; // End class XtermManip
128 
129  } // End namespace util
130 } // End namespace gcp
131 
132 
133 
134 #endif // End #ifndef GCP_UTIL_XTERMMANIP_H
Definition: XtermManip.h:23
XtermManip()
Definition: XtermManip.cc:17
Definition: XtermManip.h:36
virtual ~XtermManip()
Definition: XtermManip.cc:102