Skip to content

Commit

Permalink
space out morse characters in Substitute (#20)
Browse files Browse the repository at this point in the history
* space out morse characters in Substitute

* uhh this file

* Update README.rst

* Update setup.cfg

* add test for morse

Co-authored-by: Seth Rider <seth@thumbquat.com>
  • Loading branch information
psethwick and Seth Rider committed May 28, 2021
1 parent 5f86ecf commit 4725e46
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 83 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Transformers:
* crytyping: I' finne,,, h ddon'nt w,,,orry about me, re,,el yy
* fullwidth: vaporwave
* medieval: 𝕸𝖊𝖉𝖎𝖊𝖛𝖆𝖑
* morse: ... --- ...
* sarcasm: wELl ThIs IS cONvEnIeNt
* upsidedown: ndsᴉpǝ poʍu
* uwu: Hewwoooo <3 this aww you nyeed.
Expand Down
158 changes: 79 additions & 79 deletions plover_fancytext/character_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,86 +180,86 @@
}

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': '----. ',
'!': '-.-.-- ',
'?': '..--.. ',
'-': '-....- ',
'.': '.-.-.- ',
'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
Expand Down
2 changes: 1 addition & 1 deletion plover_fancytext/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

TRANSFORMERS = {
'bubble': lambda: Substitute(BUBBLE_MAP),
'morse': lambda: Substitute(MORSE_MAP),
'morse': lambda: Substitute(MORSE_MAP, ' '),
'crytyping': lambda: CryTyping(),
'medieval': lambda: Substitute(MEDIEVAL_MAP),
'fullwidth': lambda: Substitute(FULLWIDTH_MAP),
Expand Down
5 changes: 3 additions & 2 deletions plover_fancytext/substitute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

class Substitute(FormatterBase):

def __init__(self, character_map):
def __init__(self, character_map, joiner=''):
self._joiner = joiner
self._character_map = character_map

def swap(self, c: str) -> str:
Expand All @@ -14,4 +15,4 @@ def swap(self, c: str) -> str:
def format(self, str: str) -> str:
if str is None:
return None
return ''.join(self.swap(c) for c in str)
return self._joiner.join(self.swap(c) for c in str)
8 changes: 8 additions & 0 deletions plover_fancytext/testExtensionPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ def test_plugged_zalgo(self):

self.assertTrue(new[0].text.endswith(new[1].prev_replace))

def test_plugged_morse(self):
p = self._set_up_plugin()
p.fancy_set(FakeContext(), "morse")
new = self._get_action_return("test")
p.translated([], new)

self.assertEqual(new[0].text, "- . ... -")

def _set_up_plugin(self) -> ExtensionPlugin:
e = FakeEngine()
p = ExtensionPlugin(e)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = plover_fancytext
version = 1.5.0
version = 1.6.0
description = Silly output formatting plugin for Plover
long_description = file: README.rst
author = Seth Rider
Expand Down

0 comments on commit 4725e46

Please sign in to comment.