Skip to content

Commit b64ab09

Browse files
AndreasArvidssonpre-commit-ci-lite[bot]pokey
authored andcommitted
Public get text action (#2069)
Fixes #452 ## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [x] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [x] I have not broken the cheatsheet --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Pokey Rule <[email protected]>
1 parent c1a6c6c commit b64ab09

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/actions/get_text.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
from typing import Optional
22

3-
from talon import actions
3+
from talon import Module, actions
44

55
from ..targets.target_types import CursorlessTarget
66

7+
mod = Module()
8+
9+
10+
@mod.action_class
11+
class Actions:
12+
def cursorless_get_text(
13+
target: CursorlessTarget,
14+
hide_decorations: bool = False,
15+
) -> str:
16+
"""Get target text. If hide_decorations is True, don't show decorations"""
17+
return cursorless_get_text_action(
18+
target,
19+
show_decorations=not hide_decorations,
20+
ensure_single_target=True,
21+
)[0]
22+
23+
def cursorless_get_text_list(
24+
target: CursorlessTarget,
25+
hide_decorations: bool = False,
26+
) -> list[str]:
27+
"""Get texts for multiple targets. If hide_decorations is True, don't show decorations"""
28+
return cursorless_get_text_action(
29+
target,
30+
show_decorations=not hide_decorations,
31+
ensure_single_target=False,
32+
)
33+
734

835
def cursorless_get_text_action(
936
target: CursorlessTarget,

0 commit comments

Comments
 (0)