Skip to content

Commit

Permalink
Allow Unicode characters in history (#671)
Browse files Browse the repository at this point in the history
* Fix sending unicode words to history window

* Fix encoding problems in history
  • Loading branch information
comodoro authored and LexiconCode committed Aug 12, 2019
1 parent 54a92d5 commit 3129c6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion castervoice/asynch/hmc/hmc_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, params):
for sentence in sentences:
sentence_words = sentence.split("[w]")
sentence_words.pop()
display_sentence = " ".join(sentence_words)
display_sentence = " ".join(sentence_words).decode("unicode_escape")

cb_row = 0 # self.get_row()
cb_col = 0
Expand Down
11 changes: 4 additions & 7 deletions castervoice/lib/ccr/recording/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def record_from_history(self):
for w in t:
formatted += w.split("\\")[0] + "[w]"
formatted += "[s]"

formatted = formatted.encode("unicode_escape")
# use a response window to get a spec and word sequences for the new macro
h_launch.launch(settings.QTYPE_RECORDING, data=formatted)
on_complete = AsynchronousAction.hmc_complete(
Expand Down Expand Up @@ -74,14 +74,11 @@ def refresh(self, *args):
settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"])
mapping = {}
for spec in recorded_macros:
# Create a copy of the string without Unicode characters.
ascii_str = str(spec)
sequences = recorded_macros[spec]
delay = settings.SETTINGS["miscellaneous"]["history_playback_delay_secs"]
# It appears that the associative string (ascii_str) must be ascii, but the sequences within Playback must be Unicode.
mapping[ascii_str] = R(
Playback([(sequence, delay) for sequence in sequences]),
rdescript="Recorded Macro: " + ascii_str)*Repeat(extra="n")
play = Playback([(sequence, delay) for sequence in sequences])
command = play * Repeat(extra="n") if spec.endswith("[times <n>]") else play
mapping[spec] = R(command, rdescript="Recorded Macro: " + spec)
mapping["record from history"] = R(Function(self.record_from_history),
rdescript="Record From History")
mapping["delete recorded macros"] = R(Function(self.delete_recorded_macros),
Expand Down

0 comments on commit 3129c6e

Please sign in to comment.