我们可以在CEdit控件中使用XSL/XML语法高亮吗?

huangapple go评论81阅读模式
英文:

Can we use XSL / XML syntax highlighting with CEdit control?

问题

我有一个标准的多行 CEdit 控件:

它显示XSL脚本。是否可以使用标准的语法高亮颜色方案来显示它?

英文:

MFC Visual C++ Dialog

I have a standard multiline CEdit control:

我们可以在CEdit控件中使用XSL/XML语法高亮吗?

It displays XSL script. It is possible to display this using one of the standard syntax highlighter colour schemes?

答案1

得分: 1

Nope,标准编辑控件没有设置部分显示文本的颜色(甚至字体)的功能或消息。因此,解决方案可以是自绘控件(您需要自己实现一切)或者可能是富文本编辑控件(然后您需要将XML文本转换为富文本)。参考此帖子

此外,语法高亮是内容(语言)特定的,而“标准”颜色方案是哪些?这不是一个简单的任务。您需要大量的处理,即语法分析和将其映射到方案颜色。我不知道是否有任何Win32工具可执行此操作。也许您可以检查类似Notepad++的工具的源代码是否在某个存储库中可用,然后查看是否值得(适用于您的应用程序)。可能您需要加载用于语法分析任务的插件。

英文:

Nope, standard edit controls have no functions or messages to set the color (or even the font) for a part of the displayed text. So the solution could be either an owner-drawn control (you will need to implement everything yourself) or maybe a rich-edit control (then you will have to convert the xml text to rich text). Take a look at this post.

Also, syntax highlighting is content- (language-) specific, plus which are those "standard" color schemes? And this is not a trivial task anyway. You need a lot of processing, ie syntax analysis and mapping to the colors of the scheme. I'm not aware of any Win32 facilities that perform this. Maybe you can check if the sources of a tool like Notepad++ are available in some repository and take a look, if this is worth (for your application). Probably you will have to load plugins for the syntax analysis task.

huangapple
  • 本文由 发表于 2023年5月29日 21:29:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76357806.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定