CustomEditField Questions

Apologies - this is a second post as I somehow managed to post an incomplete post on the same topic moments ago by hitting some unknown keyboard combination!

I’ve written a couple of code editors over the years (I even sell one) but I’ve always been impressed by @Thomas_Tempelmann 's CustomEditField. What has put me off using it in the past is that its API 1.0 and its highlighting engine is RegEx based (which I dislike) whereas my engines have always been dedicated parsers and are API 2.0.

Anyway, the app I’m working on needs to highlight Markdown and highlight any code within code fences (```). Currently, my editor (XUICodeEditor) can highlight Markdown but, full disclosure, I have some concerns about its performance with very large Markdown documents so I’m exploring other options.

I have two questions:

  1. There is no current highlighter for Markdown. Fine - I’m happy to try to write one but do you think it is possible to write a Markdown highlighter definition using RegEx? I also thought that you needed a dedicated parser to do so. Our resident RegEx expert @Kem_Tekinay might be able to answer that.

  2. Assuming (1) is possible, am I correct in thinking that CustomEditField would be able to highlight the contents of ``` fences differently if I marked them as different highlight contexts? I guess this question is aimed at anyone who has ever written one of these highlighters.

I know there are other code editors out there (@Christian_Schmitz’s Scintilla plugin is one) but as far as I can see, none of them highlight code within Markdown code fences.

One more question:

Can you word wrap with CustomEditField? By this I mean have text wrap to the next line when the control is resized?

Currently you can’t do this in my editor (as the rendering and text storage is line based). I don’t see anything in CEF’s code that suggests you can. If I had a good solution in mind to implement word wrapping I would add it to XUICodeEditor.

We do have markdown and I may make an example project like this one:

Left a Scintilla Control and right the HTMLViewer with preview using our markdown class.
We do have a lever for markdown :slight_smile:

Linking back to a previous comment of yours @Christian_Schmitz, do you think one could highlight the contents of a code fence using the StyleNeeded event in Scintilla? For example, would it be possible to highlight Xojo code in a code fence?

Sorry, I have no idea whether you can combine a lexer and manual styling.