Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CS_CSUTIL_ANSIPARSE_H__
00022 #define __CS_CSUTIL_ANSIPARSE_H__
00023
00024
00032
00033 class CS_CRYSTALSPACE_EXPORT csAnsiParser
00034 {
00035 public:
00037 enum Command
00038 {
00040 cmdUnknown,
00042 cmdFormatAttrReset,
00044 cmdFormatAttrEnable,
00046 cmdFormatAttrDisable,
00048 cmdFormatAttrForeground,
00050 cmdFormatAttrBackground,
00052 cmdClearScreen,
00054 cmdClearLine,
00056 cmdCursorSetPosition,
00058 cmdCursorMoveRelative
00059 };
00061 enum CommandClass
00062 {
00064 classNone,
00066 classUnknown,
00068 classFormat,
00070 classClear,
00072 classCursor
00073 };
00078 enum FormatAttr
00079 {
00081 attrBold,
00083 attrItalics,
00085 attrUnderline,
00087 attrBlink,
00089 attrReverse,
00091 attrStrikethrough,
00093 attrDim,
00095 attrInvisible
00096 };
00098 enum FormatColor
00099 {
00101 colNone = -1,
00103 colBlack,
00105 colRed,
00107 colGreen,
00109 colYellow,
00111 colBlue,
00113 colMagenta,
00115 colCyan,
00117 colWhite
00118 };
00119 struct CursorParams
00120 {
00122 int x;
00123
00125 int y;
00126 };
00128 struct CommandParams
00129 {
00130 union
00131 {
00133 FormatColor colorVal;
00135 FormatAttr attrVal;
00137 CursorParams cursorVal;
00138 };
00139 };
00153 static bool ParseAnsi (const char* str, size_t& ansiCommandLen,
00154 CommandClass& cmdClass, size_t& textLen);
00167 static bool DecodeCommand (const char*& cmd, size_t& cmdLen,
00168 Command& command, CommandParams& commandParams);
00169 };
00170
00173 #endif // __CS_CSUTIL_ANSIPARSE_H__