From 71da9c7dadbed83c7ddf5bf5186598756339c0c0 Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 29 Aug 2016 01:11:11 +0200 Subject: [PATCH] add curr_[char,word]_phonetic commands --- config/keyboard/desktop.conf | 2 ++ config/keyboard/laptop.conf | 2 ++ config/keyboard/test.conf | 2 ++ .../commands/commands/curr_char_phonetic.py | 25 +++++++++++++++++ .../commands/commands/curr_word_phonetic.py | 28 +++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 src/fenrir-package/commands/commands/curr_char_phonetic.py create mode 100644 src/fenrir-package/commands/commands/curr_word_phonetic.py diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 7dc73774..e328e1fb 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -6,9 +6,11 @@ 1-KEY_KP5=curr_word 1-KEY_KP4=prev_word 1-KEY_KP6=next_word +#=curr_word_phonetic 1-KEY_KP2=curr_char 1-KEY_KP1=prev_char 1-KEY_KP3=next_char +#=curr_char_phonetic #=cursor_position #=indent_curr_line 1-KEY_KPDOT=exit_review diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 9a0b3c29..f6a9a2f8 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -6,9 +6,11 @@ 1-KEY_K=curr_word 1-KEY_J=prev_word 1-KEY_L=next_word +#=curr_word_phonetic 1-KEY_COMMA=curr_char 1-KEY_m=prev_char 1-KEY_DOT=next_char +#=curr_char_phonetic 1-KEY_SLASH=exit_review #=cursor_position #=curr_screen diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index eb0f6999..da6923fe 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -6,9 +6,11 @@ 1-FENRIR,1-KEY_KP5=curr_word 1-FENRIR,1-KEY_KP4=prev_word 1-FENRIR,1-KEY_KP6=next_word +1-FENRIR,1-KEY_B=curr_word_phonetic 1-FENRIR,1-KEY_KP2=curr_char 1-FENRIR,1-KEY_KP1=prev_char 1-FENRIR,1-KEY_KP3=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 diff --git a/src/fenrir-package/commands/commands/curr_char_phonetic.py b/src/fenrir-package/commands/commands/curr_char_phonetic.py new file mode 100644 index 00000000..9c020be7 --- /dev/null +++ b/src/fenrir-package/commands/commands/curr_char_phonetic.py @@ -0,0 +1,25 @@ +#!/bin/python +from utils import char_utils + +class command(): + def __init__(self): + pass + def run(self, environment): + if (environment['screenData']['newCursorReview'] != None): + cursorPos = environment['screenData']['newCursorReview'].copy() + else: + cursorPos = environment['screenData']['newCursor'].copy() + + x, y, currChar = \ + char_utils.getCurrentChar(cursorPos['x'], cursorPos['y'], environment['screenData']['newContentText']) + + if currChar.strip() == '': + environment['runtime']['outputManager'].presentText(environment, "blank" ,interrupt=True) + else: + currChar = char_utils.getPhonetic(currChar) + environment['runtime']['outputManager'].presentText(environment, currChar ,interrupt=True) + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass diff --git a/src/fenrir-package/commands/commands/curr_word_phonetic.py b/src/fenrir-package/commands/commands/curr_word_phonetic.py new file mode 100644 index 00000000..d5566f6b --- /dev/null +++ b/src/fenrir-package/commands/commands/curr_word_phonetic.py @@ -0,0 +1,28 @@ +#!/bin/python +from utils import word_utils +from utils import char_utils + +class command(): + def __init__(self): + pass + def run(self, environment): + if (environment['screenData']['newCursorReview'] != None): + cursorPos = environment['screenData']['newCursorReview'].copy() + else: + cursorPos = environment['screenData']['newCursor'].copy() + x, y, currWord = \ + word_utils.getCurrentWord(cursorPos['x'], cursorPos['y'], environment['screenData']['newContentText']) + + if currWord.strip() == '': + environment['runtime']['outputManager'].presentText(environment, "blank", interrupt=True) + else: + firstSequence = True + for c in currWord: + currChar = char_utils.getPhonetic(c) + environment['runtime']['outputManager'].presentText(environment, currChar, interrupt=firstSequence) + firstSequence = False + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass