I’m building a custom console/log viewer using CodeEdit because I want to use features such as the gutter.
Each log entry can contain style tags that affect only parts of the text. For example:
[error]Failed[/error] to load save file.
where anything inside [error][/error] should be rendered in red.
I’m not talking about syntax highlighting. The styling comes from the log message itself, and a single line may contain multiple differently styled segments.
I don’t want to use RichTextLabel because I need gutter support and other editor-like features provided by TextEdit/CodeEdit.
My questions are:
Can TextEdit or CodeEdit apply styles to arbitrary text ranges?
Is there a way to customize rendering for specific words or character ranges?
Can the syntax-highlighting system be repurposed for this use case?
If not, would a custom control be the recommended solution?
There’s probably a way to do it using regex, but I’ve not really used the syntax highlighter, however I can tell you how to customize specific keywords.
Simply extend the CodeEdit and create a new code highlighter:
The reason why I am using textEdit instead of richTextLabel it’s because I am using custom gutter to show tags like time or level and with this, I can even collapse them
And one big decision is it handle auto wrap out, flip box, meaning if a line is too long, due to the gutters, it will look as indentation
And right now, I am trying to implement line folding as well