orca.braille (version 1995, $Date$)
index
/usr/lib/python2.5/site-packages/orca/braille.py

A very experimental approach to the refreshable Braille display.  This
module treats each line of the display as a sequential set of regions, where
each region can potentially backed by an Accessible object.  Depending upon
the Accessible object, the cursor routing keys can be used to perform
operations on the Accessible object, such as invoking default actions or
moving the text caret.

 
Modules
       
orca.atspi
brlapi
orca.brlmon
orca.debug
orca.eventsynthesizer
logging
orca.settings
signal
threading
orca.util

 
Classes
       
Line
Region
Component
ReviewComponent
ReviewText
Text

 
class Component(Region)
    A subclass of Region backed by an accessible.  This Region will react
to any cursor routing key events and perform the default action on the
accessible, if a default action exists.
 
  Methods defined here:
__init__(self, accessible, string, cursorOffset=0)
Creates a new Component.
 
Arguments:
- accessible: the accessible
- string: the string to use to represent the component
- cursorOffset: a 0-based index saying where to draw the cursor
                for this Region if it gets focus.
processCursorKey(self, offset)
Processes a cursor key press on this Component.  The offset is
0-based, where 0 represents the leftmost character of string
associated with this region.  Note that the zeroeth character may have
been scrolled off the display.

 
class Line
    A horizontal line on the display.  Each Line is composed of a sequential
set of Regions.
 
  Methods defined here:
__init__(self, region=None)
addRegion(self, region)
addRegions(self, regions)
getLineInfo(self)
Computes the complete string for this line as well as a
0-based index where the focused region starts on this line.
If the region with focus is not on this line, then the index
will be -1.
 
Returns [string, offsetIndex]
getRegionAtOffset(self, offset)
Finds the Region at the given 0-based offset in this line.
 
Returns the [region, offsetinregion] where the region is
the region at the given offset, and offsetinregion is the
0-based offset from the beginning of the region, representing
where in the region the given offset is.
processCursorKey(self, offset)
Processes a cursor key press on this Component.  The offset is
0-based, where 0 represents the leftmost character of string
associated with this line.  Note that the zeroeth character may have
been scrolled off the display.

 
class Region
    A Braille region to be displayed on the display.  The width of
each region is determined by its string.
 
  Methods defined here:
__init__(self, string, cursorOffset=0)
Creates a new Region containing the given string.
 
Arguments:
- string: the string to be displayed
- cursorOffset: a 0-based index saying where to draw the cursor
                for this Region if it gets focus.
processCursorKey(self, offset)
Processes a cursor key press on this Component.  The offset is
0-based, where 0 represents the leftmost character of string
associated with this region.  Note that the zeroeth character may have
been scrolled off the display.

 
class ReviewComponent(Component)
    A subclass of Component that is to be used for flat review mode.
 
 
Method resolution order:
ReviewComponent
Component
Region

Methods defined here:
__init__(self, accessible, string, cursorOffset, zone)
Creates a new Component.
 
Arguments:
- accessible: the accessible
- string: the string to use to represent the component
- cursorOffset: a 0-based index saying where to draw the cursor
                for this Region if it gets focus.
- zone: the flat review Zone associated with this component

Methods inherited from Component:
processCursorKey(self, offset)
Processes a cursor key press on this Component.  The offset is
0-based, where 0 represents the leftmost character of string
associated with this region.  Note that the zeroeth character may have
been scrolled off the display.

 
class ReviewText(Region)
    A subclass of Region backed by a Text object.  This Region will
does not react to the caret changes, but will react if one updates
the cursorPosition.  This class is meant to be used by flat review
mode to show the current character position.
 
  Methods defined here:
__init__(self, accessible, string, lineOffset, zone)
Creates a new Text region.
 
Arguments:
- accessible: the accessible that implements AccessibleText
- string: the string to use to represent the component
- lineOffset: the character offset into where the text line starts
- zone: the flat review Zone associated with this component
processCursorKey(self, offset)
Processes a cursor key press on this Component.  The offset is
0-based, where 0 represents the leftmost character of text associated
with this region.  Note that the zeroeth character may have been
scrolled off the display.

 
class Text(Region)
    A subclass of Region backed by a Text object.  This Region will
react to any cursor routing key events by positioning the caret in
the associated text object. The line displayed will be the
contents of the text object preceded by an optional label.
[[[TODO: WDW - need to add in text selection capabilities.  Logged
as bugzilla bug 319754.]]]
 
  Methods defined here:
__init__(self, accessible, label=None)
Creates a new Text region.
 
Arguments:
- accessible: the accessible that implements AccessibleText
- label: an optional label to display
processCursorKey(self, offset)
Processes a cursor key press on this Component.  The offset is
0-based, where 0 represents the leftmost character of text associated
with this region.  Note that the zeroeth character may have been
scrolled off the display.
repositionCursor(self)
Attempts to reposition the cursor in response to a new
caret position.  If it is possible (i.e., the caret is on
the same line as it was), reposition the cursor and return
True.  Otherwise, return False.

 
Functions
       
addLine(line)
Adds a line to the logical display for painting.  The line is added to
the end of the current list of known lines.  It is necessary for the
viewport to be over the lines and for refresh to be called for the new
line to be painted.
 
Arguments:
- line: an instance of Line to add.
clear()
Clears the logical structure, but keeps the Braille display as is
(until a refresh operation).
displayMessage(message, cursor=-1)
Displays a single line, setting the cursor to the given position,
ensuring that the cursor is in view.
 
Arguments:
- message: the string to display
- cursor: the 0-based cursor position, where -1 (default) means no cursor
displayRegions(regionInfo)
Displays a list of regions on a single line, setting focus to the
   specified region.  The regionInfo parameter is something that is
   typically returned by a call to braillegenerator.getBrailleRegions.
 
Arguments:
- regionInfo: a list where the first element is a list of regions
              to display and the second element is the region
              with focus (must be in the list from element 0)
getRegionAtCell(cell)
Given a 1-based cell offset, return the braille region
associated with that cell in the form of [region, offsetinregion]
where 'region' is the region associated with the cell and
'offsetinregion' is the 0-based offset of where the cell is
in the region, where 0 represents the beginning of the region,
getShowingLine()
Returns the Line that is currently being painted on the display.
init(callback=None, tty=7)
Initializes the braille module, connecting to the BrlTTY driver.
 
Arguments:
- callback: the method to call with a BrlTTY input event.
- tty: the tty port to take ownership of (default = 7)
Returns True if the initialization procedure was run or False if this
module has already been initialized.
panLeft(panAmount=0)
Pans the display to the left, limiting the pan to the beginning
of the line being displayed.
 
Arguments:
- panAmount: the amount to pan.  A value of 0 means the entire
             width of the physical display.
 
Returns True if a pan actually happened.
panRight(panAmount=0)
Pans the display to the right, limiting the pan to the length
of the line being displayed.
 
Arguments:
- panAmount: the amount to pan.  A value of 0 means the entire
             width of the physical display.
 
Returns True if a pan actually happened.
panToOffset(offset)
Automatically pan left or right to make sure the current offset is
showing.
refresh(panToCursor=True, targetCursorCell=0)
Repaints the Braille on the physical display.  This clips the entire
logical structure by the viewport and also sets the cursor to the
appropriate location.  [[[TODO: WDW - I'm not sure how BrlTTY handles
drawing to displays with more than one line, so I'm only going to handle
drawing one line right now.]]]
 
Arguments:
 
- panToCursor: if True, will adjust the viewport so the cursor is
               showing.
- targetCursorCell: Only effective if panToCursor is True.
                    0 means automatically place the cursor somewhere
                    on the display so as to minimize movement but
                    show as much of the line as possible.  A positive
                    value is a 1-based target cell from the left side
                    of the display and a negative value is a 1-based
                    target cell from the right side of the display.
returnToRegionWithFocus(inputEvent=None)
Pans the display so the region with focus is displayed.
 
Arguments:
- inputEvent: the InputEvent instance that caused this to be called.
 
Returns True to mean the command should be consumed.
setFocus(region, panToFocus=True)
Specififes the region with focus.  This region will be positioned
at the home position if panToFocus is True.
 
Arguments:
- region: the given region, which much be in a line that has been
          added to the logical display
setLines(lines)
setupKeyRanges(keys)
Hacky method to tell BrlTTY what to send and not send us via
the readKey method.  This only works with BrlTTY v3.8 and better.
 
Arguments:
-keys: a list of BrlAPI commands.
shutdown()
Shuts down the braille module.   Returns True if the shutdown procedure
was run or False if this module has not been initialized.

 
Data
        BRL_FLG_REPEAT_DELAY = 4194304
BRL_FLG_REPEAT_INITIAL = 8388608
CMD_ATTRBLINK = 43
CMD_ATTRDN = 8
CMD_ATTRUP = 7
CMD_ATTRVIS = 42
CMD_BACK = 30
CMD_BOT = 10
CMD_BOT_LEFT = 12
CMD_CAPBLINK = 44
CMD_CHRLT = 19
CMD_CHRRT = 20
CMD_CSRBLINK = 41
CMD_CSRHIDE = 38
CMD_CSRJMP_VERT = 65
CMD_CSRSIZE = 40
CMD_CSRTRK = 39
CMD_CSRVIS = 37
CMD_DISPMD = 32
CMD_FREEZE = 31
CMD_FWINLT = 23
CMD_FWINLTSKIP = 25
CMD_FWINRT = 24
CMD_FWINRTSKIP = 26
CMD_HELP = 46
CMD_HOME = 29
CMD_HWINLT = 21
CMD_HWINRT = 22
CMD_INFO = 47
CMD_LEARN = 48
CMD_LNBEG = 27
CMD_LNDN = 2
CMD_LNEND = 28
CMD_LNUP = 1
CMD_MAX = 68
CMD_MENU_FIRST_ITEM = 52
CMD_MENU_LAST_ITEM = 53
CMD_MENU_NEXT_ITEM = 55
CMD_MENU_NEXT_SETTING = 57
CMD_MENU_PREV_ITEM = 54
CMD_MENU_PREV_SETTING = 56
CMD_MUTE = 61
CMD_NOOP = 0
CMD_NXDIFLN = 6
CMD_NXPGRPH = 14
CMD_NXPROMPT = 16
CMD_NXSEARCH = 18
CMD_PASTE = 66
CMD_PRDIFLN = 5
CMD_PREFLOAD = 51
CMD_PREFMENU = 49
CMD_PREFSAVE = 50
CMD_PRPGRPH = 13
CMD_PRPROMPT = 15
CMD_PRSEARCH = 17
CMD_RESTARTBRL = 67
CMD_RESTARTSPEECH = 68
CMD_SAY_ABOVE = 59
CMD_SAY_BELOW = 60
CMD_SAY_LINE = 58
CMD_SIXDOTS = 33
CMD_SKPBLNKWINS = 36
CMD_SKPIDLNS = 35
CMD_SLIDEWIN = 34
CMD_SPKHOME = 62
CMD_SWITCHVT_NEXT = 64
CMD_SWITCHVT_PREV = 63
CMD_TOP = 9
CMD_TOP_LEFT = 11
CMD_TUNES = 45
CMD_WINDN = 4
CMD_WINUP = 3
__copyright__ = 'Copyright (c) 2005-2006 Sun Microsystems Inc.'
__date__ = '$Date$'
__id__ = '$Id$'
__license__ = 'LGPL'
__version__ = '$Revision$'
beginningIsShowing = False
brlAPI = None
brlAPIRunning = False
command_name = {1: 'Line Up', 2: 'Line Down', 11: 'Top Left', 12: 'Bottom Right', 23: 'Line Left', 24: 'Line Right', 29: 'Cursor Position'}
cursorCell = 0
endIsShowing = False
log = <logging.Logger instance at 0x40602ecc>
monitor = None
useBrlAPIBindings = True