## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# csutil/ansiparse.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2005 by Jorrit Tyberghein
    00003               (C) 2005 by Frank Richter
    00004               (C) 2006 by Marten Svanfeldt
    00005
    00006     This library is free software; you can redistribute it and/or
    00007     modify it under the terms of the GNU Library General Public
    00008     License as published by the Free Software Foundation; either
    00009     version 2 of the License, or (at your option) any later version.
    00010
    00011     This library is distributed in the hope that it will be useful,
    00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014     Library General Public License for more details.
    00015
    00016     You should have received a copy of the GNU Library General Public
    00017     License along with this library; if not, write to the Free
    00018     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    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__