Skip to content

Commit

Permalink
Public get text action (#2069)
Browse files Browse the repository at this point in the history
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 <755842+pokey@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 19, 2023
1 parent 655e722 commit 99dcc82
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/actions/get_text.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
from typing import Optional

from talon import actions
from talon import Module, actions

from ..targets.target_types import CursorlessTarget

mod = Module()


@mod.action_class
class Actions:
def cursorless_get_text(
target: CursorlessTarget,
hide_decorations: bool = False,
) -> str:
"""Get target text. If hide_decorations is True, don't show decorations"""
return cursorless_get_text_action(
target,
show_decorations=not hide_decorations,
ensure_single_target=True,
)[0]

def cursorless_get_text_list(
target: CursorlessTarget,
hide_decorations: bool = False,
) -> list[str]:
"""Get texts for multiple targets. If hide_decorations is True, don't show decorations"""
return cursorless_get_text_action(
target,
show_decorations=not hide_decorations,
ensure_single_target=False,
)


def cursorless_get_text_action(
target: CursorlessTarget,
Expand Down

0 comments on commit 99dcc82

Please sign in to comment.