Skip to content

Commit f8fdc9b

Browse files
committed
git subrepo pull --remote=file:///Users/pokey/src/cursorless-talon-development --branch=limited-after cursorless-talon
subrepo: subdir: "cursorless-talon" merged: "21c27bb2" upstream: origin: "file:///Users/pokey/src/cursorless-talon-development" branch: "limited-after" commit: "21c27bb2" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596"
1 parent 68cd980 commit f8fdc9b

File tree

11 files changed

+85
-25
lines changed

11 files changed

+85
-25
lines changed

cursorless-talon/src/actions/actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .actions_callback import callback_action_defaults, callback_action_map
55
from .actions_custom import custom_action_defaults
66
from .actions_makeshift import makeshift_action_defaults, makeshift_action_map
7-
from .actions_simple import simple_action_defaults
7+
from .actions_simple import positional_action_defaults, simple_action_defaults
88

99
mod = Module()
1010

@@ -83,6 +83,7 @@ def vscode_command_no_wait(command_id: str, target: dict, command_options: dict
8383

8484
default_values = {
8585
"simple_action": simple_action_defaults,
86+
"positional_action": positional_action_defaults,
8687
"callback_action": callback_action_defaults,
8788
"makeshift_action": makeshift_action_defaults,
8889
"custom_action": custom_action_defaults,

cursorless-talon/src/actions/actions_simple.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"give": "deselect",
2525
"highlight": "highlight",
2626
"indent": "indentLine",
27-
"paste to": "pasteFromClipboard",
2827
"post": "setSelectionAfter",
2928
"pour": "editNewLineAfter",
3029
"pre": "setSelectionBefore",
@@ -43,8 +42,18 @@
4342
"generateSnippet",
4443
]
4544

45+
# NOTE: Please do not change these dicts. Use the CSVs for customization.
46+
# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md
47+
positional_action_defaults = {
48+
"paste": "pasteFromClipboard",
49+
}
50+
4651
mod = Module()
4752
mod.list(
4853
"cursorless_simple_action",
4954
desc="Supported simple actions for cursorless navigation",
5055
)
56+
mod.list(
57+
"cursorless_positional_action",
58+
desc="Supported actions for cursorless that expect a positional target",
59+
)

cursorless-talon/src/actions/call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77

88
def run_call_action(target: dict):
9-
targets = [target, IMPLICIT_TARGET]
9+
targets = [target, IMPLICIT_TARGET.copy()]
1010
actions.user.cursorless_multiple_target_command("callAsFunction", targets)

cursorless-talon/src/actions/move_bring.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@
44

55
mod = Module()
66
mod.list(
7-
"cursorless_source_destination_connective",
7+
"cursorless_positional_connective",
88
desc="The connective used to separate source and destination targets",
99
)
1010

1111

1212
mod.list("cursorless_move_bring_action", desc="Cursorless move or bring actions")
1313

1414

15-
@mod.capture(
16-
rule=(
17-
"<user.cursorless_target> [{user.cursorless_source_destination_connective} <user.cursorless_target>]"
18-
)
19-
)
15+
@mod.capture(rule=("<user.cursorless_target> [<user.cursorless_positional_target>]"))
2016
def cursorless_move_bring_targets(m) -> list[dict]:
21-
target_list = m.cursorless_target_list
17+
target_list = [m.cursorless_target]
2218

23-
if len(target_list) == 1:
24-
target_list = target_list + [IMPLICIT_TARGET]
19+
try:
20+
target_list += [m.cursorless_positional_target]
21+
except AttributeError:
22+
target_list += [IMPLICIT_TARGET.copy()]
2523

2624
return target_list

cursorless-talon/src/cheatsheet/sections/actions.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def get_actions():
2727
}
2828

2929
swap_connective = list(get_raw_list("swap_connective").keys())[0]
30-
source_destination_connective = list(
31-
get_raw_list("source_destination_connective").keys()
32-
)[0]
30+
positional_connectives = {
31+
value: key for key, value in get_raw_list("positional_connective").items()
32+
}
3333

3434
make_dict_readable(
3535
simple_actions,
@@ -39,10 +39,14 @@ def get_actions():
3939
)
4040
return {
4141
**simple_actions,
42-
f"{complex_actions['replaceWithTarget']} <T1> {source_destination_connective} <T2>": "Replace T2 with T1",
43-
f"{complex_actions['replaceWithTarget']} <T>": "Replace S with T",
44-
f"{complex_actions['moveToTarget']} <T1> {source_destination_connective} <T2>": "Move T1 to T2",
45-
f"{complex_actions['moveToTarget']} <T>": "Move T to S",
42+
f"{complex_actions['replaceWithTarget']} T1 {positional_connectives['contentConnective']} T2": "Replace T2 with T1",
43+
f"{complex_actions['replaceWithTarget']} T1 {positional_connectives['afterConnective']} T2": "Copy T2 after T1",
44+
f"{complex_actions['replaceWithTarget']} T1 {positional_connectives['beforeConnective']} T2": "Copy T2 before T1",
45+
f"{complex_actions['replaceWithTarget']} T": "Replace S with T",
46+
f"{complex_actions['moveToTarget']} T1 {positional_connectives['contentConnective']} T2": "Move T1 to T2",
47+
f"{complex_actions['moveToTarget']} T1 {positional_connectives['afterConnective']} T2": "Move T1 after T2",
48+
f"{complex_actions['moveToTarget']} T1 {positional_connectives['beforeConnective']} T2": "Move T1 before T2",
49+
f"{complex_actions['moveToTarget']} T": "Move T to S",
4650
f"{complex_actions['swapTargets']} <T1> {swap_connective} <T2>": "Swap T1 with T2",
4751
f"{complex_actions['swapTargets']} {swap_connective} <T>": "Swap S with T",
4852
f"{complex_actions['applyFormatter']} <F> at <T>": "Reformat T as F",

cursorless-talon/src/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def cursorless_this_command(
5656
):
5757
"""Execute cursorless command, passing `this` as single target"""
5858
actions.user.cursorless_multiple_target_command(
59-
action, [IMPLICIT_TARGET], arg1, arg2, arg3
59+
action, [IMPLICIT_TARGET.copy()], arg1, arg2, arg3
6060
)
6161

6262
def cursorless_single_target_command_with_arg_list(

cursorless-talon/src/connective.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
"until": "rangeExcludingEnd",
1212
}
1313

14+
# NOTE: Please do not change these dicts. Use the CSVs for customization.
15+
# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md
16+
positional_connectives = {
17+
"after": "afterConnective",
18+
"before": "beforeConnective",
19+
"to": "contentConnective",
20+
}
21+
1422
default_range_connective = "rangeInclusive"
1523

1624

@@ -21,7 +29,7 @@ def on_ready():
2129
"range_connective": range_connectives,
2230
"list_connective": {"and": "listConnective"},
2331
"swap_connective": {"with": "swapConnective"},
24-
"source_destination_connective": {"to": "sourceDestinationConnective"},
32+
"positional_connective": positional_connectives,
2533
},
2634
)
2735

cursorless-talon/src/cursorless-snippets.talon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ tag: user.cursorless_experimental_snippets
55
{user.cursorless_insert_snippet_action} <user.cursorless_insertion_snippet>:
66
user.cursorless_this_command(cursorless_insert_snippet_action, cursorless_insertion_snippet)
77

8-
{user.cursorless_insert_snippet_action} <user.cursorless_insertion_snippet> <user.cursorless_target>:
9-
user.cursorless_single_target_command(cursorless_insert_snippet_action, cursorless_target, cursorless_insertion_snippet)
8+
{user.cursorless_insert_snippet_action} <user.cursorless_insertion_snippet> <user.cursorless_positional_target>:
9+
user.cursorless_single_target_command(cursorless_insert_snippet_action, cursorless_positional_target, cursorless_insertion_snippet)
1010

1111
{user.cursorless_insert_snippet_action} {user.cursorless_insertion_snippet_single_phrase} <user.text> [halt]:
1212
user.cursorless_insert_snippet_with_phrase(cursorless_insert_snippet_action, cursorless_insertion_snippet_single_phrase, text)

cursorless-talon/src/cursorless.talon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ app: vscode
44
<user.cursorless_action_or_vscode_command> <user.cursorless_target>:
55
user.cursorless_action_or_vscode_command(cursorless_action_or_vscode_command, cursorless_target)
66

7+
{user.cursorless_positional_action} <user.cursorless_positional_target>:
8+
user.cursorless_single_target_command(cursorless_positional_action, cursorless_positional_target)
9+
710
{user.cursorless_swap_action} <user.cursorless_swap_targets>:
811
user.cursorless_multiple_target_command(cursorless_swap_action, cursorless_swap_targets)
912

cursorless-talon/src/modifiers/position.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66

77
positions = {
8-
"after": {"position": "after"},
9-
"before": {"position": "before"},
108
"start of": {"position": "before", "insideOutsideType": "inside"},
119
"end of": {"position": "after", "insideOutsideType": "inside"},
1210
# Disabled for now because "below" can misrecognize with "blue" and we may move away from allowing positional modifiers in arbitrary places anyway
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from talon import Module
2+
3+
mod = Module()
4+
5+
6+
@mod.capture(rule=("{user.cursorless_positional_connective} <user.cursorless_target>"))
7+
def cursorless_positional_target(m) -> list[dict]:
8+
return process_positional_connective(
9+
m.cursorless_positional_connective, m.cursorless_target
10+
)
11+
12+
13+
def process_positional_connective(cursorless_positional_connective: str, target: dict):
14+
if cursorless_positional_connective == "afterConnective":
15+
return update_first_primitive_target(target, {"position": "after"})
16+
elif cursorless_positional_connective == "beforeConnective":
17+
return update_first_primitive_target(target, {"position": "before"})
18+
19+
return target
20+
21+
22+
def update_first_primitive_target(target: dict, fields: dict):
23+
if target["type"] == "primitive":
24+
return {**target, **fields}
25+
elif target["type"] == "range":
26+
return {
27+
**target,
28+
"start": update_first_primitive_target(target["start"], fields),
29+
}
30+
else:
31+
elements = target["elements"]
32+
33+
return {
34+
**target,
35+
"elements": [
36+
update_first_primitive_target(elements[0], fields),
37+
*elements[1:],
38+
],
39+
}

0 commit comments

Comments
 (0)