def script_reportStatusLine(self, gesture): #it seems that the status bar is the last child of the forground object #so, get it from there obj = api.getForegroundObject().lastChild found=False if obj and obj.role == controlTypes.ROLE_STATUSBAR: text = api.getStatusBarText(obj) api.setNavigatorObject(obj) found=True else: info=api.getForegroundObject().flatReviewPosition if info: info.expand(textInfos.UNIT_STORY) info.collapse(True) info.expand(textInfos.UNIT_LINE) text=info.text info.collapse() api.setReviewPosition(info) found=True if not found: # Translators: Reported when there is no status line for the current program or window. ui.message(_("No status line found")) return if scriptHandler.getLastScriptRepeatCount()==0: ui.message(text) else: speech.speakSpelling(text)
def script_sayLineNumber(self, gesture): #We're using two nested functioncalls. api.getStatusBarText(obj) and #api.getStatusBar(). api.getStatusBar() returns an NVDAObjects.NVDAObject, #and api.getStatusBarText(obj) returns the status bar text of #the given obj, if it's a status bar. #This is how we get the data to split for the line number. lineNumList = api.getStatusBarText(api.getStatusBar()).split() lineNum = lineNumList[2] + lineNumList[3] ui.message(lineNum)
def event_stateChange(self, obj, nextHandler): if obj.role == controlTypes.ROLE_DOCUMENT and controlTypes.STATE_BUSY in obj.states and winUser.isWindowVisible(obj.windowHandle) and obj.isInForeground: statusBar = api.getStatusBar() if statusBar: statusText = api.getStatusBarText(statusBar) speech.cancelSpeech() speech.speakMessage(controlTypes.speechStateLabels[controlTypes.STATE_BUSY]) speech.speakMessage(statusText) return nextHandler()
def script_reportStatusLine(self,gesture): obj = api.getStatusBar() if not obj: ui.message(_("no status bar found")) return text = api.getStatusBarText(obj) if scriptHandler.getLastScriptRepeatCount()==0: ui.message(text) else: speech.speakSpelling(text) api.setNavigatorObject(obj)
def event_stateChange(self, obj, nextHandler): if obj.role == controlTypes.ROLE_DOCUMENT and controlTypes.STATE_BUSY in obj.states and winUser.isWindowVisible( obj.windowHandle) and obj.isInForeground: statusBar = api.getStatusBar() if statusBar: statusText = api.getStatusBarText(statusBar) speech.cancelSpeech() speech.speakMessage( controlTypes.stateLabels[controlTypes.STATE_BUSY]) speech.speakMessage(statusText) return nextHandler()
def event_gainFocus(self, obj, nextHandler): if obj.role == controlTypes.Role.DOCUMENT and controlTypes.State.BUSY in obj.states and winUser.isWindowVisible(obj.windowHandle): statusBar = api.getStatusBar() if statusBar: try: # The document loading status is contained in the second field of the status bar. statusText = statusBar.firstChild.next.name except: # Fall back to reading the entire status bar. statusText = api.getStatusBarText(statusBar) speech.speakMessage(controlTypes.stateLabels[controlTypes.State.BUSY]) speech.speakMessage(statusText) return nextHandler()
def event_gainFocus(self, obj, nextHandler): if obj.role == controlTypes.ROLE_DOCUMENT and controlTypes.STATE_BUSY in obj.states and winUser.isWindowVisible(obj.windowHandle): statusBar = api.getStatusBar() if statusBar: try: # The document loading status is contained in the second field of the status bar. statusText = statusBar.firstChild.next.name except: # Fall back to reading the entire status bar. statusText = api.getStatusBarText(statusBar) speech.speakMessage(controlTypes.stateLabels[controlTypes.STATE_BUSY]) speech.speakMessage(statusText) return nextHandler()
def _getCurLineNumber(): """gets current line number which has the caret in the editor based on status bar text""" obj = api.getForegroundObject().lastChild text = None if obj and obj.role == controlTypes.ROLE_STATUSBAR: text = api.getStatusBarText(obj) if not text: return 0 try: lineInfo = re.search(REG_GET_LINE_TEXT, text).group() except: return 0 try: lineNum = int(re.search(REG_GET_LINE_NUM, lineInfo).group()) except: return 0 if lineNum <= 0: return 0 return lineNum