dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

macro.py (801B)


      1 from talon import actions, Module, speech_system
      2 
      3 mod = Module()
      4 
      5 macro = []
      6 recording = False
      7 
      8 
      9 @mod.action_class
     10 class Actions:
     11     def macro_record():
     12         """record a new macro"""
     13         global macro
     14         global recording
     15 
     16         macro = []
     17         recording = True
     18 
     19     def macro_stop():
     20         """stop recording"""
     21         global recording
     22         recording = False
     23 
     24     def macro_play():
     25         """player recorded macro"""
     26         actions.user.macro_stop()
     27 
     28         # :-1 because we don't want to replay `macro play`
     29         for words in macro[:-1]:
     30             print(words)
     31             actions.mimic(words)
     32 
     33 
     34 def fn(d):
     35     if not recording:
     36         return
     37 
     38     if "parsed" not in d:
     39         return
     40 
     41     macro.append(d["parsed"]._unmapped)
     42 
     43 
     44 speech_system.register("pre:phrase", fn)