Jump to content

Manipulating text with the text selection property


Recommended Posts

Here is an example VI (LV7.0) that shows how to manipulate text in a text box. The focus of this example is the Selection Start + Selection End property. This can be very powerful in performing custom live formatting of front panel text.

The trick here is to perform formatting on the text after you highlite the section of interest. The Font property is then used within the same property node.

text_hi_lite.vi - Image:

post-2-1089818933.gif?width=400

Download File:post-19-1088657566.vi

Link to comment
  • 2 weeks later...

[attachmentid=undefined]Wouldn't you want to do this more efficiently with event structure? .... Don

Here is an example VI (LV7.0) that shows how to manipulate text in a text box. The focus of this example is the Selection Start + Selection End property. This can be very powerful in performing custom live formatting of front panel text.

The trick here is to perform formatting on the text after you highlite the section of interest. The Font property is then used within the same property node.

1084[/snapback]

Download File:post-115-1089650321.vi

Link to comment
Wouldn't you want to do this more efficiently with event structure? .... Don

1131[/snapback]

Yes! Thank You Don for the updated version. My goal was to show how the specific property node would be used. The event structure as you show it would be a much better, and preferred, implementation. Thanks for the improvement. :thumbup:

post-2-1089650995.gif?width=400

Link to comment

Don't know how the event structure improves the following because I don't have access to >6.1 at the moment ...

When I originally was after this sort of thing I was using it to create a ?simple? text editor and the highlighting was for the FIND method. It works nicely (apart from a brief flash as the text is highlighted). Now is it possible to extend this to give me real time <cough> syntax highlighting?

By that I mean as I type 'word' and word is in my list of defined text strings to be green, it gets coloured green. I reckon this could be done with the text select and highlight method outlined before, but it might be pretty ugly (flash, flash, etc), especially when loading and parsing a file for syntax highlighting at startup.

Does anyone have any better ideas?

Link to comment
  • 2 weeks later...
Don't know how the event structure improves the following because I don't have access to >6.1 at the moment ...
LV6.1 has event structures.
Now is it possible to extend this to give me real time <cough> syntax highlighting?
I don't see why not? Have you tried it? What problems are you seeing?
I reckon this could be done with the text select and highlight method outlined before, but it might be pretty ugly (flash, flash, etc).
I didn't see any flashing on my end in the examples posted previously.

I saved the LV7.0 version into 6.1 however I noticed that the behavior changed. The 6.1 version behaves very buggy. It does not remove the hi-lighting... :(

Open the attached VI using LV6.1 to see bug.

Download File:post-2-1090558621.vi

Link to comment

In a recent Info-LabVIEW thread there was a need for HTML display.

I have wired this SimpleFormatter.vi that accepts tagged (markup text) and display it in a string. With a syntax parser that will wrap keywords with property tags, it can be used for syntax highlight.

It still require some work (to handle the character "<") and has merely been tested with the provided example. The font property also needs to be implemented. Correct syntax is assumed.

I defer panel updates when formatting the string but the string indicator is still drawn twice.

Download File:post-447-1091080666.vi

Download File:post-447-1091080685.vi

Link to comment
I saved the LV7.0 version into 6.1 however I noticed that the behavior changed. The 6.1 version behaves very buggy. It does not remove the hi-lighting...

Indeed, the behaviour in LV6.1 is strange, but there is a workaround to revert a formatting of a portion of the text:

1. select the whole text in your control/indicator

2. format it the way your text portion was formatet (e.g. make whole text bold)

3. revert the formatting on the whole text (e.g. bold set to false)

4. reformat the portions that should have kept their format.

post-253-1091172104.jpg?width=400

Didier

Link to comment

It's again me...

I made some tests and got (hope so) the problem on LV6.1 with undoing a text format.

It seems that the SelStart and SelEnd marker have to reside on a text that is formated the way you want to undo. In between have as much different formatings as you want.

E.g. if you want to undo bold on a text portion, the character after SelStart and the one before SelEnd have to be bold. The other way nothing happens.

I've rewritten Michael's example with an event structure. It gives back the new value of the slider (to format the new portion) and the old value (to unformat).

Didier

Download File:post-253-1091175663.vi

Link to comment
  • 1 month later...

:oops:

I downloaded SimpleFormatter.vi and after using it, I found a small bug. All text after the last text formatter is truncated. I also modified the search for tags to be case independent, so now <b> = <B>. This new version is in LabVIEW 7.1.

Thanks for this cool new tool jpdrolet.

In a recent Info-LabVIEW thread there was a need for HTML display.

I have wired this SimpleFormatter.vi that accepts tagged (markup text) and display it in a string. With a syntax parser that will wrap keywords with property tags, it can be used for syntax highlight.

It still require some work (to handle the character "<") and has merely been tested with the provided example. The font property also needs to be implemented. Correct syntax is assumed.

I defer panel updates when formatting the string but the string indicator is still drawn twice.

1250[/snapback]

Download File:post-151-1094751483.vi

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.