B
    `aù[7  ã            4   @   s  d Z ddlZddlmZ ddlmZmZmZmZm	Z	m
Z
mZmZmZmZ ddlmZ ddlmZ dgZeded	ed	ejd
edejd
ejdejd
ejdejdejdejd
ejdejdejdejd
ej dede
dej!dej"dej#dej$dej%dej	de	diZ&G dd„ deƒZ'dS )zï
    pygments.formatters.terminal
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Formatter for terminal output with ANSI sequences.

    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    N)Ú	Formatter)
ÚKeywordÚNameÚCommentÚStringÚErrorÚNumberÚOperatorÚGenericÚTokenÚ
Whitespace)Ú
ansiformat)Úget_choice_optÚTerminalFormatter)Ú r   )Ú	lightgrayÚdarkgray)ZtealZ	turquoise)ZdarkblueÚblue)ZpurpleZfuchsia)Z	darkgreenZgreen)Z_teal_Z_turquoise_)Z_darkgreen_Z_green_)r   r   )ZdarkredÚred)r   r   )Úbrownr   )r   r   )z**z**)z*purple*z	*fuchsia*)Ú_red_r   c               @   sH   e Zd ZdZdZddgZg Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ ZdS )r   aÛ  
    Format tokens with ANSI color sequences, for output in a text console.
    Color sequences are terminated at newlines, so that paging the output
    works correctly.

    The `get_style_defs()` method doesn't do anything special since there is
    no support for common styles.

    Options accepted:

    `bg`
        Set to ``"light"`` or ``"dark"`` depending on the terminal's background
        (default: ``"light"``).

    `colorscheme`
        A dictionary mapping token types to (lightbg, darkbg) color names or
        ``None`` (default: ``None`` = use builtin colorscheme).

    `linenos`
        Set to ``True`` to have line numbers on the terminal output as well
        (default: ``False`` = no line numbers).
    ZTerminalZterminalZconsolec             K   sP   t j| f|Ž t|dddgdƒdk| _| dd ¡p4t| _| dd¡| _d| _d S )NZbgZlightZdarkÚcolorschemeÚlinenosFr   )	r   Ú__init__r   ÚdarkbgÚgetÚTERMINAL_COLORSr   r   Ú_lineno)ÚselfZoptions© r   ú;lib/python3.7/site-packages/pygments/formatters/terminal.pyr   V   s    zTerminalFormatter.__init__c             C   sB   | j s4t|dƒr4t|dƒr4| ¡ r4tjdk r4|j | _ t | ||¡S )NÚencodingÚisatty)é   )r!   Úhasattrr"   ÚsysÚversion_infor   Úformat)r   ÚtokensourceÚoutfiler   r   r    r'   ^   s
    
zTerminalFormatter.formatc             C   s4   |  j d7  _ | d| j dkr"dp$d| j f ¡ d S )Né   z%s%04d: Ú
r   )r   Úwrite)r   r)   r   r   r    Ú_write_linenog   s    zTerminalFormatter._write_linenoc             C   s6   | j  |¡}x|d kr*|j}| j  |¡}qW || j S )N)r   r   Úparentr   )r   ÚttypeZcolorsr   r   r    Ú
_get_colork   s
    
zTerminalFormatter._get_colorc          	   C   s¦   | j r|  |¡ x€|D ]x\}}|  |¡}xd| d¡D ]V}|rT| t|| d¡ƒ¡ n| | d¡¡ | d¡r4| j r€|  |¡ q4| d¡ q4W qW | j r¢| d¡ d S )NTr+   )r   r-   r0   Ú
splitlinesr,   r   ÚrstripÚendswith)r   r(   r)   r/   ÚvalueZcolorÚliner   r   r    Úformat_unencodedu   s    


z"TerminalFormatter.format_unencodedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚaliasesÚ	filenamesr   r'   r-   r0   r6   r   r   r   r    r   ;   s   	
)(r:   r%   Zpygments.formatterr   Zpygments.tokenr   r   r   r   r   r   r	   r
   r   r   Zpygments.consoler   Zpygments.utilr   Ú__all__ZPreprocZTypeZWordZBuiltinZFunctionZ	NamespaceZClassÚ	ExceptionZ	DecoratorZVariableZConstantZ	AttributeZTagZDeletedZInsertedZHeadingZ
SubheadingZPromptr   r   r   r   r   r    Ú<module>
   sB   0