tmi2_fluffos_v2/
tmi2_fluffos_v2/bin/
tmi2_fluffos_v2/etc/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/ChangeLog.old/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/Win32/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/compat/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/compat/simuls/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/include/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/clone/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/command/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/data/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/etc/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/include/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/inherit/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/inherit/master/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/log/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/compiler/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/efuns/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/operators/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/u/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/tmp/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/windows/
tmi2_fluffos_v2/lib/
tmi2_fluffos_v2/lib/adm/
tmi2_fluffos_v2/lib/adm/daemons/languages/
tmi2_fluffos_v2/lib/adm/daemons/network/I3/
tmi2_fluffos_v2/lib/adm/daemons/virtual/
tmi2_fluffos_v2/lib/adm/daemons/virtual/template/
tmi2_fluffos_v2/lib/adm/news/
tmi2_fluffos_v2/lib/adm/obj/
tmi2_fluffos_v2/lib/adm/obj/master/
tmi2_fluffos_v2/lib/adm/priv/
tmi2_fluffos_v2/lib/adm/shell/
tmi2_fluffos_v2/lib/adm/tmp/
tmi2_fluffos_v2/lib/cmds/
tmi2_fluffos_v2/lib/d/
tmi2_fluffos_v2/lib/d/Conf/
tmi2_fluffos_v2/lib/d/Conf/adm/
tmi2_fluffos_v2/lib/d/Conf/boards/
tmi2_fluffos_v2/lib/d/Conf/cmds/
tmi2_fluffos_v2/lib/d/Conf/data/
tmi2_fluffos_v2/lib/d/Conf/logs/
tmi2_fluffos_v2/lib/d/Conf/obj/
tmi2_fluffos_v2/lib/d/Conf/text/help/
tmi2_fluffos_v2/lib/d/Fooland/adm/
tmi2_fluffos_v2/lib/d/Fooland/data/
tmi2_fluffos_v2/lib/d/Fooland/data/attic/
tmi2_fluffos_v2/lib/d/Fooland/items/
tmi2_fluffos_v2/lib/d/TMI/
tmi2_fluffos_v2/lib/d/TMI/adm/
tmi2_fluffos_v2/lib/d/TMI/boards/
tmi2_fluffos_v2/lib/d/TMI/data/
tmi2_fluffos_v2/lib/d/TMI/rooms/
tmi2_fluffos_v2/lib/d/grid/
tmi2_fluffos_v2/lib/d/grid/adm/
tmi2_fluffos_v2/lib/d/grid/data/
tmi2_fluffos_v2/lib/d/std/
tmi2_fluffos_v2/lib/d/std/adm/
tmi2_fluffos_v2/lib/data/adm/
tmi2_fluffos_v2/lib/data/adm/daemons/
tmi2_fluffos_v2/lib/data/adm/daemons/doc_d/
tmi2_fluffos_v2/lib/data/adm/daemons/emoted/
tmi2_fluffos_v2/lib/data/adm/daemons/network/http/
tmi2_fluffos_v2/lib/data/adm/daemons/network/services/mail_q/
tmi2_fluffos_v2/lib/data/adm/daemons/network/smtp/
tmi2_fluffos_v2/lib/data/adm/daemons/news/archives/
tmi2_fluffos_v2/lib/data/attic/connection/
tmi2_fluffos_v2/lib/data/attic/user/
tmi2_fluffos_v2/lib/data/std/connection/b/
tmi2_fluffos_v2/lib/data/std/connection/l/
tmi2_fluffos_v2/lib/data/std/user/a/
tmi2_fluffos_v2/lib/data/std/user/b/
tmi2_fluffos_v2/lib/data/std/user/d/
tmi2_fluffos_v2/lib/data/std/user/f/
tmi2_fluffos_v2/lib/data/std/user/l/
tmi2_fluffos_v2/lib/data/std/user/x/
tmi2_fluffos_v2/lib/data/u/d/dm/working/doc_d/
tmi2_fluffos_v2/lib/data/u/l/leto/doc_d/
tmi2_fluffos_v2/lib/data/u/l/leto/smtp/
tmi2_fluffos_v2/lib/doc/
tmi2_fluffos_v2/lib/doc/driverdoc/applies/
tmi2_fluffos_v2/lib/doc/driverdoc/applies/interactive/
tmi2_fluffos_v2/lib/doc/driverdoc/concepts/
tmi2_fluffos_v2/lib/doc/driverdoc/driver/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/arrays/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/buffers/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/compile/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/ed/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/filesystem/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/floats/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/functions/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/general/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/mappings/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/numbers/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/parsing/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/constructs/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/preprocessor/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/types/
tmi2_fluffos_v2/lib/doc/driverdoc/platforms/
tmi2_fluffos_v2/lib/doc/mudlib/
tmi2_fluffos_v2/lib/ftp/
tmi2_fluffos_v2/lib/include/driver/
tmi2_fluffos_v2/lib/log/
tmi2_fluffos_v2/lib/log/driver/
tmi2_fluffos_v2/lib/obj/net/
tmi2_fluffos_v2/lib/obj/shells/
tmi2_fluffos_v2/lib/obj/tools/
tmi2_fluffos_v2/lib/std/adt/
tmi2_fluffos_v2/lib/std/board/
tmi2_fluffos_v2/lib/std/body/
tmi2_fluffos_v2/lib/std/fun/
tmi2_fluffos_v2/lib/std/living/
tmi2_fluffos_v2/lib/std/object/
tmi2_fluffos_v2/lib/std/shop/
tmi2_fluffos_v2/lib/std/socket/
tmi2_fluffos_v2/lib/std/user/
tmi2_fluffos_v2/lib/std/virtual/
tmi2_fluffos_v2/lib/student/
tmi2_fluffos_v2/lib/student/kalypso/
tmi2_fluffos_v2/lib/student/kalypso/armor/
tmi2_fluffos_v2/lib/student/kalypso/rooms/
tmi2_fluffos_v2/lib/student/kalypso/weapons/
tmi2_fluffos_v2/lib/u/l/leto/
tmi2_fluffos_v2/lib/u/l/leto/cmds/
tmi2_fluffos_v2/lib/www/errors/
tmi2_fluffos_v2/lib/www/gateways/
tmi2_fluffos_v2/lib/www/images/
tmi2_fluffos_v2/old/
tmi2_fluffos_v2/win32/
/*    /adm/daemons/terminal.c
 *    from TMI-2
 *    holds terminal colour translation information
 *    created by Descartes of Borg 93????
 *    using the colour code protocol developed by Pinkfish@Discworld
 */


#define ANSI(p) sprintf("%c["+(p)+"m", 27)
#define ESCMAC(p) sprintf("%c"+(p), 27)

static mapping term_info;

void create() {
    term_info = ([ "unknown":
      ([ "RESET": "", "BOLD": "", "FLASH":"", "BLACK":"", "RED":"", "BLUE":"",
      "CYAN":"", "MAGENTA":"", "ORANGE":"", "YELLOW":"", "GREEN":"",
      "WHITE":"", "BLACK":"", "B_RED":"", "B_ORANGE":"", "B_YELLOW":"",
      "B_BLACK":"", "B_CYAN":"","B_WHITE":"", "B_GREEN":"",
      "B_MAGENTA":"", "STATUS":"", "WINDOW":"", "INITTERM": "","ENDTERM":""]),
      "ansi": ([ "RESET":ANSI("0;37;40"), "BOLD":ANSI(1), "FLASH":ANSI(5),
      "BLACK":ANSI(30), "RED":ANSI(31), "GREEN":ANSI(32), "ORANGE":ANSI(33),
      "YELLOW":ANSI(1)+ANSI(33), "BLUE": ANSI(34), "CYAN":ANSI(36),
      "MAGENTA":ANSI(35), "BLACK":ANSI(30), "WHITE": ANSI(37),
      "B_RED":ANSI(41), "B_GREEN":ANSI(42), "B_ORANGE":ANSI(43),
      "B_YELLOW":ANSI(1)+ANSI(43), "B_BLUE":ANSI(44),
      "B_CYAN":ANSI(46), "B_BLACK":ANSI(40), "B_WHITE": ANSI(47),
      "B_MAGENTA":ANSI(45), "STATUS":"", "WINDOW":"", "INITTERM":ESCMAC("[H")+ESCMAC("[2J"),
      "ENDTERM":"" ]),
      "freedom": ([ "RESET": ESCMAC("G0"), "BOLD":ESCMAC("G@"), "FLASH":ESCMAC("G2"),
      "BLACK":"", "RED":"", "GREEN":"", "ORANGE":"", "YELLOW":"", "BLUE":"",
      "CYAN":"", "MAGENTA":"", "BLACK":"", "WHITE":"", "B_RED":ESCMAC("GD"),
      "B_GREEN": ESCMAC("GD"), "B_ORANGE":ESCMAC("G4"), "B_YELLOW":ESCMAC("G4"),
      "B_BLUE":ESCMAC("G4"), "B_CYAN":ESCMAC("GD"), "B_BLACK": ESCMAC("GD"),
      "B_WHITE":ESCMAC("G4"), "B_MAGENTA":("G4"), "STATUS":"", "WINDOW":"",
      "INITTERM":"", "ENDTERM":"" ]),
      "ansi-status": ([ "RESET": ANSI("0;37;40"), "BOLD":ANSI(1),
      "FLASH":ANSI(5), "BLACK":ANSI(30), "RED":ANSI(31),
      "GREEN":ANSI(32), "ORANGE":ANSI(33), "YELLOW":ANSI(33), "BLUE":ANSI(34),
       "CYAN": ANSI(36), "MAGENTA": ANSI(35), "BLACK":ANSI(30),
      "WHITE":ANSI(37), "B_RED":ANSI(41), "B_GREEN":ANSI(42),
      "B_ORANGE":ANSI(43), "B_YELLOW": ANSI(1)+ANSI(43), "B_BLUE":ANSI(44),
      "B_CYAN": ANSI(46), "B_BLACK":ANSI(40), "B_WHITE":ANSI(47),
      "B_MAGENTA":ANSI(45), "STATUS":ESCMAC("[23;24r")+ESCMAC(8),
      "WINDOW":ESCMAC(7)+ESCMAC("[0;22r")+ESCMAC("[22H\n"),
      "INITTERM":ESCMAC("[H")+ESCMAC("[J")+ESCMAC("[23;24r")+ESCMAC("23H\n"),
      "ENDTERM":ESCMAC("[0r")+ESCMAC("[H")+ESCMAC("[J") ]),
      "xterm": ([ "RESET": ESCMAC(">")+ESCMAC("[1;3;4;5;61")+ESCMAC("[?7h")+ESCMAC("[m"),
      "BOLD": ESCMAC("[7m"), "FLASH":ESCMAC("[5m$<2>"), "BLACK":ANSI(30),
      "RED":ANSI(31), "GREEN":ANSI(32), "ORANGE":ANSI(33), "YELLOW":ANSI(33),
      "BLUE":ANSI(34), "CYAN":ANSI(36), "MAGENTA":ANSI(35),"BLACK":ANSI(34),
      "WHITE":ANSI(38), "B_RED":ANSI(41), "B_GREEN":ANSI(42),
      "B_ORANGE":ANSI(43), "B_YELLOW":ANSI(43), "B_BLUE":ANSI(44),
      "B_CYAN":ANSI(46), "B_BLACK":ANSI(40), "B_WHITE": ANSI(47),
      "B_MAGENTA": ANSI(45), "STATUS":"", "WINDOW":"", "INITTERM":"",
      "ENDTERM":"" ]),
    ]);
}
mapping query_term_info(string type) {
    return (term_info[type] ? term_info[type] : term_info["unknown"]);
}

string *query_terms() { return keys(term_info); }

int query_term_support(string str) {
    return (term_info[str] ? 1 : 0);
}

#include <ansi.h>


string strip_ansi (string str) {
    int i,j ;
    string *strippable ;
// Initialize this array once at the start.
    strippable = ({ BLK,RED,GRN,YEL,BLU,MAG,CYN,WHT,
	HIK, HIR, HIG, HIY, HIB, HIM, HIC, HIW,
	BBLK, BRED, BGRN, BYEL, BBLU, BMAG, BCYN, BWHT,
	HBRED, HBGRN, HBYEL, HBBLU, HBMAG, HBCYN, HBWHT,
	NOR, BOLD, CLR, HOME, REF, BIGTOP, BIGBOT, SAVEC, REST,
	REVINDEX, SINGW, DBL, FRTOP, FRBOT, UNFR, BLINK, U ESC,
	REV ESC, HIREV ESC }) ;
// Find the first occurence of ESC in the string.
    i = strsrch(str,ESC) ;
// If none, return the string.
    if (i==-1) return str ;
// OK, there is one. Does it match a recognized ansi sequence?
// shortest legal sequence is 3 chars: longest is 9
    for (j=2;j<9;j++) {
// If we've hit the end of the string, then return the previous bit.
	if (i+j==strlen(str)) return str[0..i-1] ;
// If not, then see if the part of the string from i to i+j is ansi.
	if (member_array(str[i..i+j],strippable)>-1) {
// Found one. Delete it and look for another.
	    if (i==0) {
		str = str[j+1..<1] ;
	    } else {
		if (i+j==strlen(str)-1) {
		    str = str[0..i-1] ;
		} else {
	    	    str = str[0..i-1]+str[i+j+1..<1] ;
		}
	    }
	    return strip_ansi(str) ;
	}
    }
// If we get here, it means we found an ESC in the string but it didn't
// match any recognized ansi sequence.
// I'm not real sure what to do: I'm just going to strip out the ESC
// and let the rest through.
    if (i==0) {
	str = str[1..<1] ;
    } else {
	if (i=sizeof(str)-1) {
	    str = str[0..i-1] ;
	} else {
	    str = str[0..i-1] + str[i+1..<1] ;
	}
    }
    return strip_ansi(str) ;
}

//      Filter to remove the colour % ^ COLOR % ^ protocol from a string
//      and return the 'clean' string.
//      Author: Chuck @ Crossed Swords [pgregg@nyx10.cs.du.edu]
//      If you use this code please leave this header intact.

string filter_colours(string str) {
  string tmp;
   str = strip_ansi(str) ;
  while (sscanf(str, "%*s%%^%s%%^%*s", tmp) > 2)
    str = replace_string(str, "%^"+tmp+"%^", "");
  return str;
}