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,14 @@ 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 = _ ("""Pressing once will set this cell as the first column header for any cells lower and
221+ to the right of it within this table.
222+ Pressing twice will forget the current column header for this cell.""" ),
223+ category = SCRCAT_SYSTEMCARET
224+ )
215225 def script_setColumnHeader (self ,gesture ):
216226 scriptCount = scriptHandler .getLastScriptRepeatCount ()
217227 try :
@@ -234,8 +244,15 @@ def script_setColumnHeader(self,gesture):
234244 else :
235245 # Translators: a message reported in the SetColumnHeader script for Microsoft Word.
236246 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." )
238247
248+ @script (
249+ gesture = "kb:NVDA+shift+r" ,
250+ # Translators: The label of a shortcut of NVDA.
251+ description = _ ("""Pressing once will set this cell as the first row header for any cells lower and
252+ to the right of it within this table.
253+ Pressing twice will forget the current row header for this cell.""" ),
254+ category = SCRCAT_SYSTEMCARET
255+ )
239256 def script_setRowHeader (self ,gesture ):
240257 scriptCount = scriptHandler .getLastScriptRepeatCount ()
241258 try :
@@ -258,14 +275,25 @@ def script_setRowHeader(self,gesture):
258275 else :
259276 # Translators: a message reported in the SetRowHeader script for Microsoft Word.
260277 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." )
262278
279+ @script (
280+ gesture = "kb:NVDA+shift+h" ,
281+ category = SCRCAT_SYSTEMCARET
282+ )
263283 def script_reportCurrentHeaders (self ,gesture ):
264284 cell = self .WinwordSelectionObject .cells [1 ]
265285 rowText = self .fetchAssociatedHeaderCellText (cell ,False )
266286 columnText = self .fetchAssociatedHeaderCellText (cell ,True )
267287 ui .message ("Row %s, column %s" % (rowText or "empty" ,columnText or "empty" ))
268288
289+ @script (
290+ gestures = (
291+ "kb:alt+home" ,
292+ "kb:alt+end" ,
293+ "kb:alt+pageUp" ,
294+ "kb:alt+pageDown"
295+ )
296+ )
269297 def script_caret_moveByCell (self , gesture : inputCore .InputGesture ) -> None :
270298 info = self .makeTextInfo (textInfos .POSITION_SELECTION )
271299 inTable = info ._rangeObj .tables .count > 0
@@ -301,6 +329,7 @@ def script_caret_moveByCell(self, gesture: inputCore.InputGesture) -> None:
301329 # Translators: a description for a script
302330 description = _ ("Reports the text of the comment where the system caret is located." ),
303331 gesture = "kb:NVDA+alt+c" ,
332+ category = SCRCAT_SYSTEMCARET ,
304333 speakOnDemand = True ,
305334 )
306335 def script_reportCurrentComment (self ,gesture ):
@@ -375,33 +404,51 @@ def _moveInTable(self,row=True,forward=True):
375404 newInfo .updateCaret ()
376405 return True
377406
407+ @script (
408+ gesture = "kb:control+alt+downArrow"
409+ )
378410 def script_nextRow (self ,gesture ):
379411 self ._moveInTable (row = True ,forward = True )
380412
413+ @script (
414+ gesture = "kb:control+alt+upArrow"
415+ )
381416 def script_previousRow (self ,gesture ):
382417 self ._moveInTable (row = True ,forward = False )
383418
419+ @script (
420+ gesture = "kb:control+alt+rightArrow"
421+ )
384422 def script_nextColumn (self ,gesture ):
385423 self ._moveInTable (row = False ,forward = True )
386424
425+ @script (
426+ gesture = "kb:control+alt+leftArrow"
427+ )
387428 def script_previousColumn (self ,gesture ):
388429 self ._moveInTable (row = False ,forward = False )
389430
431+ @script (
432+ gesture = "kb:control+downArrow" ,
433+ resumeSayAllMode = sayAll .CURSOR .CARET
434+ )
390435 def script_nextParagraph (self ,gesture ):
391436 info = self .makeTextInfo (textInfos .POSITION_CARET )
392437 # #4375: can't use self.move here as it may check document.chracters.count which can take for ever on large documents.
393438 info ._rangeObj .move (winWordWindowModule .wdParagraph , 1 )
394439 info .updateCaret ()
395440 self ._caretScriptPostMovedHelper (textInfos .UNIT_PARAGRAPH ,gesture ,None )
396- script_nextParagraph .resumeSayAllMode = sayAll .CURSOR .CARET
397441
442+ @script (
443+ gesture = "kb:control+upArrow" ,
444+ resumeSayAllMode = sayAll .CURSOR .CARET
445+ )
398446 def script_previousParagraph (self ,gesture ):
399447 info = self .makeTextInfo (textInfos .POSITION_CARET )
400448 # #4375: keeping symmetrical with nextParagraph script.
401449 info ._rangeObj .move (winWordWindowModule .wdParagraph , - 1 )
402450 info .updateCaret ()
403451 self ._caretScriptPostMovedHelper (textInfos .UNIT_PARAGRAPH ,gesture ,None )
404- script_previousParagraph .resumeSayAllMode = sayAll .CURSOR .CARET
405452
406453 @script (
407454 gestures = (
@@ -435,23 +482,6 @@ def focusOnActiveDocument(self, officeChartObject):
435482 import api
436483 eventHandler .executeEvent ("gainFocus" , api .getDesktopObject ().objectWithFocus ())
437484
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-
455485class SpellCheckErrorField (IAccessible , winWordWindowModule .WordDocument_WwN ):
456486
457487 parentSDMCanOverrideName = False
0 commit comments