From 5f86ecf0001588c1d05763f72ca5ced896712421 Mon Sep 17 00:00:00 2001 From: Aerick <52895314+aerickt@users.noreply.github.com> Date: Fri, 28 May 2021 14:12:40 -0700 Subject: [PATCH] Add rudimentary morse mode (#19) * add rudimentary morse mode * add comma * remove slash translation as it was conflicting with adding spaces for multiword briefs --- plover_fancytext/character_helpers.py | 83 +++++++++++++++++++++++++++ plover_fancytext/common.py | 3 +- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/plover_fancytext/character_helpers.py b/plover_fancytext/character_helpers.py index 44f78e4..5f07051 100644 --- a/plover_fancytext/character_helpers.py +++ b/plover_fancytext/character_helpers.py @@ -179,6 +179,89 @@ '9': '\u2468' } +MORSE_MAP = { + 'A': '.- ', + 'B': '-... ', + 'C': '-.-. ', + 'D': '-.. ', + 'E': '. ', + 'F': '..-. ', + 'G': '--. ', + 'H': '.... ', + 'I': '.. ', + 'J': '.--- ', + 'K': '-.- ', + 'L': '.-.. ', + 'M': '-- ', + 'N': '-. ', + 'O': '--- ', + 'P': '.--. ', + 'Q': '--.- ', + 'R': '.-. ', + 'S': '... ', + 'T': '- ', + 'U': '..- ', + 'V': '...- ', + 'W': '.-- ', + 'X': '-..- ', + 'Y': '-.-- ', + 'Z': '--.. ', + 'a': '.- ', + 'b': '-... ', + 'c': '-.-. ', + 'd': '-.. ', + 'e': '. ', + 'f': '..-. ', + 'g': '--. ', + 'h': '.... ', + 'i': '.. ', + 'j': '.--- ', + 'k': '-.- ', + 'l': '.-.. ', + 'm': '-- ', + 'n': '-. ', + 'o': '--- ', + 'p': '.--. ', + 'q': '--.- ', + 'r': '.-. ', + 's': '... ', + 't': '- ', + 'u': '..- ', + 'v': '...- ', + 'w': '.-- ', + 'x': '-..- ', + 'y': '-.-- ', + 'z': '--.. ', + '0': '----- ', + '1': '.---- ', + '2': '..--- ', + '3': '...-- ', + '4': '....- ', + '5': '..... ', + '6': '-.... ', + '7': '--... ', + '8': '---.. ', + '9': '----. ', + '!': '-.-.-- ', + '?': '..--.. ', + '-': '-....- ', + '.': '.-.-.- ', + ',': '--..--', + '@': '.--.-. ', + '=': '-...- ', + '(': '-.--. ', + ')': '-.--.- ', + '+': '.-.-. ', + '&': '.-... ', + '\'': '.----. ', + '"': '.-..-. ', + ';': '-.-.-. ', + ':': '---... ', + '$': '...-..- ', + '_': '..--.- ', + ' ': '/ ' +} + # TODO: https://www.unicode.org/charts/PDF/UFF00.pdf FULLWIDTH_MAP = { "!": "\uFF01", diff --git a/plover_fancytext/common.py b/plover_fancytext/common.py index b90c511..b92f2ad 100644 --- a/plover_fancytext/common.py +++ b/plover_fancytext/common.py @@ -5,10 +5,11 @@ from .substitute import Substitute from .figlet import Figletise from .character_helpers import \ - BUBBLE_MAP, MEDIEVAL_MAP, UPSIDE_DOWN_MAP, FULLWIDTH_MAP + BUBBLE_MAP, MEDIEVAL_MAP, UPSIDE_DOWN_MAP, FULLWIDTH_MAP, MORSE_MAP TRANSFORMERS = { 'bubble': lambda: Substitute(BUBBLE_MAP), + 'morse': lambda: Substitute(MORSE_MAP), 'crytyping': lambda: CryTyping(), 'medieval': lambda: Substitute(MEDIEVAL_MAP), 'fullwidth': lambda: Substitute(FULLWIDTH_MAP),