de icon indicating copy to clipboard operation
de copied to clipboard

shell syntax highlighting

Open josephholsten opened this issue 8 years ago • 3 comments

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

josephholsten avatar Jul 01 '16 00:07 josephholsten

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.

josephholsten avatar Jul 01 '16 21:07 josephholsten

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.

driusan avatar Jul 01 '16 23:07 driusan

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.

josephholsten avatar Jul 02 '16 03:07 josephholsten