From a14cf82a2f3d477bcd4b16deb588539e40561450 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 25 Aug 2017 21:38:54 +0200 Subject: [PATCH] fix history, start cleaning up API --- .../commands/onScreenUpdate/60000-history.py | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/fenrir/commands/onScreenUpdate/60000-history.py diff --git a/src/fenrir/commands/onScreenUpdate/60000-history.py b/src/fenrir/commands/onScreenUpdate/60000-history.py new file mode 100644 index 00000000..efdbe244 --- /dev/null +++ b/src/fenrir/commands/onScreenUpdate/60000-history.py @@ -0,0 +1,54 @@ +#!/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['screen']['newAttribDelta'] != '': + return + if self.env['runtime']['screenManager'].isScreenChange(): + return + if self.env['runtime']['cursorManager'].isCursorVerticalMove(): + return + if not (self.env['runtime']['inputManager'].getLastDeepestInput() in [['KEY_UP'],['KEY_DOWN']]): + return + prevLine = self.env['screen']['oldContentText'].split('\n')[self.env['screen']['newCursor']['y']] + currLine = self.env['screen']['newContentText'].split('\n')[self.env['screen']['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 +