mimud/
mimud/doc/
# The ansi table is a very simple hash. The key is the
# string you want to recognize and the value is the
# ansi code that should replace the string.

$ansi_table = {"&r" => "\e[31m",
               "&g" => "\e[32m",
               "&y" => "\e[33m",
               "&b" => "\e[34m",
               "&m" => "\e[35m",
               "&c" => "\e[36m",
               "&w" => "\e[37m",
               "&R" => "\e[1;31m",
               "&G" => "\e[1;32m",
               "&Y" => "\e[1;33m",
               "&B" => "\e[1;34m",
               "&M" => "\e[1;35m",
               "&C" => "\e[1;36m",
               "&W" => "\e[1;37m",
               "&d" => "\e[0m"}

# This will simply run through a string and replace
# any parts matching a key in the ansi_table with
# the value assigned to the key. Afterwards it adds
# in a \e[0m to reset the color to default.

def parse_color(string)
  $ansi_table.each_key do |code|
    if string.include?(code)
      string.gsub!(code,$ansi_table[code])
    end
  end
  return (string + "\e[0m")
end