Package hsh :: Package curses_display :: Module view :: Class View
[hide private]
[frames] | no frames]

Class View

object --+
         |
        View
Known Subclasses:

An abstract superclass for anything that can be displayed in a simple curses window and can receive input.

Input keystrokes are bound to functions on the instance using a keybinding mechanism and configuration file. An instance can be named by setting the name member variable, which will affect keybinding assignment.

The default draw() method includes support for drawing a header, and skipping the draw entirely if it's not needed. The *_dirty() methods manage skipping the draw. The header is defined by the header_fmt member and the header_info() method, or just overriding the draw_header() method.

Instance Methods [hide private]
 
__init__(self, display, name=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
putch(self, ch, esc=False)
 
get_name(self)
 
has_terminal(self)
 
wants_terminal(self)
Return 0 if the terminal is not required, 1 if the terminal is required with curses still enabled, 2 if curses should be deinitialized.
 
set_has_terminal(self, newval)
 
min_height(self)
 
min_width(self)
 
set_focus(self, has_focus)
Used by display to inform a View that it is getting or losing focus, as indicated by the boolean has_focus.
 
set_visible_job(self, job)
Called by the display object to inform each view that a new job is the main visible job.
 
header_info(self)
Return a dict containing details to include in the header.
 
is_dirty(self)
 
set_dirty(self, newdirty='all')
dirty can be None, "append", "all".
 
get_face(self, facename)
Return the face for the given name specific to this view.
 
draw_cursor(self, win)
Default implementation does not draw a cursor.
 
draw_header(self, win)
Draw the header into the provided window.
 
draw_line(self, line, yoff, win)
 
_content_win(self, win)
Given the window for the whole view, derive one for the non-header portion.
boolean
draw(self, win, force_redraw, search=None)
This default implementation of draw() is purely illustrative, and only draws the header.
 
current_job(self)
Return the current job associated with this view, or None if there is nothing appropriate.
 
move_search(self, pattern, forward=True, from_end=False)
Given a regular expression object, move the position of the cursor to its next match.
 
next_window(self, ki)
 
next_job(self, ki)
 
prev_job(self, ki)
 
restart_job(self, ki)
 
edit_job(self, ki)
 
change_view(self, ki, name)
 
show_search(self, ki)
 
quit(self, ki)
 
delete_job(self, ki)
 
move_left(self, ki)
 
move_right(self, ki)
 
move_up(self, ki)
 
move_down(self, ki)
 
move_start(self, ki)
 
move_end(self, ki)
 
move_top(self, ki)
 
move_bottom(self, ki)
 
page_up(self, ki)
 
page_down(self, ki)
 
delete_left(self, ki)
 
delete_right(self, ki)
 
delete_line(self, ki)
 
insert(self, ki)
 
paste(self, ki)
 
toggle_wrap(self, ki)

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, display, name=None)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

set_focus(self, has_focus)

 

Used by display to inform a View that it is getting or losing focus, as indicated by the boolean has_focus. Return True if the change is accepted, False otherwise.

set_visible_job(self, job)

 

Called by the display object to inform each view that a new job is the main visible job. The SessionList in particular updates itself based on this information.

draw_header(self, win)

 

Draw the header into the provided window.

The header is arbitrarily limited to 5 lines, a restriction which should be lifted by providing a way to switch between header wrap and trim displays.

draw(self, win, force_redraw, search=None)

 

This default implementation of draw() is purely illustrative, and only draws the header. Subclasses will certainly override it.

Parameters:
  • force_redraw - If true the view object shouldn't try to optimize.
  • search - a regular expression object whose matches should be highlighted.
Returns: boolean
True means something was drawn or the cursor position has changed. This result is used by the main drawing loop to decide whether to draw the cursor, or take a nap.

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

 

Given a regular expression object, move the position of the cursor to its next match. If forward is False, then move to the next search backwards. If from_end is true, then search from the top or bottom rather than the current cursor position. Return True if a match was found.