### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# utils.coloransi

## Module: `utils.coloransi`

Inheritance diagram for `IPython.utils.coloransi`:

Tools for coloring text in ANSI terminals.

## Classes

### `ColorScheme`

class `IPython.utils.coloransi.``ColorScheme`(_ColorScheme__scheme_name_, colordict=None, **colormap)

  Generic color scheme class. Just a name and a Struct.

  `__init__`(_ColorScheme__scheme_name_, colordict=None, **colormap)
  `copy`(name=None)

    Return a full copy of the object, optionally renaming it.

### `ColorSchemeTable`

class `IPython.utils.coloransi.``ColorSchemeTable`(scheme_list=None, default_scheme='')

  Bases: `dict`

  General class to handle tables of color schemes.

  It’s basically a dict of color schemes with a couple of shorthand attributes and some convenient methods.

  active_scheme_name -> obvious active_colors -> actual color table of the active scheme

  `__init__`(scheme_list=None, default_scheme='')

    Create a table of color schemes.

    The table can be created empty and manually filled or it can be created with a list of valid color schemes AND the specification for the default active scheme.

  `add_scheme`(new_scheme)

    Add a new color scheme to the table.

  `clear`

    D.clear() -> None. Remove all items from D.

  `copy`()

    Return full copy of object

  static `fromkeys`(S[, v]) → New dict with keys from S and values equal to v.

    v defaults to None.

  `get`

    D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.

  `has_key`

    D.has_key(k) -> True if D has a key k, else False

  `items`

    D.items() -> list of D’s (key, value) pairs, as 2-tuples

  `iteritems`

    D.iteritems() -> an iterator over the (key, value) items of D

  `iterkeys`

    D.iterkeys() -> an iterator over the keys of D

  `itervalues`

    D.itervalues() -> an iterator over the values of D

  `keys`

    D.keys() -> list of D’s keys

  `pop`

    D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised

  `popitem`

    D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.

  `set_active_scheme`(scheme, case_sensitive=0)

    Set the currently active scheme.

    Names are by default compared in a case-insensitive way, but this can be changed by setting the parameter case_sensitive to true.

  `setdefault`

    D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D

  `update`

    D.update(E, **F) -> None. Update D from dict/iterable E and F. If E has a .keys() method, does: for k in E: D[k] = E[k] If E lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

  `values`

    D.values() -> list of D’s values

### `InputTermColors`

class `IPython.utils.coloransi.``InputTermColors`

  Color escape sequences for input prompts.

  This class is similar to TermColors, but the escapes are wrapped in and so that readline can properly know the length of each line and can wrap lines accordingly. Use this class for any colored text which needs to be used in input prompts, such as in calls to raw_input().

  This class defines the escape sequences for all the standard (ANSI?) colors in terminals. Also defines a NoColor escape which is just the null string, suitable for defining ‘dummy’ color schemes in terminals which get confused by color escapes.

  This class should be used as a mixin for building color schemes.

  `Black` = '\x01\x1b[0;30m\x02'
  `BlinkBlack` = '\x01\x1b[5;30m\x02'
  `BlinkBlue` = '\x01\x1b[5;34m\x02'
  `BlinkCyan` = '\x01\x1b[5;36m\x02'
  `BlinkGreen` = '\x01\x1b[5;32m\x02'
  `BlinkLightGray` = '\x01\x1b[5;37m\x02'
  `BlinkPurple` = '\x01\x1b[5;35m\x02'
  `BlinkRed` = '\x01\x1b[5;31m\x02'
  `BlinkYellow` = '\x01\x1b[5;33m\x02'
  `Blue` = '\x01\x1b[0;34m\x02'
  `Brown` = '\x01\x1b[0;33m\x02'
  `Cyan` = '\x01\x1b[0;36m\x02'
  `DarkGray` = '\x01\x1b[1;30m\x02'
  `Green` = '\x01\x1b[0;32m\x02'
  `LightBlue` = '\x01\x1b[1;34m\x02'
  `LightCyan` = '\x01\x1b[1;36m\x02'
  `LightGray` = '\x01\x1b[0;37m\x02'
  `LightGreen` = '\x01\x1b[1;32m\x02'
  `LightPurple` = '\x01\x1b[1;35m\x02'
  `LightRed` = '\x01\x1b[1;31m\x02'
  `NoColor` = ''
  `Normal` = '\x01\x1b[0m\x02'
  `Purple` = '\x01\x1b[0;35m\x02'
  `Red` = '\x01\x1b[0;31m\x02'
  `White` = '\x01\x1b[1;37m\x02'
  `Yellow` = '\x01\x1b[1;33m\x02'

### `TermColors`

class `IPython.utils.coloransi.``TermColors`

  Color escape sequences.

  This class defines the escape sequences for all the standard (ANSI?) colors in terminals. Also defines a NoColor escape which is just the null string, suitable for defining ‘dummy’ color schemes in terminals which get confused by color escapes.

  This class should be used as a mixin for building color schemes.

  `Black` = '\x1b[0;30m'
  `BlinkBlack` = '\x1b[5;30m'
  `BlinkBlue` = '\x1b[5;34m'
  `BlinkCyan` = '\x1b[5;36m'
  `BlinkGreen` = '\x1b[5;32m'
  `BlinkLightGray` = '\x1b[5;37m'
  `BlinkPurple` = '\x1b[5;35m'
  `BlinkRed` = '\x1b[5;31m'
  `BlinkYellow` = '\x1b[5;33m'
  `Blue` = '\x1b[0;34m'
  `Brown` = '\x1b[0;33m'
  `Cyan` = '\x1b[0;36m'
  `DarkGray` = '\x1b[1;30m'
  `Green` = '\x1b[0;32m'
  `LightBlue` = '\x1b[1;34m'
  `LightCyan` = '\x1b[1;36m'
  `LightGray` = '\x1b[0;37m'
  `LightGreen` = '\x1b[1;32m'
  `LightPurple` = '\x1b[1;35m'
  `LightRed` = '\x1b[1;31m'
  `NoColor` = ''
  `Normal` = '\x1b[0m'
  `Purple` = '\x1b[0;35m'
  `Red` = '\x1b[0;31m'
  `White` = '\x1b[1;37m'
  `Yellow` = '\x1b[1;33m'

## Function

`IPython.utils.coloransi.``make_color_table`(in_class)

  Build a set of color attributes in a class.

  Helper function for building the *TermColors classes.

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »