improve type performance
This commit is contained in:
parent
e8c8a34138
commit
8f3dc5fb94
@ -1,41 +0,0 @@
|
|||||||
#!/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Fenrir TTY screen reader
|
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
|
||||||
|
|
||||||
from core import debug
|
|
||||||
from utils import char_utils
|
|
||||||
|
|
||||||
class command():
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
def initialize(self, environment):
|
|
||||||
self.env = environment
|
|
||||||
def shutdown(self):
|
|
||||||
pass
|
|
||||||
def getDescription(self):
|
|
||||||
return ''
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'):
|
|
||||||
return
|
|
||||||
if self.env['runtime']['screenManager'].isScreenChange():
|
|
||||||
return
|
|
||||||
# detect an change on the screen, we just want to cursor arround, so no change should appear
|
|
||||||
if self.env['runtime']['screenManager'].isDelta():
|
|
||||||
return
|
|
||||||
if self.env['runtime']['screenManager'].isNegativeDelta():
|
|
||||||
return
|
|
||||||
# is a vertical change?
|
|
||||||
if self.env['runtime']['cursorManager'].isCursorVerticalMove():
|
|
||||||
return
|
|
||||||
# is it a horizontal change?
|
|
||||||
if not self.env['runtime']['cursorManager'].isCursorHorizontalMove():
|
|
||||||
return
|
|
||||||
x, y, currChar = char_utils.getCurrentChar(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText'])
|
|
||||||
if not currChar.isspace():
|
|
||||||
self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False)
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
#!/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Fenrir TTY screen reader
|
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
|
||||||
|
|
||||||
from core import debug
|
|
||||||
|
|
||||||
class command():
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
def initialize(self, environment):
|
|
||||||
self.env = environment
|
|
||||||
def shutdown(self):
|
|
||||||
pass
|
|
||||||
def getDescription(self):
|
|
||||||
return 'No Description found'
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'):
|
|
||||||
return
|
|
||||||
# detect deletion or chilling
|
|
||||||
if self.env['screen']['newCursor']['x'] <= self.env['screen']['oldCursor']['x']:
|
|
||||||
return
|
|
||||||
# is there any change?
|
|
||||||
if not self.env['runtime']['screenManager'].isDelta():
|
|
||||||
return
|
|
||||||
# big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now)
|
|
||||||
if len(self.env['screen']['newDelta']) > 3:
|
|
||||||
return
|
|
||||||
# filter unneded space on word begin
|
|
||||||
currDelta = self.env['screen']['newDelta']
|
|
||||||
if len(currDelta.strip()) != len(currDelta) and \
|
|
||||||
currDelta.strip() != '':
|
|
||||||
currDelta = currDelta.strip()
|
|
||||||
self.env['runtime']['outputManager'].presentText(currDelta, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False)
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
||||||
|
|
@ -165,7 +165,7 @@ class driver():
|
|||||||
screenContent = dirtyContent
|
screenContent = dirtyContent
|
||||||
if time.time() - timeout >= 0.4:
|
if time.time() - timeout >= 0.4:
|
||||||
break
|
break
|
||||||
time.sleep(0.03)
|
time.sleep(0.005)
|
||||||
vcsa[currScreen].seek(0)
|
vcsa[currScreen].seek(0)
|
||||||
dirtyContent = vcsa[currScreen].read()
|
dirtyContent = vcsa[currScreen].read()
|
||||||
eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":None})
|
eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":None})
|
||||||
@ -341,13 +341,18 @@ class driver():
|
|||||||
if self.env['screen']['oldCursor']['x'] != self.env['screen']['newCursor']['x'] and \
|
if self.env['screen']['oldCursor']['x'] != self.env['screen']['newCursor']['x'] and \
|
||||||
self.env['screen']['oldCursor']['y'] == self.env['screen']['newCursor']['y'] and \
|
self.env['screen']['oldCursor']['y'] == self.env['screen']['newCursor']['y'] and \
|
||||||
self.env['screen']['newContentText'][:cursorLineStart] == self.env['screen']['oldContentText'][:cursorLineStart]:
|
self.env['screen']['newContentText'][:cursorLineStart] == self.env['screen']['oldContentText'][:cursorLineStart]:
|
||||||
|
cursorLineStartOffset = cursorLineStart
|
||||||
oldScreenText = self.env['screen']['oldContentText'][cursorLineStart:cursorLineEnd]
|
cursorLineEndOffset = cursorLineEnd
|
||||||
|
if (cursorLineStart - 4) > self.env['screen']['newCursor']['y'] * self.env['screen']['columns']:
|
||||||
|
cursorLineStartOffset = (self.env['screen']['newCursor']['x'] - 4)
|
||||||
|
if (cursorLineEndOffset + 4) < self.env['screen']['newCursor']['y'] * self.env['screen']['columns'] + self.env['screen']['columns']:
|
||||||
|
cursorLineEndOffset = (self.env['screen']['newCursor']['x'] + 4)
|
||||||
|
oldScreenText = self.env['screen']['oldContentText'][cursorLineStartOffset:cursorLineEndOffset]
|
||||||
oldScreenText = re.sub(' +',' ',oldScreenText)
|
oldScreenText = re.sub(' +',' ',oldScreenText)
|
||||||
newScreenText = self.env['screen']['newContentText'][cursorLineStart:cursorLineEnd]
|
newScreenText = self.env['screen']['newContentText'][cursorLineStartOffset:cursorLineEndOffset]
|
||||||
newScreenText = re.sub(' +',' ',newScreenText)
|
newScreenText = re.sub(' +',' ',newScreenText)
|
||||||
diff = difflib.ndiff(oldScreenText, newScreenText)
|
diff = difflib.ndiff(oldScreenText, newScreenText)
|
||||||
typing = True
|
typing = True
|
||||||
else:
|
else:
|
||||||
diff = difflib.ndiff( oldScreenText.split('\n'),\
|
diff = difflib.ndiff( oldScreenText.split('\n'),\
|
||||||
newScreenText.split('\n'))
|
newScreenText.split('\n'))
|
||||||
|
Loading…
Reference in New Issue
Block a user