~chambln/steno

5814208515590ec8c50792bb42d3a97550d2ac0a — Gregory Chamberlain 2 months ago 6d5333f master
Represent keyboard chords as sets instead of lists

This prevents duplicate elements and reflects the fact that order is
not significant.
1 files changed, 5 insertions(+), 5 deletions(-)

M steno
M steno => steno +5 -5
@@ 88,16 88,16 @@ def read_chords(lines):
                keysym = words[6].strip("(),")
                yield event, keysym

    released, pressed = [], []
    released, pressed = set(), set()
    for event, keysym in read_xev(lines):
        if event == "KeyPress":
            pressed += [keysym]
            pressed.add(keysym)
        else:
            pressed = [k for k in pressed if k != keysym]
            released += [keysym]
            pressed.discard(keysym)
            released.add(keysym)
        if released and not pressed:
            yield released
            released = []
            released.clear()

def transcribe(chord):
    return [