Skip to content

Commit aba5651

Browse files
added space wrap and moved wrappers to its own file (cursorless-dev#14)
1 parent b31c4e9 commit aba5651

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

src/actions.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,6 @@
5555
# "paste": "paste",
5656
}
5757

58-
wrappers = {
59-
"square": ["[", "]"],
60-
"round": ["(", ")"],
61-
"curly": ["{", "}"],
62-
"angle": ["<", ">"],
63-
"twin": ["'", "'"],
64-
"quad": ['"', '"'],
65-
"brick": ["`", "`"],
66-
"escaped twin": ["\\'", "\\'"],
67-
"escaped quad": ['\\"', '\\"']
68-
}
69-
70-
mod.list("cursorless_wrapper", desc="Supported wrappers for cursorless wrap action")
71-
ctx.lists["self.cursorless_wrapper"] = wrappers.keys()
72-
73-
@mod.capture(rule=("{user.cursorless_wrapper}"))
74-
def cursorless_wrapper(m) -> list[str]:
75-
return wrappers[m.cursorless_wrapper]
76-
7758

7859
@mod.capture(rule=("swap [<user.cursorless_target>] with <user.cursorless_target>"))
7960
def cursorless_swap(m) -> str:

src/wrappers.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from talon import Module, Context
2+
3+
mod = Module()
4+
ctx = Context()
5+
6+
wrappers = {
7+
"square": ["[", "]"],
8+
"round": ["(", ")"],
9+
"curly": ["{", "}"],
10+
"angle": ["<", ">"],
11+
"twin": ["'", "'"],
12+
"quad": ['"', '"'],
13+
"brick": ["`", "`"],
14+
"escaped twin": ["\\'", "\\'"],
15+
"escaped quad": ['\\"', '\\"'],
16+
"space": [" ", " "]
17+
}
18+
19+
mod.list("cursorless_wrapper", desc="Supported wrappers for cursorless wrap action")
20+
ctx.lists["self.cursorless_wrapper"] = wrappers.keys()
21+
22+
@mod.capture(rule=("{user.cursorless_wrapper}"))
23+
def cursorless_wrapper(m) -> list[str]:
24+
return wrappers[m.cursorless_wrapper]

0 commit comments

Comments
 (0)