musicmud-2.1.6/data/
musicmud-2.1.6/data/help/
musicmud-2.1.6/data/policy/
musicmud-2.1.6/data/wild/
musicmud-2.1.6/data/world/
musicmud-2.1.6/doc/
musicmud-2.1.6/src/ident/
musicmud-2.1.6/src/lua/
musicmud-2.1.6/src/lua/include/
musicmud-2.1.6/src/lua/src/lib/
musicmud-2.1.6/src/lua/src/lua/
musicmud-2.1.6/src/lua/src/luac/
#ifndef COLOUR_H
#define COLOUR_H

#include <string>

using namespace std;

#include "charset.h"

class Player;
class MudObject;

//! colour-handling
namespace colour {

  //! the state that the remote ends colour parser should be in 
struct colstate_t {
  int fgcol;
  int bgcol;
  int bold;
  int ital;
  int undl;
  int dec;
  int sout;
  colstate_t() : fgcol(-1), bgcol(-1), bold(0), ital(0), undl(0), dec(0),
  sout(0) {
  }
};

//! info about the remote terminal
struct colourinfo_t {
  //! whether they want ANSI codes
  bool colour;
  //! the character set used by the remote end
  charset cset;
  //! the colour scheme the player has selected
  const char *scheme;
  //! the terminal the player is using
  const char *term;
  //! whether they want DEC VT100 font changing codes. 0 = off, 1 = auto, 2 = on
  int dec;
  //! how many cols this can support (should be 8, or 256 for xterm-256 or putty256)
  int xtermcols;
  //! the player associated with this
  const Player *who;
};

//! format string in accordance with colourinfo, then return its width. clip at /precision/
size_t colour_strnlen(const char *, int precision, const colourinfo_t &cs);

//! format string in accordance with colourinfo, then return its width. clip the original string at /bytes/
size_t colour_strlenof(const char *, int bytes, const colourinfo_t &cs);

//! obtain width of string formatted in accorance with colourinfo
size_t colour_strlen(const char *a, const colourinfo_t &ci);

//! obtain width of string formatted for /fr/
size_t colour_strlen(const char *what, MudObject *fr);

//! default colourinfo.
extern const colourinfo_t def_cols;

//! colourinfo for ASCII
extern const colourinfo_t asc_cols;

//! convert a string and info about colour state to the formatted version
typedef string (*colourparse_t)(colstate_t *, const char *src, const colourinfo_t t);

//! the currently in use colour formatter
extern colourparse_t msi_colourfilter;

//! obtain the visual width of a string given the given colour state
typedef size_t (*stringlength_t)(const char *, int len, const colourinfo_t &ci);

//! the currently in use length determiner
extern stringlength_t msi_stringlength;

//! obtain the colourinfo setting for /who/
colourinfo_t colinfo(const MudObject *who);

//! escape the colour codes in s2. withcol is 0 to indicate the string should be plain, 1 to indicate the colourcodes should take effect too.
string escape_colour(const string &s2, int withcol=1);

//! remove colour codes from /what/ and convert it to Latin1.
string lose_colour(const char *what);

}

using namespace colour;

#endif