make indention speak

This commit is contained in:
chrys 2018-03-24 21:08:08 +01:00
parent 40c26cbcf4
commit 9dc8287a63

View File

@ -10,7 +10,7 @@ from fenrirscreenreader.utils import word_utils
class command(): class command():
def __init__(self): def __init__(self):
pass self.lastIdent = -1
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment
def shutdown(self): def shutdown(self):
@ -22,6 +22,7 @@ class command():
if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'): if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'):
return return
if self.env['runtime']['screenManager'].isScreenChange(): if self.env['runtime']['screenManager'].isScreenChange():
self.lastIdent = 0
return return
# this leads to problems in vim -> status line change -> no announcement, so we do check the lengh as hack # this leads to problems in vim -> status line change -> no announcement, so we do check the lengh as hack
if self.env['runtime']['screenManager'].isDelta(): if self.env['runtime']['screenManager'].isDelta():
@ -36,11 +37,21 @@ class command():
if currLine.isspace(): if currLine.isspace():
self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False) self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False)
else: else:
currIdent = len(currLine) - len(currLine.lstrip())
if self.lastIdent == -1:
self.lastIdent = currIdent
if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoPresentIndent'): if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoPresentIndent'):
if oldIndent < newIndent: self.env['runtime']['outputManager'].presentText('indented ' + str(oldIndent - newIndent), interrupt=True, flush=False) doInterrupt = True
if oldIndent > newIndent: self.env['runtime']['outputManager'].presentText('outdented ' + str(newIndent - oldIndent), interrupt=True, flush=False) if self.lastIdent < currIdent:
self.env['runtime']['outputManager'].presentText(_('indented ') + str(currIdent - self.lastIdent) + ' ', interrupt=doInterrupt, flush=False)
doInterrupt = False
if self.lastIdent > currIdent:
self.env['runtime']['outputManager'].presentText(_('outdented ') + str(self.lastIdent - currIdent) + ' ', interrupt=doInterrupt, flush=False)
doInterrupt = False
self.env['runtime']['outputManager'].presentText(currLine, interrupt=doInterrupt, flush=False)
else:
self.env['runtime']['outputManager'].presentText(currLine, interrupt=True, flush=False) self.env['runtime']['outputManager'].presentText(currLine, interrupt=True, flush=False)
self.lastIdent = currIdent
def setCallback(self, callback): def setCallback(self, callback):
pass pass