hsh :: content :: text_viewport :: TextViewport :: Class TextViewport
[hide private]
[frames] | no frames]

Class TextViewport

                  object --+    
                           |    
text_formatter.TextFormatter --+
                               |
                              TextViewport

Extends TextFormatter with functionality for tracking a displayed area within the formatted text, tracking a cursor, and regular expression search through the text.

Instance Methods [hide private]
 
__init__(self, text)
Create a viewport on the given Text object positioned at [0,0]
 
get_tail(self)
 
set_tail(self, tail)
Instruct this viewport to start or stop tailing the content.
 
set_size(self, height, width)
Set the size of this viewport, adjusting position to ensure that the cursor is visible.
 
_align_display(self)
If necessary, adjust display_pos to ensure that cursor_pos is within the viewport.
 
_len_curline(self)
Return the length of the line containing the cursor.
MutableText
get_lines(self, search=None)
Get formatted lines appropriate for drawing to a UI window.
 
_get_trim(self)
Easy access to the trim format.
 
_set_trim(self, nt)
Coordinates
get_cursor_pos(self)
Get the cursor position relative to the top left corner of the output from get_lines().
Coordinates
get_end_pos(self)
Get the text end position relative to the top left corner of the output from get_lines().
 
move_cursor_left(self, count)
 
move_display_left(self, count)
 
move_cursor_right(self, count)
 
move_display_right(self, count)
 
move_cursor_up(self, count)
 
move_display_up(self, count)
 
move_cursor_down(self, count)
 
move_display_down(self, count)
 
move_cursor_start(self)
 
move_display_start(self)
 
move_cursor_end(self)
 
move_display_end(self)
 
move_top(self)
 
move_bottom(self)
 
move_search(self, pattern, forward=True, from_end=False)
Update the display and cursor positions to the next match of the given pattern.

Inherited from text_formatter.TextFormatter: char_at, coord_diff, coord_down_fline, coord_line_start, coord_up_fline, coord_visi, get_format, get_text, search, set_format, set_text, text_width

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  _trim
Easy access to the trim format.

Inherited from object: __class__

Method Details [hide private]

__init__(self, text)
(Constructor)

 

Create a viewport on the given Text object positioned at [0,0]

Parameters:
  • text (Text) - The text to view.
Overrides: object.__init__

set_tail(self, tail)

 

Instruct this viewport to start or stop tailing the content.

Parameters:
  • tail (boolean) - If True, always show the end of the content.

_align_display(self)

 

If necessary, adjust display_pos to ensure that cursor_pos is within the viewport. This is necessary when the viewport changes size, or after cursor movement.

get_lines(self, search=None)

 

Get formatted lines appropriate for drawing to a UI window.

Parameters:
  • search (regular expression) - Optional regexp to be highlighted in results.
Returns: MutableText
Appropriately formatted text, preserving any formatting regions of the original source. Columns containing line continuation and clipping markers are added to either side of the output. Each contained TextLine its line_number variable set to the number of the line from which it originated, and regions are updated to include face information based on input channel.
Overrides: text_formatter.TextFormatter.get_lines

get_cursor_pos(self)

 

Get the cursor position relative to the top left corner of the output from get_lines().

Returns: Coordinates
cursor position

get_end_pos(self)

 

Get the text end position relative to the top left corner of the output from get_lines().

Returns: Coordinates
cursor position

move_search(self, pattern, forward=True, from_end=False)

 

Update the display and cursor positions to the next match of the given pattern.

Parameters:
  • pattern (compiled regexp) - Pattern to search for
  • forward - True to search forward, False for backwards
  • from_end - True means start searching from the beginning/end of the text instead of the display position

Property Details [hide private]

_trim

Easy access to the trim format.

Get Method:
_get_trim(self) - Easy access to the trim format.
Set Method:
_set_trim(self, nt)