add attribute announcement

This commit is contained in:
chrys 2017-08-16 02:21:52 +02:00
commit 2111c26980
13 changed files with 204 additions and 8 deletions

View File

@ -7,7 +7,7 @@ Fix Bugs:
- Wlan is disabled on Lenovo (LED is not synced?, needs debug bgid)
General:
- implement commands
- implement commands (WIP)
attributes_curr_char (Easy for contribution)
https://github.com/jwilk/vcsapeek/blob/master/linuxvt.py
-----------DONE----------------

View File

@ -17,6 +17,12 @@ Cleanups:
settingsData -> defaultSettings.py
General:
- imporove attribute handling
[] add an attribute sound
[] beep on cursor/ review by char (capital wins)
[] beep on review by word (once for multible, captial wins)
[] configurable (by char, by word, none)
- generic list or see Tutorial mode list (convert clipboard management) (Easy for contribution)
next item
pref item

View File

@ -61,7 +61,7 @@ KEY_FENRIR,KEY_SHIFT,KEY_7=set_bookmark_7
KEY_FENRIR,KEY_7=bookmark_7
KEY_FENRIR,KEY_CTRL,KEY_8=clear_bookmark_8
KEY_FENRIR,KEY_SHIFT,KEY_8=set_bookmark_8
KEY_FENRIR,KEY_8=bookmark_8
#KEY_FENRIR,KEY_8=bookmark_8
KEY_FENRIR,KEY_CTRL,KEY_9=clear_bookmark_9
KEY_FENRIR,KEY_SHIFT,KEY_9=set_bookmark_9
KEY_FENRIR,KEY_9=bookmark_9
@ -85,6 +85,7 @@ KEY_FENRIR,KEY_KPASTERISK=toggle_highlight_tracking
KEY_FENRIR,KEY_Q=quit_fenrir
KEY_FENRIR,KEY_T=time
2,KEY_FENRIR,KEY_T=date
KEY_KPMINUS=attribute_cursor
KEY_FENRIR,KEY_S=spell_check
2,KEY_FENRIR,KEY_S=add_word_to_spell_check
KEY_FENRIR,KEY_SHIFT,KEY_S=remove_word_from_spell_check

View File

@ -85,6 +85,7 @@ KEY_FENRIR,KEY_Y=toggle_highlight_tracking
KEY_FENRIR,KEY_Q=quit_fenrir
KEY_FENRIR,KEY_T=time
2,KEY_FENRIR,KEY_T=date
KEY_FENRIR<KEY_MINUS=attribute_cursor
KEY_FENRIR,KEY_S=spell_check
2,KEY_FENRIR,KEY_S=add_word_to_spell_check
KEY_FENRIR,KEY_SHIFT,KEY_S=remove_word_from_spell_check

View File

@ -165,6 +165,14 @@ autoSpellCheck=True
spellCheckLanguage=en_US
scriptPath=/usr/share/fenrir/scripts
commandPath=
#fenrirBGColor = the backgroundcolor
#fenrirFGColor = the foregroundcolor
#fenrirUnderline = speak the underline attribute
#fenrirBold = speak the bold attribute
#fenrirBlink = speak the blink attribute
#fenrirFont = the font
#fenrirFontSize = the fontsize
attributeFormatString=Background fenrirBGColor,Foreground fenrirFGColor,fenrirUnderline,fenrirBold,fenrirBlink, Font fenrirFont,Fontsize fenrirFontSize
[focus]
cursor=True

View File

@ -173,6 +173,14 @@ spellCheckLanguage=en_US
scriptPath=/usr/share/fenrir/scripts
# overload commands, and create new one without changing Fenrir default
commandPath=
#fenrirBGColor = the backgroundcolor
#fenrirFGColor = the foregroundcolor
#fenrirUnderline = speak the underline attribute
#fenrirBold = speak the bold attribute
#fenrirBlink = speak the blink attribute
#fenrirFont = the font
#fenrirFontSize = the fontsize
attributeFormatString=Background fenrirBGColor,Foreground fenrirFGColor,fenrirUnderline,fenrirBold,fenrirBlink, Font fenrirFont,Fontsize fenrirFontSize
[focus]
#follow the text cursor

View File

@ -120,6 +120,14 @@ spellCheckLanguage=en_US
scriptPath=/usr/share/fenrir/scripts
# overload commands, and create new one without changing Fenrir default
commandPath=
#fenrirBGColor = the backgroundcolor
#fenrirFGColor = the foregroundcolor
#fenrirUnderline = speak the underline attribute
#fenrirBold = speak the bold attribute
#fenrirBlink = speak the blink attribute
#fenrirFont = the font
#fenrirFontSize = the fontsize
attributeFormatString=Background fenrirBGColor,Foreground fenrirFGColor,fenrirUnderline,fenrirBold,fenrirBlink, Font fenrirFont,Fontsize fenrirFontSize
[focus]
#follow the text cursor

39
play zone/colors.sh Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
echo "foreground colors"
echo -e "\e[39mDefault"
echo -e "\e[30mBlack"
echo -e "\e[31mRed"
echo -e "\e[32mGreen"
echo -e "\e[33mYellow"
echo -e "\e[34mBlue"
echo -e "\e[35mMagenta"
echo -e "\e[36mCyan"
echo -e "\e[37mLight gray"
echo -e "\e[90mDark gray"
echo -e "\e[91mLight red"
echo -e "\e[92mLight green"
echo -e "\e[93mLight yellow"
echo -e "\e[94mLight blue"
echo -e "\e[95mLight magenta"
echo -e "\e[96mLight cyan"
echo -e "\e[97mWhite"
echo "background colors"
echo -e "\e[49mDefault"
echo -e "\e[40mBlack"
echo -e "\e[41mRed"
echo -e "\e[42mGreen"
echo -e "\e[43mYellow"
echo -e "\e[44mBlue"
echo -e "\e[45mMagenta"
echo -e "\e[46mCyan"
echo -e "\e[47mLight gray"
echo -e "\e[100mDark gray"
echo -e "\e[101mLight red"
echo -e "\e[102mLight green"
echo -e "\e[103mLight yellow"
echo -e "\e[104mLight blue"
echo -e "\e[105mLight magenta"
echo -e "\e[106mLight cyan"
echo -e "\e[107mWhite"

48
play zone/fg.sh Normal file
View File

@ -0,0 +1,48 @@
#!/bin/bash
echo "foreground colors"
echo -e "\e[39mDefault"
echo -e "\e[30mBlack"
echo -e "\e[31mRed"
echo -e "\e[32mGreen"
echo -e "\e[33mYellow"
echo -e "\e[34mBlue"
echo -e "\e[35mMagenta"
echo -e "\e[36mCyan"
echo -e "\e[37mLight gray"
echo -e "\e[90mDark gray"
echo -e "\e[91mLight red"
echo -e "\e[92mLight green"
echo -e "\e[93mLight yellow"
echo -e "\e[94mLight blue"
echo -e "\e[95mLight magenta"
echo -e "\e[96mLight cyan"
echo -e "\e[97mWhite"
#7: _('Default'), 0: _('Black'), 4: _('Red'), 2: _('Green'), 6: _('Yellow'), 1: _('Blue'), 5: _('Magenta'), 3: _('Cyan'), 7: _('Light gray'), 8: _('Dark gray'), 12: _('Light red'), 10: , ('Light green'), 14: _('Light yellow'), 9: _('Light blue'), 13: _('Light magenta'), 11: _('Light cyan'), 15: _('White')
echo "background colors"
echo -e "\e[49mDefault"
echo -e "\e[40mBlack"
echo -e "\e[41mRed"
echo -e "\e[42mGreen"
echo -e "\e[43mYellow"
echo -e "\e[44mBlue"
echo -e "\e[45mMagenta"
echo -e "\e[46mCyan"
echo -e "\e[47mLight gray"
echo -e "\e[100mDark gray"
echo -e "\e[101mLight red"
echo -e "\e[102mLight green"
echo -e "\e[103mLight yellow"
echo -e "\e[104mLight blue"
echo -e "\e[105mLight magenta"
echo -e "\e[106mLight cyan"
echo -e "\e[107mWhite"
echo "format"
echo -e "\e[1mBold"
echo -e "\e[2mDim"
echo -e "\e[4mUnderlined"
echo -e "\e[5mBlink"
echo -e "\e[7minverted"
echo -e "\e[8mHidden"

View File

@ -0,0 +1,27 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
from utils import screen_utils
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):
cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor()
attributes = screen_utils.splitEvery(self.env['screen']['newContentAttrib'], self.env['screen']['columns'])
attributes = attributes[cursorPos['y']][cursorPos['x']]
attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString')
attributeFormatString = self.env['runtime']['screenManager'].formatAttributes(attributes, attributeFormatString)
self.env['runtime']['outputManager'].presentText(attributeFormatString, soundIcon='', interrupt=True)
def setCallback(self, callback):
pass

View File

@ -35,7 +35,21 @@ class screenManager():
# or len(self.env['screen']['newDelta']) > 6:
# self.env['runtime']['screenDriver'].getCurrApplication()
self.env['screen']['lastScreenUpdate'] = time.time()
def formatAttributes(self, attribute, attributeFormatString = None):
if not attributeFormatString:
attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString')
if not attributeFormatString:
return ''
if attributeFormatString == '':
return ''
attributeFormatString = attributeFormatString.replace('fenrirBGColor', self.env['runtime']['screenDriver'].getFenrirBGColor(attribute))
attributeFormatString = attributeFormatString.replace('fenrirFGColor', self.env['runtime']['screenDriver'].getFenrirFGColor(attribute))
attributeFormatString = attributeFormatString.replace('fenrirUnderline', self.env['runtime']['screenDriver'].getFenrirUnderline(attribute))
attributeFormatString = attributeFormatString.replace('fenrirBold', self.env['runtime']['screenDriver'].getFenrirBold(attribute))
attributeFormatString = attributeFormatString.replace('fenrirBlink', self.env['runtime']['screenDriver'].getFenrirBlink(attribute))
attributeFormatString = attributeFormatString.replace('fenrirFontSize', self.env['runtime']['screenDriver'].getFenrirFontSize(attribute))
attributeFormatString = attributeFormatString.replace('fenrirFont', self.env['runtime']['screenDriver'].getFenrirFont(attribute))
return attributeFormatString
def isSuspendingScreen(self, screen = None):
if screen == None:
screen = self.env['screen']['newTTY']

View File

@ -67,8 +67,9 @@ settingsData = {
'dateFormat': '%A, %B %d, %Y',
'autoSpellCheck': False,
'spellCheckLanguage': 'en_US',
'scriptPath':'/usr/share/fenrir/scripts',
'commandPath':'/usr/share/fenrir/commands',
'scriptPath': '/usr/share/fenrir/scripts',
'commandPath': '/usr/share/fenrir/commands',
'attributeFormatString': 'Background fenrirBGColor,Foreground fenrirFGColor,fenrirUnderline,fenrirBold,fenrirBlink, Font fenrirFont,Fontsize fenrirFontSize'
},
'focus':{
'cursor': True,

View File

@ -35,6 +35,8 @@ class driver():
self.vcsaDevicePath = '/dev/vcsa'
self.ListSessions = None
self.charmap = {}
self.bgColorNames = {0: _('black'), 1: _('blue'), 2: _('green'), 3: _('cyan'), 4: _('red'), 5: _('Magenta'), 6: _('brown/yellow'), 7: _('white')}
self.fgColorNames = {0: _('Black'), 1: _('Blue'), 2: _('Green'), 3: _('Cyan'), 4: _('Red'), 5: _('Magenta'), 6: _('brown/yellow'), 7: _('Light gray'), 8: _('Dark gray'), 9: _('Light blue'), 10: ('Light green'), 11: _('Light cyan'), 12: _('Light red'), 13: _('Light magenta'), 14: _('Light yellow'), 15: _('White')}
self.hichar = None
def initialize(self, environment):
self.env = environment
@ -209,7 +211,7 @@ class driver():
#ink = 7
#paper = 0
#ch = ' '
lineAttrib.append((7,7,0,0,0,0)) # attribute, ink, paper, blink, bold, underline
lineAttrib.append((7,15,0,0,0,0)) # attribute, ink, paper, blink, bold, underline
lineText += ' '
continue
(sh,) = unpack("=H", data)
@ -219,6 +221,12 @@ class driver():
attr >>= 1
ink = attr & 0x0F
paper = (attr>>4) & 0x0F
blink = 0
#if attr & 1:
# blink = 1
bold = 0
#if attr & 16:
# bold = 1
#if (ink != 7) or (paper != 0):
# print(ink,paper)
if sh & self.hichar:
@ -227,11 +235,38 @@ class driver():
lineText += self.charmap[ch]
except KeyError:
lineText += '?'
lineAttrib.append((attr,ink, paper,0,0,0)) # attribute, ink, paper, blink, bold, underline
lineAttrib.append((attr,ink, paper,blink,bold,0)) # attribute, ink, paper, blink, bold, underline
allText += lineText + '\n'
allAttrib += lineAttrib
return str(allText), allAttrib
def getFenrirBGColor(self, attribute):
try:
return self.bgColorNames[attribute[2]]
except Exception as e:
print(e)
return ''
def getFenrirFGColor(self, attribute):
try:
return self.fgColorNames[attribute[1]]
except Exception as e:
print(e)
return ''
def getFenrirUnderline(self, attribute):
if attribute[5] == 1:
return _('underlined')
return ''
def getFenrirBold(self, attribute):
if attribute[4] == 1:
return _('bold')
return ''
def getFenrirBlink(self, attribute):
if attribute[3] == 1:
return _('blink')
return ''
def getFenrirFont(self, attribute):
return _('Default')
def getFenrirFontSize(self, attribute):
return _('Default')
def update(self, trigger='onUpdate'):
if trigger == 'onInput': # no need for an update on input for VCSA
return