From bc396a92236a09ec82f6c5b42e8673b6f14986bc Mon Sep 17 00:00:00 2001 From: root Date: Wed, 12 Oct 2016 22:22:02 +0200 Subject: [PATCH] add toggle_emoticon --- config/keyboard/desktop.conf | 1 + config/keyboard/laptop.conf | 1 + config/keyboard/test.conf | 1 + config/settings/settings.conf | 1 + config/settings/settings.conf.chrys | 1 + config/settings/settings.conf.orig | 1 + config/settings/settings.conf.storm | 1 + .../commands/commands/toggle_emoticons.py | 26 +++++++++++++++++++ src/fenrir/core/punctuationManager.py | 3 ++- src/fenrir/core/settings.py | 1 + 10 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/fenrir/commands/commands/toggle_emoticons.py diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index d5fe4d40..960a09db 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -66,6 +66,7 @@ KEY_FENRIR,KEY_F4=toggle_speech KEY_FENRIR,KEY_CTRL,KEY_P=toggle_punctuation_level KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_BACKSLASH=toggle_output +#=toggle_emoticons key_FENRIR,KEY_KPENTER=toggle_auto_read KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index d85e04f7..d51f9c59 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -66,6 +66,7 @@ KEY_FENRIR,KEY_F4=toggle_speech KEY_FENRIR,KEY_SHIFT,KEY_CTRL,KEY_P=toggle_punctuation_level KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_SHIFT,KEY_ENTER=toggle_output +#=toggle_emoticons KEY_FENRIR,KEY_ENTER=toggle_auto_read KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index d5fe4d40..960a09db 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -66,6 +66,7 @@ KEY_FENRIR,KEY_F4=toggle_speech KEY_FENRIR,KEY_CTRL,KEY_P=toggle_punctuation_level KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_BACKSLASH=toggle_output +#=toggle_emoticons key_FENRIR,KEY_KPENTER=toggle_auto_read KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time diff --git a/config/settings/settings.conf b/config/settings/settings.conf index ad76400e..e5a75410 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -100,6 +100,7 @@ debugLevel=3 punctuationProfile=default punctuationLevel=some numberOfClipboards=10 +emoticons=True # define the current fenrir key fenrirKeys=KEY_KP0,KEY_META timeFormat=%H:%M:%P diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index c8d30263..cfb9f818 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -100,6 +100,7 @@ debugLevel=1 punctuationProfile=default punctuationLevel=Some numberOfClipboards=10 +emoticons=True # define the current fenrir key fenrirKeys=KEY_KP0,KEY_META timeFormat=%H:%M:%P diff --git a/config/settings/settings.conf.orig b/config/settings/settings.conf.orig index 0f17bb6a..5843144e 100644 --- a/config/settings/settings.conf.orig +++ b/config/settings/settings.conf.orig @@ -98,6 +98,7 @@ debugLevel=0 punctuationProfile=default punctuationLevel=some numberOfClipboards=10 +emoticons=True # define the current fenrir key fenrirKeys=KEY_KP0,KEY_META timeFormat=%H:%M%P diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index df2d9f1a..892f1261 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -51,6 +51,7 @@ debugLevel=0 punctuationProfile=default punctuationLevel=some numberOfClipboards=10 +emoticons=True fenrirKeys=KEY_KP0 timeFormat=%H:%M:%P dateFormat="%A, %B %d, %Y" diff --git a/src/fenrir/commands/commands/toggle_emoticons.py b/src/fenrir/commands/commands/toggle_emoticons.py new file mode 100644 index 00000000..fc1872df --- /dev/null +++ b/src/fenrir/commands/commands/toggle_emoticons.py @@ -0,0 +1,26 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from core import debug +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return 'enables or disables announcement of emoticons insteed of chars' + + def run(self): + self.env['runtime']['settingsManager'].setSetting('general', 'emoticons', str(not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'emoticons'))) + if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'emoticons'): + self.env['runtime']['outputManager'].presentText("emoticons enabled", soundIcon='', interrupt=True) + else: + self.env['runtime']['outputManager'].presentText("emoticons disabled", soundIcon='', interrupt=True) + + def setCallback(self, callback): + pass diff --git a/src/fenrir/core/punctuationManager.py b/src/fenrir/core/punctuationManager.py index 50f92195..b287571a 100644 --- a/src/fenrir/core/punctuationManager.py +++ b/src/fenrir/core/punctuationManager.py @@ -40,7 +40,8 @@ class punctuationManager(): def proceedPunctuation(self, text, ignorePunctuation=False): resultText = text resultText = self.useCustomDict(resultText, self.env['punctuation']['CUSTOMDICT']) - resultText = self.useCustomDict(resultText, self.env['punctuation']['EMOJDICT']) + if self.env['runtime']['settingsManager'].getSetting('general', 'emoticons'): + resultText = self.useCustomDict(resultText, self.env['punctuation']['EMOJDICT']) currPunctLevel = '' if not ignorePunctuation and self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').lower() in self.env['punctuation']['LEVELDICT']: currPunctLevel = self.env['punctuation']['LEVELDICT'][self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').lower()] diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 13e4895b..7f59ce7e 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -44,6 +44,7 @@ settings = { 'punctuationProfile':'default', 'punctuationLevel': 1, 'numberOfClipboards': 10, + 'emoticons': True, 'fenrirKeys': ['KEY_KP0'], 'timeFormat': '%I:%M%P', 'dateFormat': '%A, %B %d, %Y',