brailleInput module

brailleInput.FALLBACK_TABLE

Table to use if the input table configuration is invalid.

brailleInput.LOUIS_DOTS_IO_START = 32768

This bit flag must be added to all braille cells when using liblouis with dotsIO.

brailleInput.UNICODE_BRAILLE_START = 10240

The start of the Unicode braille range. @type: int

brailleInput.UNICODE_BRAILLE_PROTECTED = '⣿'

The Unicode braille character to use when masking cells in protected fields. @type: str

class brailleInput.BrailleInputHandler(*args, **kwargs)

Bases: AutoPropertyObject

Handles braille input.

bufferBraille: List[int]

A buffer of entered braille cells so that state set by previous cells can be maintained; e.g. capital and number signs.

bufferText: str

The text translated so far from the cells in L{bufferBraille}.

cellsWithText: Set[int]

Indexes of cells which produced text. For example, this includes letters and numbers, but not number signs, since a number sign by itself doesn’t produce text. This is used when erasing cells to determine when to backspace an actual character.

untranslatedBraille: str

The cells in L{bufferBraille} that have not yet been translated or were translated but did not produce any text. This is used to show these cells to the user while they’re entering braille. This is a string of Unicode braille.

untranslatedStart: int

The position in L{brailleBuffer} where untranslated braille begins.

untranslatedCursorPos: int

The user’s cursor position within the untranslated braille. This enables the user to move within the untranslated braille.

_uncontSentTime: float | None

The time at which uncontracted characters were sent to the system.

currentModifiers: Set[str]

The modifiers currently being held virtually to be part of the next braille input gesture.

property table: BrailleTable

Type definition for auto prop ‘_get_table/_set_table’

_get_table() BrailleTable

The translation table to use for braille input.

_set_table(table: BrailleTable)
currentFocusIsTextObj: bool
_get_currentFocusIsTextObj()
useContractedForCurrentFocus: bool
_get_useContractedForCurrentFocus()
_translate(endWord: bool) bool

Translate buffered braille up to the cursor. Any text produced is sent to the system. @param endWord: C{True} if this is the end of a word, C{False} otherwise. @return: C{True} if translation produced text, C{False} if not.

_translateForReportContractedCell(pos)

Translate text for current input as required by L{_reportContractedCell}. @return: The previous translated text. @rtype: str

_reportContractedCell(pos)

Report a guess about the character(s) produced by a cell of contracted braille. It’s not possible to report the exact characters because later cells might change text produced by earlier cells. However, it’s helpful for the user to have a rough idea. For example, in English contracted braille, “alw” is the contraction for “always”. As the user types “alw”, the characters a, l, w will be spoken. @return: C{True} if a guess was reported, C{False} if not (e.g. a number sign). @rtype: bool

_reportUntranslated(pos)

Report a braille cell which hasn’t yet been translated into text.

input(dots: int)

Handle one cell of braille input.

toggleModifier(modifier: str)
toggleModifiers(modifiers: List[str])
enter()

Translates any braille input and presses the enter key.

translate()

Translates any braille input without inserting a space or new line.

_updateUntranslated()

Update the untranslated braille to be shown to the user. If the display will not otherwise be updated, L{updatedisplay} should be called after this.

updateDisplay()

Update the braille display to reflect untranslated input.

eraseLastCell()
flushBuffer()
emulateKey(key: str, withModifiers: bool = True)

Emulates a key using the keyboard emulation system. If emulation fails (e.g. because of an unknown key), a debug warning is logged and the system falls back to sending unicode characters. @param withModifiers: Whether this key emulation should include the modifiers that are held virtually.

Note that this method does not take care of clearing L{self.currentModifiers}.

sendChars(chars: str)

Sends the provided unicode characters to the system. @param chars: The characters to send to the system.

handleGainFocus(obj)

Clear all state when the focus changes. :type obj: NVDAObjects.NVDAObject

handleCaretMove(obj)
handlePostConfigProfileSwitch()
_abc_impl = <_abc._abc_data object>
brailleInput.handler: BrailleInputHandler | None = None

The singleton BrailleInputHandler instance.

brailleInput.initialize()
brailleInput.terminate()
brailleInput.formatDotNumbers(dots: int)
brailleInput.speakDots(dots: int)
class brailleInput.BrailleInputGesture(*args, **kwargs)

Bases: InputGesture

Input (dots and/or space bar) from a braille keyboard. This could either be as part of a braille display or a stand-alone unit. L{dots} and L{space} should be set appropriately.

_abc_impl = <_abc._abc_data object>
displayName: str
dots = 0

Bitmask of pressed dots. @type: int

identifiers: List[str] | Tuple[str, ...]
space = False

Whether the space bar is pressed. @type: bool

shouldPreventSystemIdle: bool = True

Indicates whether executing this gesture should explicitly prevent the system from being idle. For example, the system is unaware of C{BrailleDisplayGesture} execution, and might even get into sleep mode when reading a long portion of text in braille. In contrast, the system is aware of C{KeyboardInputGesture} execution itself.

_makeDotsId()
GENERIC_ID_SPACE_DOTS = 'bk:dots+space'

The generic gesture identifier for space plus any dots. This could be used to bind many braille commands to a single script.

GENERIC_ID_DOTS = 'bk:dots'

The generic gesture identifier for any dots. This is used to bind entry of braille text to a single script.

_get_identifiers()

The identifier(s) which will be used in input gesture maps to represent this gesture. These identifiers will be normalized and looked up in order until a match is found. A single identifier should take the form: C{source:id} where C{source} is a few characters representing the source of this gesture and C{id} is the specific gesture. An example identifier is: C{kb(desktop):NVDA+1}

This property should not perform normalization itself. However, please note the following regarding normalization. If C{id} contains multiple chunks separated by a + sign, they are considered to be ordered arbitrarily and may be reordered when normalized. Normalization also ensures that the entire identifier is lower case. For example, NVDA+control+f1 and control+nvda+f1 will match when normalized. See L{normalizeGestureIdentifier} for more details.

Subclasses must implement this method. @return: One or more identifiers which uniquely identify this gesture. @rtype: list or tuple of str

classmethod _makeDisplayText(dots: int, space: bool)
_get_displayName()

The name of this gesture as presented to the user. The base implementation calls L{getDisplayTextForIdentifier} for the first identifier. Subclasses need not override this unless they wish to provide a more optimal implementation. @return: The display name. @rtype: str

classmethod getDisplayTextForIdentifier(identifier: str)

Get the text to be presented to the user describing a given gesture identifier. This should only be called with normalized gesture identifiers returned by the L{normalizedIdentifiers} property in the same subclass. For example, C{KeyboardInputGesture.getDisplayTextForIdentifier} should only be called for “kb:*” identifiers returned by C{KeyboardInputGesture.normalizedIdentifiers}. Most callers will want L{inputCore.getDisplayTextForIdentifier} instead. The display text consists of two strings: the gesture’s source (e.g. “laptop keyboard”) and the specific gesture (e.g. “alt+tab”). @param identifier: The normalized gesture identifier in question. @type identifier: str @return: A tuple of (source, specificGesture). @rtype: tuple of (str, str) @raise Exception: If no display text can be determined.