fJc @ sL d Z d d k l Z d g Z d d d YZ d e f d YZ d S( s pygments.formatters.terminal256 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Formatter for 256-color terminal output with ANSI sequences. RGB-to-XTERM color conversion routines adapted from xterm256-conv tool (http://frexx.de/xterm-256-notes/data/xterm256-conv2.tar.bz2) by Wolfgang Frisch. Formatter version 1. :copyright: Copyright 2006-2009 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. i( t Formattert Terminal256Formattert EscapeSequencec B s8 e Z d d e e d Z d Z d Z d Z RS( c C s( | | _ | | _ | | _ | | _ d S( N( t fgt bgt boldt underline( t selfR R R R ( ( sC /usr/lib/python2.6/site-packages/pygments/formatters/terminal256.pyt __init__" s c C s' t | o d d i | d Sd S( Ns [t ;t mt ( t lent join( R t attrs( ( sC /usr/lib/python2.6/site-packages/pygments/formatters/terminal256.pyt escape( s c C s g } | i d j o! | i d d d | i f n | i d j o! | i d d d | i f n | i o | i d n | i o | i d n | i | S( Nt 38t 5s %it 48t 01t 04( R t Nonet extendR R t appendR R ( R R ( ( sC /usr/lib/python2.6/site-packages/pygments/formatters/terminal256.pyt color_string- s !! c C sz g } | i d j o | i d n | i d j o | i d n | i p | i o | i d n | i | S( Nt 39t 49t 00( R R R R R R R ( R R ( ( sC /usr/lib/python2.6/site-packages/pygments/formatters/terminal256.pyt reset_string9 s N( t __name__t __module__R t FalseR R R R ( ( ( sC /usr/lib/python2.6/site-packages/pygments/formatters/terminal256.pyR ! s c B sh e Z d Z d Z d d d g Z g Z d Z d Z d Z d Z d Z d Z d Z RS( sY Format tokens with ANSI color sequences, for output in a 256-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly. The formatter takes colors from a style defined by the `style` option and converts them to nearest ANSI 256-color escape sequences. Bold and underline attributes from the style are preserved (and displayed). *New in Pygments 0.9.* Options accepted: `style` The style to use, can be a string or a Style subclass (default: ``'default'``). t Terminal256t terminal256t console256t 256c K sa t i | | g | _ h | _ h | _ d | j | _ d | j | _ | i | i d S( Nt noboldt nounderline( R R t xterm_colorst best_matcht style_stringt useboldt useunderlinet _build_color_tablet _setup_styles( R t options( ( sC /usr/lib/python2.6/site-packages/pygments/formatters/terminal256.pyR Y s c C s | i i d | i i d | i i d | i i d | i i d | i i d | i i d | i i d | i i d | i i d | i i d | i i d | i i d | i i d | i i d! | i i d" d# } x_ t d D]Q } | | d d } | | d d } | | d } | i i | | | f qWx> t d d D]- } d | d } | i i | | | f qxWd S($ Ni i i i i i i\ i_ i i i i i$ i i i i i ( i i i ( i i i ( i i i ( i i i ( i i i ( i i i ( i i i ( i i i ( i i i ( i i i ( i i i ( i i i ( i\ i\ i ( i i i ( i i i ( i i i ( i i_ i i i i ( R&