06-29-2012 12:05 PM
Hello all,
I am working on a project that is something of a text editor. I am using a string control, and would like to be able to highlight the syntax of the code we will write into it.
However, using Match Pattern and Match Regular Expression is very slow, taking a few seconds to highlight what I want. Also, the text that changes color will make any text typed after it the same color. I also hate that I must move the text selection around to color things with the property node.
Is there any way to speed up my search for certain things and coloring them?
Also, if anyone can suggest a way I can highlight as a user types, I would be most grateful.
06-30-2012 12:48 AM
Are you using SelEnd and SelStart property nodes to setup the coloring/highlighting?
If we could see your code it would be pretty helpful.
06-30-2012 08:31 AM
Please do not repeat your earlier request for help. In that post you also did not post code, and did not follow up on what the issue was.
07-02-2012 07:31 AM - edited 07-02-2012 07:39 AM
This is not a repeat of my earlier request, as this is a different question.
I don't post code unless I find it necessary. I am asking what I would think are simple questions, and only asking for general tips or advice on how this task is normally accomplished.
My goal is to highlight some features of the DMC we will be writing into this editor. However, as I said, this is slow when run on code we use (which isn't even that long), and due to the nature of needing to move the TextSel around, I can't really have this running in a different loop while a user would be editing as it will move their cursor around and generally cause flashes and look bad. But this seems to be the only way to color a string control.
Is syntax coloring in a string control even possible? Or would I have to use something like RichTextBox?
07-02-2012 07:34 AM
Here is a simple example of some text for that highlighter VI.
07-02-2012 07:50 AM
@j-son wrote:
This is not a repeat of my earlier request, as this is a different question.
My post was not clear. I did not intend to imply you were asking the same question. Rather, I mean to indicate the same manner in asking the question. That of asking the question, showing no code, and then not following up on questions.
I don't post code unless I find it necessary.
Then you will find that people will not be able to help you as much as you'd like. 99% of the time respondents here ask for code. That should tell you something. We work much better when we can see what you've tried and indicate what you'd need to change. Code also helps to clarify what people are asking since often what people say doesn't match up with what they want, or what they think they are saying. My reply was a perfect example. It did not end up saying what I thought it was saying.
Is syntax coloring in a string control even possible? Or would I have to use something like RichTextBox?
It is not directly possible. Or rather, it is not automatic. The only way to change the coloring of text is by selecting text and changing the color. I do not know if using a RichTextBox will be any easier, but that's beyond the scope of LabVIEW, as it has to do with the RichTextBox ActiveX control.
A completely different approach would be to use a picture control, but that would be a very large task, as you'd need to basically program in your own text selection - i.e., you'd need to programmatically select text as the user tries to "select" text.
Another approach is to use an ActiveX control designed for this task. Something like this: http://www.tetradyne.com/srcvwax.htm . Of course that would limit you to a Windows platform.