@@ -1866,6 +1866,62 @@ def formatCellsForLog(cells: List[int]) -> str:
18661866 if cell else "-"
18671867 for cell in cells ])
18681868
1869+
1870+ pre_writeCells = extensionPoints .Action ()
1871+ """
1872+ Notifies when cells are about to be written to a braille display.
1873+ This allows components and add-ons to perform an action.
1874+ For example, when a system is controlled by a braille enabled remote system,
1875+ the remote system should know what cells to show on its display.
1876+ @param cells: The list of braille cells.
1877+ @type cells: List[int]
1878+ @param rawText: The raw text that corresponds with the cells.
1879+ @type rawText: str
1880+ @param currentCellCount: The current number of cells
1881+ @type currentCellCount: bool
1882+ """
1883+
1884+ filter_displaySize = extensionPoints .Filter ()
1885+ """
1886+ Filter that allows components or add-ons to change the display size used for braille output.
1887+ For example, when a system is controlled by a remote system while having a 80 cells display connected,
1888+ the display size should be lowered to 40 whenever the remote system has a 40 cells display connected.
1889+ @param value: the number of cells of the current display.
1890+ @type value: int
1891+ """
1892+
1893+ displaySizeChanged = extensionPoints .Action ()
1894+ """
1895+ Action that allows components or add-ons to be notified of display size changes.
1896+ For example, when a system is controlled by a remote system and the remote system swaps displays,
1897+ The local system should be notified about display size changes at the remote system.
1898+ @param displaySize: The current display size used by the braille handler.
1899+ @type displaySize: int
1900+ """
1901+
1902+ displayChanged = extensionPoints .Action ()
1903+ """
1904+ Action that allows components or add-ons to be notified of braille display changes.
1905+ For example, when a system is controlled by a remote system and the remote system swaps displays,
1906+ The local system should be notified about display parameters at the remote system,
1907+ e.g. name and cellcount.
1908+ @param display: The new braille display driver
1909+ @type display: L{BrailleDisplayDriver}
1910+ @param isFallback: Whether the display is set as fallback display due to another display's failure
1911+ @type isFallback: bool
1912+ @param detected: If the display was set by auto detection, the device match that matched the driver
1913+ @type detected: bdDetect.DeviceMatch or C{None}
1914+ """
1915+
1916+ decide_enabled = extensionPoints .Decider ()
1917+ """
1918+ Allows components or add-ons to decide whether the braille handler should be forcefully disabled.
1919+ For example, when a system is controlling a remote system with braille,
1920+ the local braille handler should be disabled as long as the system is in control of the remote system.
1921+ Handlers are called without arguments.
1922+ """
1923+
1924+
18691925class BrailleHandler (baseObject .AutoPropertyObject ):
18701926 # TETHER_AUTO, TETHER_FOCUS, TETHER_REVIEW and tetherValues
18711927 # are deprecated, but remain to retain API backwards compatibility
@@ -1878,60 +1934,6 @@ class BrailleHandler(baseObject.AutoPropertyObject):
18781934 queuedWriteLock : threading .Lock
18791935 ackTimerHandle : int
18801936
1881- pre_writeCells : extensionPoints .Action
1882- """
1883- Notifies when cells are about to be written to a braille display.
1884- This allows components and add-ons to perform an action.
1885- For example, when a system is controlled by a braille enabled remote system,
1886- the remote system should know what cells to show on its display.
1887- @param cells: The list of braille cells.
1888- @type cells: List[int]
1889- @param rawText: The raw text that corresponds with the cells.
1890- @type rawText: str
1891- @param currentCellCount: The current number of cells
1892- @type currentCellCount: bool
1893- """
1894-
1895- filter_displaySize : extensionPoints .Filter
1896- """
1897- Filter that allows components or add-ons to change the display size used for braille output.
1898- For example, when a system is controlled by a remote system while having a 80 cells display connected,
1899- the display size should be lowered to 40 whenever the remote system has a 40 cells display connected.
1900- @param value: the number of cells of the current display.
1901- @type value: int
1902- """
1903-
1904- displaySizeChanged : extensionPoints .Action
1905- """
1906- Action that allows components or add-ons to be notified of display size changes.
1907- For example, when a system is controlled by a remote system and the remote system swaps displays,
1908- The local system should be notified about display size changes at the remote system.
1909- @param displaySize: The current display size used by the braille handler.
1910- @type displaySize: int
1911- """
1912-
1913- displayChanged : extensionPoints .Action
1914- """
1915- Action that allows components or add-ons to be notified of braille display changes.
1916- For example, when a system is controlled by a remote system and the remote system swaps displays,
1917- The local system should be notified about display parameters at the remote system,
1918- e.g. name and cellcount.
1919- @param display: The new braille display driver
1920- @type display: L{BrailleDisplayDriver}
1921- @param isFallback: Whether the display is set as fallback display due to another display's failure
1922- @type isFallback: bool
1923- @param detected: If the display was set by auto detection, the device match that matched the driver
1924- @type detected: bdDetect.DeviceMatch or C{None}
1925- """
1926-
1927- decide_enabled : extensionPoints .Decider
1928- """
1929- Allows components or add-ons to decide whether the braille handler should be forcefully disabled.
1930- For example, when a system is controlling a remote system with braille,
1931- the local braille handler should be disabled as long as the system is in control of the remote system.
1932- Handlers are called without arguments.
1933- """
1934-
19351937 def __init__ (self ):
19361938 louisHelper .initialize ()
19371939 self .display : Optional [BrailleDisplayDriver ] = None
@@ -1975,12 +1977,6 @@ def __init__(self):
19751977
19761978 brailleViewer .postBrailleViewerToolToggledAction .register (self ._onBrailleViewerChangedState )
19771979
1978- self .pre_writeCells = extensionPoints .Action ()
1979- self .filter_displaySize = extensionPoints .Filter ()
1980- self .displaySizeChanged = extensionPoints .Action ()
1981- self .displayChanged = extensionPoints .Action ()
1982- self .decide_enabled = extensionPoints .Decider ()
1983-
19841980 def terminate (self ):
19851981 self ._disableDetection ()
19861982 if self ._messageCallLater :
@@ -2025,9 +2021,9 @@ def _get_displaySize(self):
20252021 Therefore, this is a read only property and can't be set.
20262022 """
20272023 numCells = self .display .numCells if self .display else 0
2028- currentDisplaySize = self . filter_displaySize .apply (numCells )
2024+ currentDisplaySize = filter_displaySize .apply (numCells )
20292025 if self ._displaySize != currentDisplaySize :
2030- self . displaySizeChanged .notify (displaySize = currentDisplaySize )
2026+ displaySizeChanged .notify (displaySize = currentDisplaySize )
20312027 self ._displaySize = currentDisplaySize
20322028 return currentDisplaySize
20332029
@@ -2054,7 +2050,7 @@ def _get_enabled(self):
20542050 and thus is C{True} when the display size is greater than 0.
20552051 This is a read only property and can't be set.
20562052 """
2057- currentEnabled = bool (self .displaySize ) and self . decide_enabled .decide ()
2053+ currentEnabled = bool (self .displaySize ) and decide_enabled .decide ()
20582054 if self ._enabled != currentEnabled :
20592055 self ._enabled = currentEnabled
20602056 if currentEnabled is False :
@@ -2164,7 +2160,7 @@ def setDisplayByName( # noqa: C901
21642160 # When setDisplayByName is refactored, ensure that braille display detection no longer triggers
21652161 # an unnecessary reinit of noBraille.
21662162 if not (sameDisplayReInit and newDisplay .name == "noBraille" ):
2167- self . displayChanged .notify (display = newDisplay , isFallback = isFallback , detected = detected )
2163+ displayChanged .notify (display = newDisplay , isFallback = isFallback , detected = detected )
21682164 return True
21692165 except :
21702166 # For auto display detection, logging an error for every failure is too obnoxious.
@@ -2198,7 +2194,7 @@ def _updateDisplay(self):
21982194
21992195 def _writeCells (self , cells : List [int ]):
22002196 handlerCellCount = self .displaySize
2201- self . pre_writeCells .notify (cells = cells , rawText = self ._rawText , currentCellCount = handlerCellCount )
2197+ pre_writeCells .notify (cells = cells , rawText = self ._rawText , currentCellCount = handlerCellCount )
22022198 displayCellCount = self .display .numCells
22032199 if not displayCellCount :
22042200 # No physical display to write to
0 commit comments