add initial set/read/clear bookmark commands

This commit is contained in:
chrys 2016-09-22 23:42:50 +02:00
parent ac6e11537c
commit a037dde714
10 changed files with 193 additions and 63 deletions

View File

@ -21,6 +21,9 @@ KEY_FENRIR,KEY_KPDOT=exit_review
KEY_FENRIR,KEY_KP5=curr_screen
KEY_FENRIR,KEY_KP8=curr_screen_before_cursor
KEY_FENRIR,KEY_KP2=curr_screen_after_cursor
#=clear_bookmark_1
#=set_bookmark_1
#=bookmark_1
KEY_KPPLUS=last_incomming
KEY_FENRIR,KEY_F2=toggle_braille
KEY_FENRIR,KEY_F3=toggle_sound

View File

@ -20,6 +20,9 @@ KEY_FENRIR,KEY_SHIFT,KEY_DOT=cursor_position
KEY_FENRIR,KEY_SHIFT,KEY_K=curr_screen
KEY_FENRIR,KEY_SHIFT,KEY_I=curr_screen_before_cursor
KEY_FENRIR,KEY_SHIFT,KEY_COMMA=curr_screen_after_cursor
#=clear_bookmark_1
#=set_bookmark_1
#=bookmark_1
2,KEY_FENRIR,KEY_I=indent_curr_line
KEY_FENRIR,KEY_SEMICOLON=last_incomming
KEY_FENRIR,KEY_F2=toggle_braille

View File

@ -1,58 +1,60 @@
#=toggle_tutorial_mode
1-KEY_LEFTCTRL=shut_up
1-FENRIR,1-KEY_RIGHTCTRL=shut_up
1-FENRIR,1-KEY_KPENTER=review_bottom
1-FENRIR,1-KEY_KPPLUS=review_top
1-FENRIR,1-KEY_KP8=review_curr_line
1-FENRIR,1-KEY_KP7=review_prev_line
1-FENRIR,1-KEY_KP9=review_next_line
KEY_FENRIR,KEY_H=toggle_tutorial_mode
KEY_CTRL=shut_up
KEY_FENRIR,KEY_KP9=review_bottom
KEY_FENRIR,KEY_KP7=review_top
KEY_KP8=review_curr_line
KEY_KP7=review_prev_line
KEY_KP9=review_next_line
#=present_first_line
#=present_last_line
1-FENRIR,1-KEY_KP5=review_curr_word
1-FENRIR,1-KEY_KP4=review_prev_word
1-FENRIR,1-KEY_KP6=review_next_word
1-FENRIR,1-KEY_B=curr_word_phonetic
1-FENRIR,1-KEY_KP2=review_curr_char
1-FENRIR,1-KEY_KP1=review_prev_char
1-FENRIR,1-KEY_KP3=review_next_char
1-FENRIR,1-KEY_W=curr_char_phonetic
1-FENRIR,1-KEY_KPDOT=exit_review
1-FENRIR,1-KEY_J=cursor_position
1-FENRIR,1-KEY_U=curr_screen
1-FENRIR,1-KEY_I=curr_screen_before_cursor
1-FENRIR,1-KEY_O=curr_screen_after_cursor
1-FENRIR,1-KEY_P=indent_curr_line
#=last_incomming
1-FENRIR,1-KEY_F2=toggle_braille
#1-FENRIR,1-KEY_F3=toggle_sound
1-FENRIR,1-KEY_F4=toggle_speech
1-FENRIR,1-KEY_M=toggle_auto_spell_check
#=toggle_output
#=toggle_auto_read
#=quit_fenrir
1-FENRIR,1-KEY_T=time
1-FENRIR,1-KEY_R=date
1-FENRIR,1-KEY_M=spell_check
1-FENRIR,1-KEY_G=add_word_to_spell_check
#=remove_word_from_spell_check
1-FENRIR,1-KEY_A=foreward_keypress
#1-FENRIR,1-KEY_F2=inc_speech_volume
#1-FENRIR,1-KEY_F3=dec_sound_volume
#=inc_speech_rate
#=dec_speech_rate
#=inc_speech_pitch
#=dec_speech_pitch
#=inc_sound_volume
#=dec_sound_volume
1-FENRIR,1-KEY_F2=clear_clipboard
1-FENRIR,1-KEY_X=remove_marks
1-FENRIR,1-KEY_A=first_clipboard
1-FENRIR,1-KEY_S=last_clipboard
1-FENRIR,1-KEY_D=prev_clipboard
1-FENRIR,1-KEY_F=next_clipboard
#=curr_clipboard
1-FENRIR,1-KEY_Q=set_mark
#1-FENRIR,1-KEY_V=marked_text
1-FENRIR,1-KEY_V=copy_marked_to_clipboard
KEY_KP5=review_curr_word
KEY_KP4=review_prev_word
KEY_KP6=review_next_word
2,KEY_KP5=curr_word_phonetic
KEY_KP2=review_curr_char
KEY_KP1=review_prev_char
KEY_KP3=review_next_char
2,KEY_KP2=curr_char_phonetic
KEY_KPDOT=cursor_position
KEY_FENRIR,KEY_I=indent_curr_line
KEY_FENRIR,KEY_KPDOT=exit_review
KEY_FENRIR,KEY_KP5=curr_screen
KEY_FENRIR,KEY_KP8=curr_screen_before_cursor
KEY_FENRIR,KEY_KP2=curr_screen_after_cursor
KEY_FENRIR,KEY_3=clear_bookmark_1
KEY_FENRIR,KEY_1=set_bookmark_1
KEY_FENRIR,KEY_2=bookmark_1
KEY_KPPLUS=last_incomming
KEY_FENRIR,KEY_F2=toggle_braille
KEY_FENRIR,KEY_F3=toggle_sound
KEY_FENRIR,KEY_F4=toggle_speech
KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check
KEY_FENRIR,KEY_BACKSLASH=toggle_output
key_FENRIR,KEY_KPENTER=toggle_auto_read
KEY_FENRIR,KEY_Q=quit_fenrir
KEY_FENRIR,KEY_T=time
2,KEY_FENRIR,KEY_T=date
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
KEY_FENRIR,KEY_BACKSPACE=foreward_keypress
KEY_FENRIR,KEY_UP=inc_speech_volume
KEY_FENRIR,KEY_DOWN=dec_speech_volume
KEY_FENRIR,KEY_RIGHT=inc_speech_rate
KEY_FENRIR,KEY_LEFT=dec_speech_rate
KEY_FENRIR,KEY_ALT,KEY_RIGHT=inc_speech_pitch
KEY_FENRIR,KEY_ALT,KEY_LEFT=dec_speech_pitch
KEY_FENRIR,KEY_ALT,KEY_UP=inc_sound_volume
KEY_FENRIR,KEY_ALT,KEY_DOWN=dec_sound_volume
KEY_FENRIR,KEY_SHIFT,KEY_C=clear_clipboard
KEY_FENRIR,KEY_SHIFT,KEY_X=remove_marks
KEY_FENRIR,KEY_HOME=first_clipboard
KEY_FENRIR,KEY_END=last_clipboard
KEY_FENRIR,KEY_PAGEUP=prev_clipboard
KEY_FENRIR,KEY_PAGEDOWN=next_clipboard
KEY_FENRIR,KEY_SHIFT,KEY_C=curr_clipboard
KEY_FENRIR,KEY_X=set_mark
KEY_FENRIR,KEY_SHIFT,KEY_X=marked_text
KEY_FENRIR,KEY_C=copy_marked_to_clipboard
# linux only
1-FENRIR,1-KEY_F3=linux_paste_clipboard
KEY_FENRIR,KEY_V=linux_paste_clipboard

View File

@ -79,7 +79,7 @@ device=all
grabDevices=True
ignoreShortcuts=False
# the current shortcut layout located in /etc/fenrir/keyboard
keyboardLayout=desktop
keyboardLayout=test
# echo chars while typing.
charEcho=False
# echo deleted chars

View File

@ -0,0 +1,52 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
from utils import mark_utils
class command():
def __init__(self):
self.ID = '1'
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'read Bookmark ' + self.ID
def run(self):
currApp = ''
try:
currApp = str(self.env['screenData']['newApplication'][0])
except:
currApp = 'DEFAULT'
if not self.env['commandBuffer']['bookMarks'][self.ID]:
self.env['runtime']['outputManager'].presentText("Bookmark " + self.ID + "not found.", interrupt=True)
return
if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]:
self.env['runtime']['outputManager'].presentText("Bookmark for application " + currApp + "not found.", interrupt=True)
return
if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']:
self.env['runtime']['outputManager'].presentText("No valid bookmark position", interrupt=True)
return
# set marks
marked = ''
startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy()
if self.env['commandBuffer']['bookMarks'][self.ID][currApp]]['2']:
endMark = self.env['commandBuffer']['Marks']['2'].copy()
marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screenData']['newContentText'])
else:
x, y, marked = \
line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screenData']['newContentText'])
if marked.strip(" \t\n") == '':
self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else:
self.env['runtime']['outputManager'].presentText(marked, interrupt=True)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,30 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
self.ID = '1'
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'remove Bookmark ' + self.ID
def run(self):
currApp = ''
try:
currApp = str(self.env['screenData']['newApplication'][0])
except:
currApp = 'DEFAULT'
del self.env['commandBuffer']['bookMarks'][self.ID][currApp]
self.env['runtime']['outputManager'].presentText('Bookmark ' + self.ID + " removed for application " + currApp, interrupt=True)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,39 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
self.ID = '1'
def initialize(self, environment):
self.env = environment
self.env['commandBuffer']['bookMarks'][self.ID] = {}
def shutdown(self):
pass
def getDescription(self):
return 'set Bookmark ' + self.ID
def run(self):
if not self.env['commandBuffer']['Marks']['1']:
self.env['runtime']['outputManager'].presentText("No Mark found", interrupt=True)
return
currApp = ''
try:
currApp = str(self.env['screenData']['newApplication'][0])
except Exception as e:
print(e)
currApp = 'DEFAULT'
self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {}
self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy()
if self.env['commandBuffer']['Marks']['2']:
self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy()
self.env['runtime']['outputManager'].presentText('Bookmark ' + self.ID + " set for application " + currApp, interrupt=True)
self.env['commandBuffer']['Marks']['1'] = None
self.env['commandBuffer']['Marks']['2'] = None
def setCallback(self, callback):
pass

View File

@ -69,9 +69,9 @@ class commandManager():
if len(unLoadScript) == 0:
oldScript = 'DEFAULT'
else:
oldScript = unLoadScript[0].upper()
oldScript = unLoadScript[0]
elif unLoadScript:
oldScript = str(unLoadScript).upper()
oldScript = str(unLoadScript)
if oldScript == '':
oldScript == 'DEFAULT'
if self.commandExists(oldScript, trigger):
@ -87,9 +87,9 @@ class commandManager():
if len(loadScript) == 0:
newScript = 'DEFAULT'
else:
newScript = loadScript[0].upper()
newScript = loadScript[0]
elif unLoadScript:
newScript = str(loadScript).upper()
newScript = str(loadScript)
if newScript == '':
newScript == 'DEFAULT'
if self.commandExists(newScript, trigger):

View File

@ -16,14 +16,15 @@ commandBuffer = {
'genericListSelection': 0,
'clipboard':[],
'currClipboard': 0,
'Marks':{'1':None, '2':None}
'Marks':{'1':None, '2':None},
'bookMarks':{},
}
# used by the commandManager
commandInfo = {
'currCommand': '',
'lastCommandExecutionTime': time.time(),
'lastCommandRequestTime': time.time()
'lastCommandRequestTime': time.time(),
}
# used by the commandManager

View File

@ -46,7 +46,7 @@ class driver():
not "sh" == i[0] and \
not "ps" == i[0]:
if "tty"+currScreen in i[1]:
appList.append(i[0])
appList.append(i[0].upper())
return appList
def getIgnoreScreens(self):