fenrir/src/fenrir-package/commands/onScreenUpdate/65000-char_delete_echo.py

43 lines
1.3 KiB
Python
Raw Normal View History

2016-08-07 17:00:54 +02:00
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
2016-08-07 17:00:54 +02:00
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'No Description found'
2016-09-17 02:14:11 +02:00
def run(self):
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'):
return
2016-08-07 17:00:54 +02:00
# detect typing or chilling
if self.env['screenData']['newCursor']['x'] >= self.env['screenData']['oldCursor']['x']:
return
2016-08-07 17:00:54 +02:00
# More than just a deletion happend
if self.env['screenData']['newDelta'].strip() != '':
if self.env['screenData']['newDelta'] != self.env['screenData']['oldDelta']:
return
2016-08-07 17:00:54 +02:00
# No deletion
if self.env['screenData']['newNegativeDelta'] == '':
return
2016-09-02 23:20:27 +02:00
# too much for a single backspace...
if len(self.env['screenData']['newNegativeDelta']) >= 5:
return
2016-09-22 22:42:14 +02:00
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newNegativeDelta'], interrupt=True, ignorePunctuation=True)
2016-08-07 17:00:54 +02:00
def setCallback(self, callback):
pass