Posted 17 years ago by Dan Oren - Software Developer, Watchfire
Version: 4.0.0234
Avatar
Hey,

Our application uses the syntax editor to show HTTP trafic.
We want to show the trafic content like you can see in sniffers products.
(Ethereal is a good example...)
We go over the text and set 2 outlines for the Request section and the Response section.
We also parse the HTML that we get from the server using the "ActiproSoftware.HTML.xml" file that was supplied with the TestApplication of the syntax editor.
We are having very good results and we succeeded to customize your control for our needs using the supplied XML file and with small customization to support our needs.

We also need to highlight part of the text that we don't know in the design time what will it be.
Only after we already have the HTTP trafic we run some algorithem that tells us what text should be highlighted.

In order to highlight the relevant text we are using a semantic parsing with the postParse method by
running over the tokens and set their CustomHighlight.

The results of this method are very good.

But - when saving the document to RTF or HTML file we cant see the changes that were made in the PostParse.
We assume that the default behaviour of the SyntaxEditor is to run only the Lexical Parsing.
How can we cause the SyntxEditor to save also the changes of the PostParse ?

Dan

Dan Oren

Comments (7)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Dan,

I'm not sure exactly which method you are doing this with... are you setting the CustomHighlightingStyle property of a DynamicToken or are you using span indicators? If you are using the CustomHighlightingStyle property, it should show up in the export. Span indicators probably will not right now.


Actipro Software Support

Posted 17 years ago by Dan Oren - Software Developer, Watchfire
Avatar
Yes, I am using custom highlight style.
The changes dont saved.

Dan

Dan Oren

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Can you email or post exact steps/code need to duplicate this in our sample project? I had tried it in the sample and it worked for me.


Actipro Software Support

Posted 17 years ago by Dan Oren - Software Developer, Watchfire
Avatar
Hey again,

I check it one more time and yes... we are using span indicators to mark the wanted text :
private void HighlightSection(ArrayList arrayList, HighlightSectionTypes highlightSectionType, Color foreColor, Color backColor)
        {
            TextSegment hTTPSegment = null;
            for (int i = 0; i < arrayList.Count; i++)
            {
                SpanIndicator spanIndicator = new BreakpointIndicator(highlightSectionType.ToString() + i.ToString(),
                                                                                     0,
                                                                                     foreColor,
                                                                                     backColor);
                if (highlightSectionType == HighlightSectionTypes.HighlightValidation)
                {
                    highlightValidationSpanIndicatorsArrayList.Add(spanIndicator);
                }
                else if (highlightSectionType == HighlightSectionTypes.RequestModification)
                {
                    requestModificationSpanIndicatorsArrayList.Add(spanIndicator);
                }

                hTTPSegment = (TextSegment)arrayList[i];
                if (syntaxEditorControl.Text.Length >= hTTPSegment.Length)
                {
                    syntaxEditorControl.Document.Indicators.Add(spanIndicator, hTTPSegment.Start, hTTPSegment.Length);
                }
            }
        }
What can we do in order to save these changes when saving to file or printing ?

Dan

Dan Oren

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The reason that they aren't included when exporting to HTML or RTF is that they are generally considered to not be part of the code. For instance, set a breakpoint in Visual Studio code, select the document and paste it in Word and you'll see the code only with no breakpoint highlight. SyntaxEditor operates the same way.

If you are using a dynamic language then the tokens it generates will inherit DynamicToken. That type has a CustomHighlightingStyle property you can set. If you change your post parse code to set that property for your appropriate tokens, it will override what the lexical parser assigned. And the custom highlighting style will export and print as you are hoping it to. Is that a possibility for you?


Actipro Software Support

Posted 17 years ago by Dan Oren - Software Developer, Watchfire
Avatar
Hey,

So I am trying to set the CustomHighlightingStyle of the token in the PostParse method but I cant set to bold specific characters in the text since the text is devided to tokens that are not always in a length of 1,
so I actually color all the token string instead of one charcter in it...
for (int i = 0; i < requestDeletionArrayList.Count; i++)
                {
                    TextSegment textSegment = (TextSegment)requestDeletionArrayList[i];
                    for(int k = 0 ; k < textSegment.Length ; k++ )
                    {
                        Token token = document.Tokens.GetTokenAtOffset(textSegment.Start + textSegment.Length);
                        token.CustomHighlightingStyle = new HighlightingStyle(  i.ToString() + k.ToString(), 
                                                                                i.ToString() + k.ToString(),
                                                                                token.HighlightingStyle.ForeColor,
                                                                                Color.Red, 
                                                                                true,
                                                                                token.HighlightingStyle.Italic,
                                                                                token.HighlightingStyle.Underline); ;
                    }
                }
Is there away to color only specific characters in my text ?
Actually I want that the highlight style of a token that its lenght > 1 will stay except that I only want to change it to bold.

How can I implement this ?
When I used the span indicators I could change the style of a specific character...
Should I split the token into small tokens in a lenght of 1 and then copy the highlight style to all of them except from the specific character that I need to change ?
I know that this is very ugly but I have no other idea...

Thanks

[Modified at 11/20/2006 05:30 PM]

Dan Oren

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ahhh... this presents a dilemma. On one hand, CustomHighlightingStyle is currently the only way
to be able to export modified styles to RTF. However you are saying that the tokens that are
created don't match in length the text you want to highlight. The workaround for that is to
make smaller tokens that do match the things you would highlight. However that will of course
make the parser a little slower and will use more memory since more tokens are created.

The other original request you made by having span indicator highlights be exported with the
text is probably the best solution for you. But unfortunately that isn't currently
implemented since as I explained above, most people don't need that sort of functionality.

If you would like us to custom develop this feature for you, we can do it at an hourly rate.
E-mail us if you are interested in that sort of thing. Otherwise, making smaller tokens is
probably what you will have to do.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.