Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [lsp4e-dev] Implementing inactive code highlighting

On Mon, Jul 9, 2018 at 6:56 AM, Nathan Ridge <zeratul976@xxxxxxxxxxx> wrote:
Hi all,

Hi, 

We would like to implement inactive code highlighting (greying out of lines in inactive preprocessor branches) in lsp4e-cpp. The CQuery language server has support for this, but we are trying to figure out how to implement the greying out in the Generic Editor.

That's an interesting feature. 
Do you think this feature would make sense in the protocol directly? Is there already a ticket open against the LSP spec for this?

The way CDT's C++ editor, which also supports this feature, implements it is by installing a LineBackgroundListener on the editor's StyledText widget. Would it be appropriate for us to do the same thing in the Generic Editor? I ask in part because I'm not sure if manipulating the Generic Editor's StyledText widget is a supported / intended way of interacting with the Generic Editor.

To be honest, I don't know, and the only answer I can give is "try, see and tell".
Unless the LineBackgroundListener changes drastically how the underlying StyledText work, I don't think there would be too much trouble. The Generic Editor is a text editor like any other, and just has the functional value coming from extensions rather than hardcoding. Compared to existing editors like CDT one, It doesn't (or shouldn't) change too much how the editor interacts with the underlying StyledText so the same patterns could apply successfully.

Or should we use the presentation reconciler for this purpose? Or something else? Any suggestions would be appreciated.

Using a (presentation?) reconciler sounds actually cleaner. The cool thing is that there is already an extension point for it in Generic Editor so it's easy, and the presentation reconciler has some good magic built-in; and I think it does work for this use-case as IIRC EclEmma successfully uses a presentation reconciler to highlight code coverage as background color.
Or maybe they're dealing with annotations and a regular reconciler, that could be a good approach for your use-case too.

HTH

Back to the top