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

shell syntax highlighting #24

Open
josephholsten opened this issue Jul 1, 2016 · 3 comments
Open

shell syntax highlighting #24

josephholsten opened this issue Jul 1, 2016 · 3 comments

Comments

@josephholsten
Copy link
Contributor

it's safe to say that (bourne) shell is a popular language. it would be neato to have syntax highlighting.

@josephholsten
Copy link
Contributor Author

hopefully I will be able to collect enough caffeine this weekend to attempt it. anyone got suggestions of an external syntax highlighting plugin that would be useful to study? the only kind I've played with in the past was textmate, and that was a very unique approach.

@driusan
Copy link
Owner

driusan commented Jul 1, 2016

I'm not sure what you mean by "external syntax highlighting plugin". If you mean de plugins which are external to this repo that do syntax highlighting, I don't know of any, you might be the first. If you mean external tools which do syntax highlighting, I'm not sure that studying them would be incredibly useful, since I don't think many of them use same approach of just having the viewport be an image that gets drawn to using a TTF font (especially since a lot of them are for the console..)

The easiest place to start is probably the de renderers/nosyntax/ renderer. The ones that add syntax highlighting basically take that as a starting point, but for each character as it's ranging through the runes tries to keep track of where it is in the language's context based on what it knows about what it's rendered so far (and maybe doing a comparison on a slice of the runes at the current index to look ahead to see if it's the start of a keyword), then changes the writer.Src to a new colour when the context changes (ie. if it's inside a string and it sees a string terminator, it changes the colour back to the default after drawing the closing quote.)

I've been meaning to extract the code that's in common so that more is shared between the renderers and they only need to figure out the colourization, but I haven't had a chance yet.

@josephholsten
Copy link
Contributor Author

Ah, I just meant I want sure if it was worth reading through the sh syntax plugin used in another editor, like atom, emacs, vim, &c.

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

No branches or pull requests

2 participants