Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Emphasis API for Highlighting Text Ranges #62

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tom-ludwig
Copy link
Member

Description

This PR introduces the Emphasis API to highlight specific text ranges within a TextView. This functionality can be used in various scenarios, such as highlighting search results, emphasizing code symbols, or highlighting the code symbol that the mouse is hovering over.
This PR only introduces the Emphasis API and does not include any search functionality or text-range validation (e.g., checking if an already emphasized range has changed).

Note

To test the UI changes, you will likely need to use CESE and add CETE as a local package.
To experiment with the highlighting, add the following snippet to TextView+KeyDown at line 13 and change the ranges accordingly:

        let rangesToHighlight = [
            NSRange(location: 562, length: 7),
            NSRange(location: 651, length: 7),
            NSRange(location: 724, length: 7),
        ]

        if event.keyCode == kVK_F1 {
            emphasizeAPI?.emphasizeRanges(ranges: rangesToHighlight, activeIndex: 0)
            return
        }

        if event.keyCode == kVK_F2 {
            emphasizeAPI?.highlightNext()
            return
        }
        if event.keyCode == kVK_F3 {
            emphasizeAPI?.highlightPrevious()
            return
        }
        if event.keyCode == kVK_F4 {
            emphasizeAPI?.removeEmphasizeLayers()
            return
        }

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Screen.Recording.2024-11-25.at.8.46.32.PM.mov

Multiline:
Screenshot 2024-11-28 at 12 12 54 PM

Screenshot 2024-11-28 at 12 13 10 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Emphasis API for Highlighting Text Ranges
1 participant