I am writing a FMX application and I need a simple editor component that can show line numbers in a gutter and the ability to change the font color of individual bits of text. At the moment I use TMemo which is very limited. TMS have such a component but it’s based on an underlying JavaScript component which would make life difficult I think during deployment to the Mac and Windows. Synedit would work but it’s just for VCL. I can’t find anything else for FMX that can do this.
My question is could TRichViewEdit be used for the role described above? Obviously I would not use most of the functionality that the control would offer but I don’t care about that. I just want something that can show line numbers in a gutter and the ability to change font colors for individual bits of text.
Use TRichViewEdit as a simple code editor?
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Use TRichViewEdit as a simple code editor?
Text color can be changed, just like any other text attribute.
Line numbers is not a built-in feature but can be implemented using custom drawing events.
I'll provide an example later today.
Line numbers is not a built-in feature but can be implemented using custom drawing events.
I'll provide an example later today.
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Use TRichViewEdit as a simple code editor?
Sorry for the delay, an example will be tomorrow.
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Use TRichViewEdit as a simple code editor?
This code shows how to draw line numbers in FireMonkey version of TRichView:
viewtopic.php?p=45845#p45845
But if you want to implement not only simple text coloring, but syntax highlighting, it is much more complicated task. In TRichViewEdit, you can change colors only by changing font attributes of the specified text fragment.
There is an implementation of syntax highlighting (TSyntaxRichViewEdit can be found here: https://www.trichview.com/resources/), but it is a very basic example.
viewtopic.php?p=45845#p45845
But if you want to implement not only simple text coloring, but syntax highlighting, it is much more complicated task. In TRichViewEdit, you can change colors only by changing font attributes of the specified text fragment.
There is an implementation of syntax highlighting (TSyntaxRichViewEdit can be found here: https://www.trichview.com/resources/), but it is a very basic example.
Re: Use TRichViewEdit as a simple code editor?
Thanks for getting back. Are the line number painted in a gutter or in the text area of the control? Although even if painted in the text area i assume they aren’t considered part of the text in the control?
Re: Use TRichViewEdit as a simple code editor?
I think I could handle text highlighting, my syntax is relatively simple. I think I’ll try the trial version to see how it goes. If it works out I’ll purchase a copy.
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Use TRichViewEdit as a simple code editor?
This example draws line numbers on the left margin. Just make sure that value of LeftMargin property is large enough.
It's only a drawing, so these numbers are not considered as a part of a document.
It's only a drawing, so these numbers are not considered as a part of a document.