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

Work on Codemirror 6 highlighting #102

Merged

Conversation

mindofmatthew
Copy link
Contributor

Here's an implementation of highlight marking that queries the pattern every frame. There are certainly some performance optimizations that could be done (plus some nuances of exactly how it should behave when the user starts/stops the pattern), but I think this is a good conceptual starting-point and an implementation that seems to perform pretty well.

Let me know if you've got any thoughts!

Copy link
Collaborator

@felixroos felixroos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@@ -118,6 +119,29 @@ function App() {
return () => window.removeEventListener('keydown', handleKeyPress);
}, [pattern, code, activateCode, cycle]);

useEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! we could also move this to a custom hook like useHighlights({pattern,view,started}) or similar, then we could reuse it in the mini repl

// console.log('filter', f,t,value, e.value.from, e.value.to);
},
});
if (e.is(setHighlights)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that looks much simpler than what I fabricated :D didn't know you could just set the Decorations directly

e.value
.flatMap((event) => event.context.locations || [])
.map(({ start, end }) => {
let from = tr.newDoc.line(start.line).from + start.column;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should make offsetToPosition/ positionToOffset obsolete :)

@felixroos
Copy link
Collaborator

related #28

@felixroos felixroos merged commit f00e28c into tidalcycles:codemirror-6 Apr 28, 2022
@felixroos felixroos mentioned this pull request May 10, 2022
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.

None yet

2 participants