Ejemplo n.º 1
0
	def _getFieldsInRange(self, start: int, end: int) -> textInfos.TextInfo.TextWithFieldsT:
		text=NVDAHelper.VBuf_getTextInRange(self.obj.VBufHandle,start,end,True)
		if not text:
			return [""]
		commandList = XMLFormatting.XMLTextParser().parse(text)
		commandList = [
			self._normalizeCommand(command)
			for command in commandList
			# drop None to convert from XMLFormatting.CommandListT to textInfos.TextInfo.TextWithFieldsT
			if command is not None
		]
		return commandList
Ejemplo n.º 2
0
	def _getFieldsInRange(self,start,end):
		text=NVDAHelper.VBuf_getTextInRange(self.obj.VBufHandle,start,end,True)
		if not text:
			return ""
		commandList=XMLFormatting.XMLTextParser().parse(text)
		for index in range(len(commandList)):
			if isinstance(commandList[index],textInfos.FieldCommand):
				field=commandList[index].field
				if isinstance(field,textInfos.ControlField):
					commandList[index].field=self._normalizeControlField(field)
				elif isinstance(field,textInfos.FormatField):
					commandList[index].field=self._normalizeFormatField(field)
		return commandList
Ejemplo n.º 3
0
	def getTextWithFields(self,formatConfig=None):
		start=self._startOffset
		end=self._endOffset
		if start==end:
			return ""
		text=NVDAHelper.VBuf_getTextInRange(self.obj.VBufHandle,start,end,True)
		if not text:
			return ""
		commandList=XMLFormatting.XMLTextParser().parse(text)
		for index in xrange(len(commandList)):
			if isinstance(commandList[index],textInfos.FieldCommand):
				field=commandList[index].field
				if isinstance(field,textInfos.ControlField):
					commandList[index].field=self._normalizeControlField(field)
				elif isinstance(field,textInfos.FormatField):
					commandList[index].field=self._normalizeFormatField(field)
		return commandList
Ejemplo n.º 4
0
    def _getFieldsInRange(self, start, end):
        text = NVDAHelper.VBuf_getTextInRange(self.obj.VBufHandle, start, end,
                                              True)
        if not text:
            return ""
        commandList: typing.List[
            textInfos.FieldCommand] = XMLFormatting.XMLTextParser().parse(text)
        for command in commandList:
            if not isinstance(command, textInfos.FieldCommand):
                continue  # no need to normalize str or None

            field = command.field
            if isinstance(field, textInfos.ControlField):
                command.field = self._normalizeControlField(field)
            elif isinstance(field, textInfos.FormatField):
                command.field = self._normalizeFormatField(field)
        return commandList
Ejemplo n.º 5
0
	def _getTextRange(self,start,end):
		if start==end:
			return u""
		return NVDAHelper.VBuf_getTextInRange(self.obj.VBufHandle,start,end,False) or u""
Ejemplo n.º 6
0
 def update(self):
     # t = logTimeStart()
     if self.treeInterceptor is None or not self.treeInterceptor.isReady:
         self._ready = False
         return False
     try:
         info = self.treeInterceptor.makeTextInfo(textInfos.POSITION_LAST)
     except:
         self._ready = False
         return False
     try:
         size = info._endOffset + 1
     except:
         self._ready = False
         return False
     if size == self.treeInterceptorSize:
         # probably not changed
         return False
     self.treeInterceptorSize = size
     if True:
         self.updating = True
         info = self.treeInterceptor.makeTextInfo(textInfos.POSITION_ALL)
         self.info = info
         start = info._startOffset
         end = info._endOffset
         if start == end:
             self._ready = False
             return False
         text = NVDAHelper.VBuf_getTextInRange(info.obj.VBufHandle, start,
                                               end, True)
         if self.mainNode is not None:
             self.mainNode.recursiveDelete()
         self.parseXML(text)
         # logTime("Update node manager %d, text=%d" % (self.index, len(text)), t)
         self.info = None
         gc.collect()
     else:
         self.updating = False
         self._ready = False
         log.info(u"reading vBuff error")
         return False
     # self.info = info
     if self.mainNode is None:
         self.updating = False
         self._ready = False
         return False
     self.identifier = time.time()
     # logTime ("Update node manager %d nodes" % len(fields), t)
     self.updating = False
     # playWebAppSound ("tick")
     self._curNode = self.caretNode = self.getCaretNode()
     try:
         info = self.treeInterceptor.makeTextInfo(textInfos.POSITION_LAST)
     except:
         self._ready = False
         return False
     size = info._endOffset + 1
     from . import webAppScheduler
     if size != self.treeInterceptorSize:
         # treeInterceptor has changed during analyze
         self._ready = False
         webAppScheduler.scheduler.send(
             eventName="updateNodeManager",
             treeInterceptor=self.treeInterceptor)
         return False
     else:
         self._ready = True
         webAppScheduler.scheduler.send(eventName="nodeManagerUpdated",
                                        nodeManager=self)
         return True
     return False