Request for 'invisible text'

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Marianne
Avatar
Had an idea to provide a notes area inside a Syntax Editor instance similarly to the way Word or Excel provides notes. After creating a note a small glyph would show up in the editor next to the token or line. Hovering over that token would cause a popup with the note text. I would like to save this note data with the actual file itself but I don't want this text to actually display inside the Syntax Editor.

So my first question is, is there currently a way to hide text from view? If not, then my second question is could something be done to accommodate this?

This is something that could/would be used quite a bit I imagine since any sort of metadata could be embedded with the file itself but not dirty up the actual display. The uses for something like this are many.

------------------------------- Marianne

Comments (3)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Not directly but you might be able to use a combination of collapsed outlining nodes, read-only regions, and indicators to support something like that.


Actipro Software Support

Posted 18 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
I have a similar approach I have to use. There's a file format I must support that adds a bunch of data at the end of each line of code to provide additional information about that line. I don't, however, want that code to appear in the editor.

As a result, my process of loading/saving documents is a two-step process. To load the document, I load the full source file into a temporary document. I then parse that document and remove all the extra data at the end of the lines and store that information in a collection that notes the original line where the data was stored. Once all data has been parsed and removed from the temporary document, I get the Text property of the temporary document (since data has been removed) and use it to set the Text property of the document that will officially hold the document. I then go through my collection of line data and add zero-width non-expanding SpanIndicators to the document at the beginning of each line where the data was originally stored. Using SpanIndicators allows the data to "move" with the document as edits are made and also ensures the line data is deleted if the entire line is deleted from the document. Saving the document is a similar process where I copy the text to a temporary document and then re-add the extra line data in that document. I then save the temporary document to a file.

The main reason I used a temporary document for this process is so that the UndoRedo stack wouldn't contain the edits I used to add/remove the extra line data. This also helped ensure that document modification tracking didn't show those lines as being edited.

For your purposes, you could use a similar approach. You could use special delimiter characters to mark the beginning and end of your hidden data. Load the file into a temporary document and parse for those delimiters. Remove the text of the hidden data from the document and mark the offset where the data came from. Once all data has been removed and offsets recorded, copy the text to a new document and create zero-width non-expanding SpanIndicators at every offset where data was removed. You'll need to create a custom SpanIndicator class to do this, and your class can store the details about the hidden text. When saving, copy your text to a temporary document and then re-insert the hidden text based on the current offsets of the SpanIndicators.
Posted 18 years ago by Marianne
Avatar
Thanks. Parsing the data ahead of time was something I had thought about doing. The details provided will really make this something that should be pretty straightforward. Thanks much for all the info!

------------------------------- Marianne

The latest build of this product (v24.1.1) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.