Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.support.pygments.formatters.terminal.TerminalFormatter Class Reference
Inheritance diagram for MoinMoin.support.pygments.formatters.terminal.TerminalFormatter:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.support.pygments.formatters.terminal.TerminalFormatter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def format
def format_unencoded

Public Attributes

 darkbg
 colorscheme
 encoding

Static Public Attributes

string name = 'Terminal'
list aliases = ['terminal', 'console']
list filenames = []

Detailed Description

Definition at line 56 of file terminal.py.


Constructor & Destructor Documentation

Definition at line 79 of file terminal.py.

00079 
00080     def __init__(self, **options):
00081         Formatter.__init__(self, **options)
00082         self.darkbg = get_choice_opt(options, 'bg',
00083                                      ['light', 'dark'], 'light') == 'dark'
00084         self.colorscheme = options.get('colorscheme', None) or TERMINAL_COLORS


Member Function Documentation

def MoinMoin.support.pygments.formatters.terminal.TerminalFormatter.format (   self,
  tokensource,
  outfile 
)

Definition at line 85 of file terminal.py.

00085 
00086     def format(self, tokensource, outfile):
00087         # hack: if the output is a terminal and has an encoding set,
00088         # use that to avoid unicode encode problems
00089         if not self.encoding and hasattr(outfile, "encoding") and \
00090            hasattr(outfile, "isatty") and outfile.isatty():
00091             self.encoding = outfile.encoding
00092         return Formatter.format(self, tokensource, outfile)

Definition at line 93 of file terminal.py.

00093 
00094     def format_unencoded(self, tokensource, outfile):
00095         for ttype, value in tokensource:
00096             color = self.colorscheme.get(ttype)
00097             while color is None:
00098                 ttype = ttype[:-1]
00099                 color = self.colorscheme.get(ttype)
00100             if color:
00101                 color = color[self.darkbg]
00102                 spl = value.split('\n')
00103                 for line in spl[:-1]:
00104                     if line:
00105                         outfile.write(ansiformat(color, line))
00106                     outfile.write('\n')
00107                 if spl[-1]:
00108                     outfile.write(ansiformat(color, spl[-1]))
00109             else:
00110                 outfile.write(value)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 76 of file terminal.py.

Definition at line 83 of file terminal.py.

Definition at line 81 of file terminal.py.

Definition at line 90 of file terminal.py.

Definition at line 77 of file terminal.py.

Definition at line 75 of file terminal.py.


The documentation for this class was generated from the following file: