ranger.gui.displayable
index
/home/hut/work/ranger/ranger/gui/displayable.py

# Copyright (c) 2009, 2010 hut <hut@lavabit.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

 
Modules
       
_curses

 
Classes
       
ranger.gui.curses_shortcuts.CursesShortcuts(ranger.shared.settings.SettingsAware)
Displayable(ranger.shared.EnvironmentAware, ranger.shared.FileManagerAware, ranger.gui.curses_shortcuts.CursesShortcuts)
DisplayableContainer
ranger.shared.EnvironmentAware(ranger.shared.Awareness)
Displayable(ranger.shared.EnvironmentAware, ranger.shared.FileManagerAware, ranger.gui.curses_shortcuts.CursesShortcuts)
DisplayableContainer
ranger.shared.FileManagerAware(ranger.shared.Awareness)
Displayable(ranger.shared.EnvironmentAware, ranger.shared.FileManagerAware, ranger.gui.curses_shortcuts.CursesShortcuts)
DisplayableContainer

 
class Displayable(ranger.shared.EnvironmentAware, ranger.shared.FileManagerAware, ranger.gui.curses_shortcuts.CursesShortcuts)
    Displayables are objects which are displayed on the screen.
 
This is just the abstract class, defining basic operations
such as resizing, printing, changing colors.
Subclasses of displayable can extend these methods:
 
draw() -- draw the object. Is only called if visible.
poke() -- is called just before draw(), even if not visible.
finalize() -- called after all objects finished drawing.
click(event) -- called with a MouseEvent. This is called on all
        visible objects under the mouse, until one returns True.
press(key) -- called after a key press on focused objects.
destroy() -- called before destroying the displayable object
 
Additionally, there are these methods:
 
__contains__(item) -- is the item (y, x) inside the widget?
 
These attributes are set:
 
Modifiable:
        focused -- Focused objects receive press() calls.
        visible -- Visible objects receive draw() and finalize() calls
        need_redraw -- Should the widget be redrawn? This variable may
                be set at various places in the script and should eventually be
                handled (and unset) in the draw() method.
 
Read-Only: (i.e. reccomended not to change manually)
        win -- the own curses window object
        parent -- the parent (DisplayableContainer) object or None
        x, y, wid, hei -- absolute coordinates and boundaries
        settings, fm, env -- inherited shared variables
 
 
Method resolution order:
Displayable
ranger.shared.EnvironmentAware
ranger.shared.FileManagerAware
ranger.shared.Awareness
ranger.gui.curses_shortcuts.CursesShortcuts
ranger.shared.settings.SettingsAware
builtins.object

Methods defined here:
__contains__(self, item)
Is item inside the boundaries?
item can be an iterable like [y, x] or an object with x and y methods.
__init__(self, win, env=None, fm=None, settings=None)
__nonzero__(self)
Always True
__str__(self)
click(self, event)
Called when a mouse key is pressed and self.focused is True.
Override this!
contains_point(self, y, x)
Test whether the point (with absolute coordinates) lies
within the boundaries of this object.
destroy(self)
Called when the object is destroyed.
Override this!
draw(self)
Draw the object. Called on every main iteration if visible.
Containers should call draw() on their contained objects here.
Override this!
finalize(self)
Called after every displayable is done drawing.
Override this!
poke(self)
Called before drawing, even if invisible
press(self, key)
Called when a key is pressed and self.focused is True.
Override this!
resize(self, y, x, hei=None, wid=None)
Resize the widget

Data and other attributes inherited from ranger.shared.EnvironmentAware:
env = None

Data and other attributes inherited from ranger.shared.FileManagerAware:
fm = None

Data descriptors inherited from ranger.shared.Awareness:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from ranger.gui.curses_shortcuts.CursesShortcuts:
addnstr(self, *args)
addstr(self, *args)
color(self, keylist=None, *keys)
Change the colors from now on.
color_at(self, y, x, wid, keylist=None, *keys)
Change the colors at the specified position
color_reset(self)
Change the colors to the default colors

Data and other attributes inherited from ranger.shared.settings.SettingsAware:
settings = <ranger.ext.openstruct.OpenStruct object at 0x7f28d0aa5bd0>

 
class DisplayableContainer(Displayable)
    DisplayableContainers are Displayables which contain other Displayables.
 
This is also an abstract class. The methods draw, poke, finalize,
click, press and destroy are extended here and will recursively
call the function on all contained objects.
 
New methods:
 
add_child(object) -- add the object to the container.
remove_child(object) -- remove the object from the container.
 
New attributes:
 
container -- a list with all contained objects (rw)
 
 
Method resolution order:
DisplayableContainer
Displayable
ranger.shared.EnvironmentAware
ranger.shared.FileManagerAware
ranger.shared.Awareness
ranger.gui.curses_shortcuts.CursesShortcuts
ranger.shared.settings.SettingsAware
builtins.object

Methods defined here:
__init__(self, win, env=None, fm=None, settings=None)
add_child(self, obj)
Add the objects to the container.
click(self, event)
Recursively called on objects in container
destroy(self)
Recursively called on objects in container
draw(self)
Recursively called on visible objects in container
finalize(self)
Recursively called on visible objects in container
poke(self)
Recursively called on objects in container
press(self, key)
Recursively called on objects in container
remove_child(self, obj)
Remove the object from the container.

Methods inherited from Displayable:
__contains__(self, item)
Is item inside the boundaries?
item can be an iterable like [y, x] or an object with x and y methods.
__nonzero__(self)
Always True
__str__(self)
contains_point(self, y, x)
Test whether the point (with absolute coordinates) lies
within the boundaries of this object.
resize(self, y, x, hei=None, wid=None)
Resize the widget

Data and other attributes inherited from ranger.shared.EnvironmentAware:
env = None

Data and other attributes inherited from ranger.shared.FileManagerAware:
fm = None

Data descriptors inherited from ranger.shared.Awareness:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from ranger.gui.curses_shortcuts.CursesShortcuts:
addnstr(self, *args)
addstr(self, *args)
color(self, keylist=None, *keys)
Change the colors from now on.
color_at(self, y, x, wid, keylist=None, *keys)
Change the colors at the specified position
color_reset(self)
Change the colors to the default colors

Data and other attributes inherited from ranger.shared.settings.SettingsAware:
settings = <ranger.ext.openstruct.OpenStruct object at 0x7f28d0aa5bd0>