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

# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

 
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:
__bool__ = __nonzero__(self)
__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:
addch(self, *args)
addnstr(self, *args)
addstr(self, *args)
color(self, *keys)
Change the colors from now on.
color_at(self, y, x, wid, *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 = {}

 
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:
__bool__ = __nonzero__(self)
Always True
__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:
addch(self, *args)
addnstr(self, *args)
addstr(self, *args)
color(self, *keys)
Change the colors from now on.
color_at(self, y, x, wid, *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 = {}