dotfiles

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

edit.py (658B)


      1 import time
      2 from talon import Context, Module, actions, clip, ui
      3 
      4 ctx = Context()
      5 mod = Module()
      6 
      7 
      8 @ctx.action_class("edit")
      9 class edit_actions:
     10     def selected_text() -> str:
     11         with clip.capture() as s:
     12             actions.edit.copy()
     13         try:
     14             return s.get()
     15         except clip.NoChange:
     16             return ""
     17 
     18 
     19 @mod.action_class
     20 class Actions:
     21     def paste(text: str):
     22         """Pastes text and preserves clipboard"""
     23 
     24         with clip.revert():
     25             clip.set_text(text)
     26             actions.edit.paste()
     27             # sleep here so that clip.revert doesn't revert the clipboard too soon
     28             actions.sleep("150ms")