Formats a given Text object to make it appropriate for presentation to
the user, most importantly supporting line-folding for fixed width
displays. Details of formatting are configurable through assigning of
format options.
Formatting includes assigning faces, such as colours for curses
displays, to regions within the formatted output. In addition to faces
used by the formatter itself (eg. wrap markers and search highlighting)
input text can be tagged with a source, which is used to determine a
face. The formatter uses its association with a specific view to choose
specific faces.
|
__init__(self,
text)
Create a formatter for the given text with default formatting. |
|
|
|
get_format(self,
key)
Return the format option for the given key. |
|
|
|
set_format(self,
**kwargs)
Set formatting options. |
|
|
Text
|
get_text(self)
Returns:
Text being formatted. |
|
|
|
|
|
_clear_cache(self)
Forget any cached formatting work because something has changed. |
|
|
|
_get_face(self,
formatname=None,
facename=None)
Return a face for this specific view, specified either by its format
name or face name. |
|
|
|
_set_face(self,
region)
Set a face for a region, either using the region's source (eg. |
|
|
|
char_at(self,
coord)
Return the character at the given raw coordinates, or None. |
|
|
|
text_width(self)
The actual width for drawing text, accounting for wrap columns at
either end and a prefix. |
|
|
|
coord_line_start(self,
coord_src)
Modify the given raw coordinates to the beginning of the line. |
|
|
Coordinates
|
coord_diff(self,
coord_src,
coord_origin)
Given two sets of coordinates in raw text, determine the difference
between them in formatted coordinates. |
|
|
|
coord_visi(self,
coord_src,
coord_origin)
Given source and origin coordinates in raw text, with origin
representing the top left displayed position, return the coordinates
of source in the visible area, adjusted for formatting, wrap columns
and line prefix. |
|
|
int
|
coord_up_fline(self,
coord,
clamp,
count=1,
beyond=0)
Given raw coordinates, modify them so that they refer to a cursor
position in a formatted line above. |
|
|
int
|
coord_down_fline(self,
coord,
clamp,
count=1,
beyond=0)
Given raw coordinates, modify them so that they refer to the cursor
position in the formatted line directly below. |
|
|
MutableText
|
get_lines(self,
height,
display_pos=[ 0, 0] ,
search=None,
text=None,
more=None)
Get formatted lines suitable for drawing to a fix-width UI window. |
|
|
|
|
|
_format_line(self,
line,
trim,
prewrap,
lnum) |
|
|
|
_format_line_wrap(self,
line_fmt,
wrapface,
lc)
Internal function for _format_line() |
|
|
|
_format_line_clip(self,
line_fmt,
wrapface)
Internal function for _format_line() |
|
|
|
_format_line_start(self,
line_fmt,
wrapface,
lc,
trim,
prewrap)
Internal function for _format_line() |
|
|
|
_format_line_end(self,
line_fmt)
Internal function for _format_line() |
|
|
(coordinates,coordinates) or None
|
search(self,
pattern,
from_pos=[ 0, 0] ,
forward=True)
Search for a pattern within the raw text. |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|