Skip to content

Commit

Permalink
Added strict here selection type (#114)
Browse files Browse the repository at this point in the history
* Added strict here selection type

* Support raw selections

* Run black

Co-authored-by: Pokey Rule <pokey.rule@gmail.com>
  • Loading branch information
AndreasArvidsson and pokey authored Dec 16, 2021
1 parent 9f8abfa commit 18ec811
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/actions/call.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from ..primitive_target import STRICT_HERE
from ..primitive_target import IMPLICIT_TARGET
from talon import Module, actions

mod = Module()


def run_call_action(target: dict):
targets = [target, STRICT_HERE]
targets = [target, IMPLICIT_TARGET]
actions.user.cursorless_multiple_target_command("callAsFunction", targets)
4 changes: 2 additions & 2 deletions src/actions/move_bring.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from talon import Module
from ..primitive_target import STRICT_HERE
from ..primitive_target import IMPLICIT_TARGET

mod = Module()
mod.list(
Expand All @@ -20,6 +20,6 @@ def cursorless_move_bring_targets(m) -> list[dict]:
target_list = m.cursorless_target_list

if len(target_list) == 1:
target_list = target_list + [STRICT_HERE]
target_list = target_list + [IMPLICIT_TARGET]

return target_list
14 changes: 0 additions & 14 deletions src/modifiers/identity.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/modifiers/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"inside": "interiorOnly",
"bound": "excludeInterior",
}
identity = {"just": "identity"}
to_raw_selection = {"just": "toRawSelection"}


def on_ready():
Expand All @@ -20,7 +20,7 @@ def on_ready():
"delimiter_inclusion": delimiter_inclusions,
"range_type": range_types,
"head_tail": head_tail,
"identity": identity,
"to_raw_selection": to_raw_selection,
},
)

Expand Down
14 changes: 14 additions & 0 deletions src/modifiers/to_raw_selection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from talon import Module

mod = Module()


mod.list(
"cursorless_to_raw_selection",
desc="Cursorless modifier that converts its input to a raw selection.",
)


@mod.capture(rule="{user.cursorless_to_raw_selection}")
def cursorless_to_raw_selection(m) -> dict:
return {"modifier": {"type": "toRawSelection"}}
11 changes: 2 additions & 9 deletions src/primitive_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
mod = Module()

BASE_TARGET = {"type": "primitive"}
STRICT_HERE = {
"type": "primitive",
"mark": {"type": "cursor"},
"selectionType": "token",
"position": "contents",
"modifier": {"type": "identity"},
"insideOutsideType": "inside",
}
IMPLICIT_TARGET = {"type": "primitive", "isImplicit": True}


modifiers = [
Expand All @@ -21,7 +14,7 @@
"<user.cursorless_containing_scope>", # funk, state, class
"<user.cursorless_subtoken_scope>", # first past second word
"<user.cursorless_surrounding_pair>", # matching/pair [curly, round]
"<user.cursorless_identity>", # just
"<user.cursorless_to_raw_selection>", # just
# "<user.cursorless_matching_paired_delimiter>", # matching
]

Expand Down

0 comments on commit 18ec811

Please sign in to comment.