Skip to content

Commit

Permalink
Add rudimentary morse mode (#19)
Browse files Browse the repository at this point in the history
* add rudimentary morse mode

* add comma

* remove slash translation as it was conflicting with adding spaces for multiword briefs
  • Loading branch information
aerickt committed May 28, 2021
1 parent f929945 commit 5f86ecf
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
83 changes: 83 additions & 0 deletions plover_fancytext/character_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion plover_fancytext/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 5f86ecf

Please sign in to comment.