Skip to content

Implement color printing #363

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

Closed
wants to merge 3 commits into from
Closed

Conversation

t4ccer
Copy link

@t4ccer t4ccer commented Nov 13, 2020

Implement --color flag handling, and color printing in hoogle search.

This PR addresses #133

@ndmitchell
Copy link
Owner

Thanks for the diff!

Having syntax highlighting seems reasonable. But I'm not convinced that going as far as reparsing the output makes sense - that's a lot of complexity. The HTML output already marks keywords with bold tags, so taking the bold tags and applying them to the console output seems perfectly reasonable. Whether highlighting type variables differently from other variables has benefit is something I'm less sure of. The HTML rendering of Hoogle doesn't do that, and having just experimented with it, when I turned it on it made things less clear - since the useful information in a search isn't specific details of variables etc, but instead the list of names.

Rainbow is also only restricted to Unix terminals, so something like ansi-terminal would be better. But that's a detail that's easy to change once we've got the concept right.

@t4ccer
Copy link
Author

t4ccer commented Nov 14, 2020

I noticed that HTML output marks keywords in tags, but everything coming after :: in function signature comes in one tag, so it is impossible to differentiate symbols like -> from types. Therefore reparsing output seems to me as only way to separate them.

@ndmitchell
Copy link
Owner

What's the desire to separate things like -> from types? Why does this desire exist on the console, but not the web version? Maybe it does exist on both, in which case a unified approach would make more sense?

@t4ccer
Copy link
Author

t4ccer commented Nov 15, 2020

I believe that it exists on both. Many code editors separate -> and types so I find it useful to have this separation also in hoogle

@ndmitchell
Copy link
Owner

That doesn't seem unreasonable. Although, I wonder if it already exists in the HTML version too? At one point there were <1> tags in the output, to denote arguments. But they might have been stripped out since.

Either way, it seems the right way to implement this would be by tagging the type targets in the HTML, and then having the HTML rendered to the console with formatting. Does that sound about right?

@t4ccer
Copy link
Author

t4ccer commented Nov 15, 2020

Comments say that arguments should be in <s1> tags, but they are not. It would be reasonable to at first implement argument tagging in html, and then color console output using these tags, instead of reparsing whole output.

@ndmitchell
Copy link
Owner

I think the idea was to put in the <s1> tags so we could colour code each argument differently when matching to show how arguments got rearranged. I don't think that aspect has been implemented yet, but its somewhere on the todo list, so adding those tags and using them to print out in the console sounds good.

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.

2 participants