Skip to content

Commit 64cc17c

Browse files
authored
Merge 8ca0cca into 93bbe4f
2 parents 93bbe4f + 8ca0cca commit 64cc17c

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

source/braille.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,7 @@ def __init__(self, handler):
17691769
#: The translated braille representation of the entire buffer.
17701770
#: @type: [int, ...]
17711771
self.brailleCells = []
1772-
self._windowRowBufferOffsets: list[tuple[int, int]] = [(0, 1)]
1772+
self._windowRowBufferOffsets: list[tuple[int, int]] = [(0, 0)]
17731773
"""
17741774
A list representing the rows in the braille window,
17751775
each item being a tuple of start and end braille buffer offsets.
@@ -1879,6 +1879,8 @@ def windowPosToBufferPos(self, windowPos: int) -> int:
18791879
"""
18801880
Converts a position relative to the braille window to a position relative to the braille buffer.
18811881
"""
1882+
if self.handler.displaySize == 0:
1883+
return 0
18821884
windowPos = max(min(windowPos, self.handler.displaySize), 0)
18831885
row, col = divmod(windowPos, self.handler.displayDimensions.numCols)
18841886
if row < len(self._windowRowBufferOffsets):
@@ -1905,7 +1907,7 @@ def _calculateWindowRowBufferOffsets(self, pos: int) -> None:
19051907
self._windowRowBufferOffsets.clear()
19061908
if len(self.brailleCells) == 0:
19071909
# Initialising with no actual braille content.
1908-
self._windowRowBufferOffsets = [(0, 1)]
1910+
self._windowRowBufferOffsets = [(0, 0)]
19091911
return
19101912
doWordWrap = config.conf["braille"]["wordWrap"]
19111913
bufferEnd = len(self.brailleCells)
@@ -2539,9 +2541,14 @@ def _set_displaySize(self, value):
25392541
_cache_displayDimensions = True
25402542

25412543
def _get_displayDimensions(self) -> DisplayDimensions:
2544+
if not self.display:
2545+
numRows = numCols = 0
2546+
else:
2547+
numRows = self.display.numRows
2548+
numCols = self.display.numCols if numRows > 1 else self.display.numCells
25422549
rawDisplayDimensions = DisplayDimensions(
2543-
numRows=self.display.numRows if self.display else 0,
2544-
numCols=self.display.numCols if self.display else 0,
2550+
numRows=numRows,
2551+
numCols=numCols,
25452552
)
25462553
filteredDisplayDimensions = filter_displayDimensions.apply(rawDisplayDimensions)
25472554
# Would be nice if there were a more official way to find out if the displaySize filter is currently registered by at least 1 handler.
@@ -3284,7 +3291,9 @@ class BrailleDisplayDriver(driverHandler.Driver):
32843291
containing a BrailleDisplayDriver class which inherits from this base class.
32853292
32863293
At a minimum, drivers must set L{name} and L{description} and override the L{check} method.
3287-
To display braille, L{numCells} and L{display} must be implemented.
3294+
To display braille, :meth:`display` must be implemented.
3295+
For a single line display, :attr:`numCells` must be implemented.
3296+
For a multi line display, :attr:`numRows` and :attr:`numCols` must be implemented.
32883297
32893298
To support automatic detection of braille displays belonging to this driver:
32903299
* The driver must be thread safe and L{isThreadSafe} should be set to C{True}

tests/system/libraries/SystemTestSpy/speechSpyGlobalPlugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Optional,
1616
Tuple,
1717
)
18-
18+
from braille import DisplayDimensions
1919
import core
2020
import globalPluginHandler
2121
import threading
@@ -189,7 +189,7 @@ def _onNvdaStartupComplete(self):
189189
self._isNvdaStartupComplete = True
190190
import braille
191191

192-
braille.filter_displaySize.register(self.getBrailleCellCount)
192+
braille.filter_displayDimensions.register(self.getBrailleDisplayDimensions)
193193
braille.pre_writeCells.register(self._onNvdaBraille)
194194

195195
def _onNvdaBraille(self, rawText: str):
@@ -266,8 +266,8 @@ def _hasSpeechFinished(self, speechStartedIndex: Optional[int] = None):
266266
def setBrailleCellCount(self, brailleCellCount: int):
267267
self._brailleCellCount = brailleCellCount
268268

269-
def getBrailleCellCount(self, value: int):
270-
return self._brailleCellCount
269+
def getBrailleDisplayDimensions(self, value: DisplayDimensions):
270+
return DisplayDimensions(1, self._brailleCellCount)
271271

272272
def _getBrailleAtIndex(self, brailleIndex: int) -> str:
273273
with self._brailleLock:

0 commit comments

Comments
 (0)