-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathmodifiers.py
More file actions
50 lines (39 loc) · 1.75 KB
/
modifiers.py
File metadata and controls
50 lines (39 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from talon import Module
mod = Module()
mod.list(
"cursorless_simple_modifier",
desc="Simple cursorless modifiers that only need to specify their type",
)
@mod.capture(rule="{user.cursorless_simple_modifier}")
def cursorless_simple_modifier(m) -> dict[str, str]:
"""Simple cursorless modifiers that only need to specify their type"""
return {
"type": m.cursorless_simple_modifier,
}
# These are the modifiers that will be "swallowed" by the head/tail modifier.
# For example, saying "head funk" will result in a "head" modifier that will
# select past the start of the function.
# Note that we don't include "inside" here, because that requires slightly
# special treatment to ensure that "head inside round" swallows "inside round"
# rather than just "inside".
head_tail_swallowed_modifiers = [
"<user.cursorless_simple_modifier>", # bounds, just, leading, trailing
"<user.cursorless_simple_scope_modifier>", # funk, state, class, every funk
"<user.cursorless_ordinal_scope>", # first past second word
"<user.cursorless_relative_scope>", # next funk, 3 funks
]
modifiers = [
"<user.cursorless_interior_modifier>", # inside
"<user.cursorless_head_tail_modifier>", # head, tail
"<user.cursorless_position_modifier>", # start of, end of
"<user.cursorless_reference_modifier>", # reference formats
*head_tail_swallowed_modifiers,
]
@mod.capture(rule="|".join(modifiers))
def cursorless_modifier(m) -> str:
"""Cursorless modifier"""
return m[0]
@mod.capture(rule="|".join(head_tail_swallowed_modifiers))
def cursorless_head_tail_swallowed_modifier(m) -> str:
"""Cursorless modifier that is swallowed by the head/tail modifier, excluding interior, which requires special treatment"""
return m[0]