Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Unicode characters in history #671

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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