2727from speech import sayAll
2828import inputCore
2929
30+ # Translators: The name of a category of NVDA commands.
31+ SCRCAT_SYSTEMCARET = _ ("System caret" )
3032
3133class WordDocument (IAccessible , EditableTextWithoutAutoSelectDetection , winWordWindowModule .WordDocument ):
3234
@@ -212,6 +214,17 @@ def fetchAssociatedHeaderCellText(self,cell,columnHeader=False):
212214 if text :
213215 return text
214216
217+ @script (
218+ gesture = "kb:NVDA+shift+c" ,
219+ # Translators: The label of a shortcut of NVDA.
220+ description = _ (
221+ "Set column header"
222+ "Pressing once will set this cell as the first column header for any cells lower and "
223+ "to the right of it within this table. "
224+ "Pressing twice will forget the current column header for this cell."
225+ ),
226+ category = SCRCAT_SYSTEMCARET
227+ )
215228 def script_setColumnHeader (self ,gesture ):
216229 scriptCount = scriptHandler .getLastScriptRepeatCount ()
217230 try :
@@ -234,8 +247,18 @@ def script_setColumnHeader(self,gesture):
234247 else :
235248 # Translators: a message reported in the SetColumnHeader script for Microsoft Word.
236249 ui .message (_ ("Cannot find row {rowNumber} column {columnNumber} in column headers" ).format (rowNumber = cell .rowIndex ,columnNumber = cell .columnIndex ))
237- script_setColumnHeader .__doc__ = _ ("Pressing once will set this cell as the first column header for any cells lower and to the right of it within this table. Pressing twice will forget the current column header for this cell." )
238250
251+ @script (
252+ gesture = "kb:NVDA+shift+r" ,
253+ # Translators: The label of a shortcut of NVDA.
254+ description = _ (
255+ "Set row header."
256+ "Pressing once will set this cell as the first row header for any cells lower and "
257+ "to the right of it within this table. "
258+ "Pressing twice will forget the current row header for this cell."
259+ ),
260+ category = SCRCAT_SYSTEMCARET
261+ )
239262 def script_setRowHeader (self ,gesture ):
240263 scriptCount = scriptHandler .getLastScriptRepeatCount ()
241264 try :
@@ -258,14 +281,25 @@ def script_setRowHeader(self,gesture):
258281 else :
259282 # Translators: a message reported in the SetRowHeader script for Microsoft Word.
260283 ui .message (_ ("Cannot find row {rowNumber} column {columnNumber} in row headers" ).format (rowNumber = cell .rowIndex ,columnNumber = cell .columnIndex ))
261- script_setRowHeader .__doc__ = _ ("Pressing once will set this cell as the first row header for any cells lower and to the right of it within this table. Pressing twice will forget the current row header for this cell." )
262284
285+ @script (
286+ gesture = "kb:NVDA+shift+h" ,
287+ category = SCRCAT_SYSTEMCARET
288+ )
263289 def script_reportCurrentHeaders (self ,gesture ):
264290 cell = self .WinwordSelectionObject .cells [1 ]
265291 rowText = self .fetchAssociatedHeaderCellText (cell ,False )
266292 columnText = self .fetchAssociatedHeaderCellText (cell ,True )
267293 ui .message ("Row %s, column %s" % (rowText or "empty" ,columnText or "empty" ))
268294
295+ @script (
296+ gestures = (
297+ "kb:alt+home" ,
298+ "kb:alt+end" ,
299+ "kb:alt+pageUp" ,
300+ "kb:alt+pageDown"
301+ )
302+ )
269303 def script_caret_moveByCell (self , gesture : inputCore .InputGesture ) -> None :
270304 info = self .makeTextInfo (textInfos .POSITION_SELECTION )
271305 inTable = info ._rangeObj .tables .count > 0
@@ -301,6 +335,7 @@ def script_caret_moveByCell(self, gesture: inputCore.InputGesture) -> None:
301335 # Translators: a description for a script
302336 description = _ ("Reports the text of the comment where the system caret is located." ),
303337 gesture = "kb:NVDA+alt+c" ,
338+ category = SCRCAT_SYSTEMCARET ,
304339 speakOnDemand = True ,
305340 )
306341 def script_reportCurrentComment (self ,gesture ):
@@ -375,33 +410,51 @@ def _moveInTable(self,row=True,forward=True):
375410 newInfo .updateCaret ()
376411 return True
377412
413+ @script (
414+ gesture = "kb:control+alt+downArrow"
415+ )
378416 def script_nextRow (self ,gesture ):
379417 self ._moveInTable (row = True ,forward = True )
380418
419+ @script (
420+ gesture = "kb:control+alt+upArrow"
421+ )
381422 def script_previousRow (self ,gesture ):
382423 self ._moveInTable (row = True ,forward = False )
383424
425+ @script (
426+ gesture = "kb:control+alt+rightArrow"
427+ )
384428 def script_nextColumn (self ,gesture ):
385429 self ._moveInTable (row = False ,forward = True )
386430
431+ @script (
432+ gesture = "kb:control+alt+leftArrow"
433+ )
387434 def script_previousColumn (self ,gesture ):
388435 self ._moveInTable (row = False ,forward = False )
389436
437+ @script (
438+ gesture = "kb:control+downArrow" ,
439+ resumeSayAllMode = sayAll .CURSOR .CARET
440+ )
390441 def script_nextParagraph (self ,gesture ):
391442 info = self .makeTextInfo (textInfos .POSITION_CARET )
392443 # #4375: can't use self.move here as it may check document.chracters.count which can take for ever on large documents.
393444 info ._rangeObj .move (winWordWindowModule .wdParagraph , 1 )
394445 info .updateCaret ()
395446 self ._caretScriptPostMovedHelper (textInfos .UNIT_PARAGRAPH ,gesture ,None )
396- script_nextParagraph .resumeSayAllMode = sayAll .CURSOR .CARET
397447
448+ @script (
449+ gesture = "kb:control+upArrow" ,
450+ resumeSayAllMode = sayAll .CURSOR .CARET
451+ )
398452 def script_previousParagraph (self ,gesture ):
399453 info = self .makeTextInfo (textInfos .POSITION_CARET )
400454 # #4375: keeping symmetrical with nextParagraph script.
401455 info ._rangeObj .move (winWordWindowModule .wdParagraph , - 1 )
402456 info .updateCaret ()
403457 self ._caretScriptPostMovedHelper (textInfos .UNIT_PARAGRAPH ,gesture ,None )
404- script_previousParagraph .resumeSayAllMode = sayAll .CURSOR .CARET
405458
406459 @script (
407460 gestures = (
@@ -435,23 +488,6 @@ def focusOnActiveDocument(self, officeChartObject):
435488 import api
436489 eventHandler .executeEvent ("gainFocus" , api .getDesktopObject ().objectWithFocus ())
437490
438- __gestures = {
439- "kb:NVDA+shift+c" :"setColumnHeader" ,
440- "kb:NVDA+shift+r" :"setRowHeader" ,
441- "kb:NVDA+shift+h" :"reportCurrentHeaders" ,
442- "kb:control+alt+upArrow" : "previousRow" ,
443- "kb:control+alt+downArrow" : "nextRow" ,
444- "kb:control+alt+leftArrow" : "previousColumn" ,
445- "kb:control+alt+rightArrow" : "nextColumn" ,
446- "kb:control+downArrow" :"nextParagraph" ,
447- "kb:control+upArrow" :"previousParagraph" ,
448- "kb:alt+home" :"caret_moveByCell" ,
449- "kb:alt+end" :"caret_moveByCell" ,
450- "kb:alt+pageUp" :"caret_moveByCell" ,
451- "kb:alt+pageDown" :"caret_moveByCell" ,
452- }
453-
454-
455491class SpellCheckErrorField (IAccessible , winWordWindowModule .WordDocument_WwN ):
456492
457493 parentSDMCanOverrideName = False
0 commit comments