From 119a36a6ca04986f86f46de867999483c8057b68 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 25 Feb 2017 16:16:26 +0100 Subject: [PATCH] improve vim/emaces --- src/fenrir/commands/onInput/72000-history.py | 58 +++++++++++++++++++ .../onScreenUpdate/deactive/70000-incoming.py | 36 ++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/fenrir/commands/onInput/72000-history.py create mode 100644 src/fenrir/commands/onScreenUpdate/deactive/70000-incoming.py diff --git a/src/fenrir/commands/onInput/72000-history.py b/src/fenrir/commands/onInput/72000-history.py new file mode 100644 index 00000000..48b16434 --- /dev/null +++ b/src/fenrir/commands/onInput/72000-history.py @@ -0,0 +1,58 @@ +#!/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 '' + + def run(self): + if self.env['runtime']['inputManager'].noKeyPressed(): + return + if self.env['screenData']['newAttribDelta'] != '': + return + if self.env['runtime']['screenManager'].isScreenChange(): + return + if self.env['runtime']['cursorManager'].isCursorVerticalMove(): + return + if len(self.env['input']['currInput']) != 1: + return + if not self.env['input']['currInput'][0] in ['KEY_UP','KEY_DOWN']: + return + prevLine = self.env['screenData']['oldContentText'].split('\n')[self.env['screenData']['newCursor']['y']] + currLine = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']] + if not currLine.isspace(): + currPrompt = currLine.find('$') + rootPrompt = currLine.find('#') + if currPrompt <= 0: + if rootPrompt > 0: + currPrompt = rootPrompt + else: + announce = currLine + if currPrompt > 0: + remove_digits = str.maketrans('0123456789', ' ') + if prevLine[:currPrompt].translate(remove_digits) == currLine[:currPrompt].translate(remove_digits): + announce = currLine[currPrompt+1:] + else: + announce = currLine + + if currLine.isspace(): + self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True, flush=False) + else: + self.env['runtime']['outputManager'].presentText(announce, interrupt=True, flush=False) + self.env['commandsIgnore']['onScreenUpdate']['CHAR_DELETE_ECHO'] = True + self.env['commandsIgnore']['onScreenUpdate']['CHAR_ECHO'] = True + self.env['commandsIgnore']['onScreenUpdate']['INCOMING_IGNORE'] = True + def setCallback(self, callback): + pass + diff --git a/src/fenrir/commands/onScreenUpdate/deactive/70000-incoming.py b/src/fenrir/commands/onScreenUpdate/deactive/70000-incoming.py new file mode 100644 index 00000000..fe96b5c4 --- /dev/null +++ b/src/fenrir/commands/onScreenUpdate/deactive/70000-incoming.py @@ -0,0 +1,36 @@ +#!/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('speech', 'autoReadIncoming'): + return + # is there something to read? + #if not self.env['runtime']['screenManager'].isDelta(): + # return + + # its a cursor movement (experimental) - maybe also check current shortcut string? + if abs(self.env['screenData']['newCursor']['x'] - self.env['screenData']['oldCursor']['x']) >= 1: + if len(self.env['screenData']['newDelta'].strip(' \n\t')) <= 2: + return + #if abs(self.env['screenData']['newCursor']['y'] - self.env['screenData']['oldCursor']['y']) = 1: + # return + self.env['runtime']['outputManager'].presentText(self.env['screenData']['newDelta'], interrupt=False, flush=False) + + def setCallback(self, callback): + pass +