2016-09-02 15:37:36 -04:00
|
|
|
#!/bin/python
|
2016-09-19 16:15:58 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Fenrir TTY screen reader
|
|
|
|
# By Chrys, Storm Dragon, and contributers.
|
|
|
|
|
|
|
|
from core import debug
|
2016-09-02 15:37:36 -04:00
|
|
|
import time
|
|
|
|
|
|
|
|
class screenManager():
|
|
|
|
def __init__(self):
|
2016-09-13 07:04:55 -04:00
|
|
|
self.autoIgnoreScreens = []
|
2016-09-14 17:27:19 -04:00
|
|
|
|
|
|
|
def initialize(self, environment):
|
2016-09-21 17:17:54 -04:00
|
|
|
self.env = environment
|
|
|
|
self.env['runtime']['settingsManager'].loadDriver(\
|
|
|
|
self.env['runtime']['settingsManager'].getSetting('screen', 'driver'), 'screenDriver')
|
|
|
|
if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'):
|
|
|
|
self.autoIgnoreScreens = self.env['runtime']['screenDriver'].getIgnoreScreens()
|
2016-09-14 17:27:19 -04:00
|
|
|
|
2016-09-21 17:17:54 -04:00
|
|
|
def shutdown(self):
|
|
|
|
self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
|
2016-09-12 19:25:08 -04:00
|
|
|
|
2016-09-27 17:17:46 -04:00
|
|
|
def update(self, trigger = 'onUpdate'):
|
2016-09-29 17:11:57 -04:00
|
|
|
self.env['runtime']['screenDriver'].getCurrScreen()
|
2016-09-21 17:17:54 -04:00
|
|
|
if not self.isSuspendingScreen():
|
2016-10-02 17:27:29 -04:00
|
|
|
if trigger == 'onUpdate' or self.isScreenChange():
|
2016-10-02 17:24:50 -04:00
|
|
|
self.env['runtime']['screenDriver'].getCurrApplication()
|
2016-09-27 17:17:46 -04:00
|
|
|
self.env['runtime']['screenDriver'].update(trigger)
|
2016-09-21 17:17:54 -04:00
|
|
|
self.env['screenData']['lastScreenUpdate'] = time.time()
|
2016-09-04 09:04:23 -04:00
|
|
|
|
2016-09-21 17:17:54 -04:00
|
|
|
def isSuspendingScreen(self):
|
2016-09-27 17:17:46 -04:00
|
|
|
return ((self.env['screenData']['newTTY'] in \
|
2016-09-21 17:17:54 -04:00
|
|
|
self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or
|
2016-09-27 17:17:46 -04:00
|
|
|
(self.env['screenData']['newTTY'] in self.autoIgnoreScreens))
|
|
|
|
|
2016-09-23 03:51:47 -04:00
|
|
|
def isScreenChange(self):
|
2016-09-23 20:45:12 -04:00
|
|
|
return self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']
|
2016-09-27 17:17:46 -04:00
|
|
|
|
2016-09-24 16:56:18 -04:00
|
|
|
def getWindowAreaInText(self, text):
|
|
|
|
if not self.env['runtime']['cursorManager'].isApplicationWindowSet():
|
|
|
|
return text
|
|
|
|
windowText = ''
|
|
|
|
windowList = text.split('\n')
|
2016-09-27 17:17:46 -04:00
|
|
|
windowList = windowList[self.env['commandBuffer']['windowArea'][self.env['screenData']['newApplication']]['1']['y']:self.env['commandBuffer']['windowArea'][currApp]['2']['y'] + 1]
|
2016-09-24 16:56:18 -04:00
|
|
|
for line in windowList:
|
2016-09-27 17:17:46 -04:00
|
|
|
windowText += line[self.env['commandBuffer']['windowArea'][self.env['screenData']['newApplication']]['1']['x']:self.env['commandBuffer']['windowArea'][currApp]['2']['x'] + 1] + '\n'
|
2016-09-24 16:56:18 -04:00
|
|
|
return windowText
|
|
|
|
|