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

Implement search / find API #553

Closed
AlmirKadric opened this issue Feb 19, 2017 · 2 comments
Closed

Implement search / find API #553

AlmirKadric opened this issue Feb 19, 2017 · 2 comments

Comments

@AlmirKadric
Copy link

I would like to request a buffer search API. This would highlight all instances inside the buffer which match the search with the current search position highlighted uniquely.

Alternatively if you would like to make this more generic and only provide the means by which one could implement search, I would like the ability to highlight parts of the buffer via the API as well as the ability to flatten the buffer ignoring any special colouring and character tags etc (right now when i use innerHTML, colouring breaks words and sentences searching, innerText for some reason is return character code 160 instead of 32 for spaces).

@parisk
Copy link
Contributor

parisk commented Feb 19, 2017

I get your use case. I think though that this would fit better in an add-on rather than in the core.

The way I see this happening is through an abstraction in the rendering logic, that would allow you to pass additional HTML classes for particular tokens (e.g. search-term).

P.S.: Have in mind though that interacting with the terminal's innerHTML or text directly is not part of it's public API so there is no guarantee that this will work.

@Tyriar
Copy link
Member

Tyriar commented Feb 19, 2017

@parisk what you're describing is pretty similar to how link matchers work, we could potentially make that logic more generic (work with non a elements and classes) and more robust (ability to split text style spans). Then have the link matchers hook into this new 'buffer manipulation" API.

This is very performance critical stuff so you need to be weary of when this manipulation occurs. 200ms is great for links but probably would be took slow for jumping around search terms.

I like this model because it keeps lines pristine by performing the change at the end, that way we don't run into issues like the old linkify add on which broke everything when you changed the buffer.

As for finding the text to highlight it would need some way of traversing lines. Which would trigger the manipulation.

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

No branches or pull requests

3 participants