make highlighted mode work in driver

This commit is contained in:
chrys 2016-11-01 21:55:08 +01:00
parent 965c850ca2
commit 0221ba358f
7 changed files with 20 additions and 18 deletions

View File

@ -21,6 +21,7 @@ ReadWrite permission
- brltty, python-brlapi [using braille] # (not implemented yet) - brltty, python-brlapi [using braille] # (not implemented yet)
- gstreamer [soundicons via gstreamer] # not working yet - gstreamer [soundicons via gstreamer] # not working yet
- python-pyenchant [spell check functionality] - python-pyenchant [spell check functionality]
- aspell-<language> [your languagedata for spellchecker, english support "aspell-en"]
- python-daemonize [use fenrir as background service on Unix like systems] - python-daemonize [use fenrir as background service on Unix like systems]
# installation # installation

View File

@ -77,8 +77,8 @@ autodetectSuspendingScreen=True
[keyboard] [keyboard]
driver=evdev driver=evdev
# filter input devices AUTO, ALL or a DEVICE NAME # filter input devices NOMICE, ALL or a DEVICE NAME
device=AUTO device=ALL
# gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems. # gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems.
grabDevices=True grabDevices=True
ignoreShortcuts=False ignoreShortcuts=False

View File

@ -77,8 +77,8 @@ autodetectSuspendingScreen=True
[keyboard] [keyboard]
driver=evdev driver=evdev
# filter input devices AUTO, ALL or a DEVICE NAME # filter input devices NOMICE, ALL or a DEVICE NAME
device=AUTO device=ALL
# gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems. # gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems.
grabDevices=True grabDevices=True
ignoreShortcuts=False ignoreShortcuts=False

View File

@ -34,8 +34,8 @@ autodetectSuspendingScreen=False
[keyboard] [keyboard]
driver=evdev driver=evdev
# filter input devices AUTO, ALL or a DEVICE NAME # filter input devices NOMICE, ALL or a DEVICE NAME
device=AUTO device=ALL
grabDevices=True grabDevices=True
ignoreShortcuts=False ignoreShortcuts=False
keyboardLayout=desktop keyboardLayout=desktop

View File

@ -75,7 +75,7 @@ class driver():
if self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'ALL': if self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'ALL':
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()} self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()}
self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities()} self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities()}
elif self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'AUTO': elif self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'NOMICE':
self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()} self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()}
self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()} self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()}
else: else:

View File

@ -5,7 +5,7 @@
# By Chrys, Storm Dragon, and contributers. # By Chrys, Storm Dragon, and contributers.
import difflib import difflib
import re import re, time
import subprocess import subprocess
from core import debug from core import debug
from utils import screen_utils from utils import screen_utils
@ -20,6 +20,7 @@ class driver():
def getCurrScreen(self): def getCurrScreen(self):
self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY']
try: try:
time.sleep(0.1)
currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r') currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r')
self.env['screenData']['newTTY'] = str(currScreenFile.read()[3:-1]) self.env['screenData']['newTTY'] = str(currScreenFile.read()[3:-1])
currScreenFile.close() currScreenFile.close()
@ -149,8 +150,7 @@ class driver():
self.env['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x[0] == '-') self.env['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x[0] == '-')
# track highlighted # track highlighted
#print(self.env['screenData']['oldContentAttrib'] , self.env['screenData']['newContentAttrib'])
if self.env['screenData']['oldContentAttrib'] != self.env['screenData']['newContentAttrib']: if self.env['screenData']['oldContentAttrib'] != self.env['screenData']['newContentAttrib']:
self.env['screenData']['newAttribDelta'], currCursor = screen_utils.trackHighlights(self.env['screenData']['oldContentAttrib'], self.env['screenData']['newContentAttrib'], self.env['screenData']['newContentText'], self.env['screenData']['columns']) self.env['screenData']['newAttribDelta'], currCursor = screen_utils.trackHighlights(self.env['screenData']['oldContentAttrib'], self.env['screenData']['newContentAttrib'], self.env['screenData']['newContentText'], self.env['screenData']['columns'])
#print('drin',self.env['screenData']['newAttribDelta']) print('drin',self.env['screenData']['newAttribDelta'])

View File

@ -24,14 +24,14 @@ def trackHighlights(oldAttr, newAttr, text, lenght):
return result, currCursor return result, currCursor
if len(newAttr) == 0: if len(newAttr) == 0:
return result, currCursor return result, currCursor
textLines = insertNewlines(text,lenght) if len(oldAttr) != len(newAttr):
textLines = textLines.split('\n') return result, currCursor
old = splitEvery(oldAttr,lenght) old = splitEvery(oldAttr,lenght)
new = splitEvery(newAttr,lenght) new = splitEvery(newAttr,lenght)
if len(old) != len(new): textLines = text.split('\n')
return result, currCursor if len(textLines) != len(new):
if len(text) != len(new):
return result, currCursor return result, currCursor
try: try:
background = Counter(newAttr).most_common(1) background = Counter(newAttr).most_common(1)
background = background[0][0] background = background[0][0]
@ -39,10 +39,11 @@ def trackHighlights(oldAttr, newAttr, text, lenght):
background = chr(7) background = chr(7)
for line in range(len(new)): for line in range(len(new)):
if old[line] != new[line]: if old[line] != new[line]:
for column in range(len(new)): for column in range(len(new[line])):
if old[line][column] != new[line][column]: if old[line][column] != new[line][column]:
if new[line][column] != background: if new[line][column] != background:
if not currCursor: if not currCursor:
currCursor = {}
currCursor['x'] = column currCursor['x'] = column
currCursor['y'] = line currCursor['y'] = line
result += textLines[line][column] result += textLines[line][column]