Outlining-related questions/requests

CodeHighlighter for ASP.NET Forum

Posted 18 years ago by Calum Chisholm - Ingen Process Ltd.
Avatar
Hi,
I'm currently working on a web-based tool which displays simple snippets of vb.net code to a user. It is my intention to replace blocks of code with a human-readable equivalent using collapsed regions.

For example, for the code
return value_lookup(0,10) + value_lookup(1,15)
I would add labelled regions
Calculation result = #Region " [Apples (current month)] " value_lookup(0,10) #End Region + #Region " [Oranges (previous month)] " value_lookup(1,15) #End Region
And the end-user would see
Calculation result = [Apples (current month)] + [Oranges (previous month)]
I have already used this approach with some sucess in a windows-based app using the SyntaxEditor control.

The problem is that CodeHighlighter doesn't appear to support single-line regions (or multiple regions on a single line). I'm not particularly familiar with the language-definition stuff - is there a change I could make to my parser class to support this functionality?

It would also be handy if the outline checkbox column could be independantly enabled/disabled. I realise I can do this using javascript or CSS, but doing it server-side would be nicer.

Regards,
Calum Chisholm

Comments (4)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Calum,

It should expand/collapse a single region on a line ok. However with multiple nodes on a line, it currently only expands/collapses the first one. If the box is clicked, should it just operate on all the nodes on the line?


Actipro Software Support

Posted 18 years ago by Calum Chisholm - Ingen Process Ltd.
Avatar
Thanks for your response.

The SyntaxEditor behaviour is to expand/collapse all regions on the line when the checkbox is toggled. I think this is probably the right approach.

I haven't managed to get single-line regions working yet - is the demo page up to date? If I paste the following line into it -
#Region " Test " my_function() #End Region
It collapses to
Test " my_function() #End Region
I have performed some testing locally against version 3.0.14.0, and have noticed similar problems with mismatched quotes.
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I believe that is actually correct per the VB.NET language definition. Regions are defined as each preprocessor element being on a separate line. If you had a single line statement like that and pasted it in code, VS would complain about it because it's a compile error. Our language definition works similarly and in this case thinks the #End Region is part of your #Region description.


Actipro Software Support

Posted 18 years ago by Calum Chisholm - Ingen Process Ltd.
Avatar
Yep, it does look like vb.net doesn't like single-line regions. This doesn't cause me any compilation problems, as I only add them at display-time. I only use them for the UI functionality they provide (in SyntaxEditor, at least).

Is there an alternative method I could use to collapse multiple sections of code on a single line?

My (somewhat messy) alternative is to split the code into sections, render each separately, render my human-readable sections outwith SyntaxEditor, and then finally glue it all together. This would be simplified if I could instruct CodeHighlighter to render a block of code as plain text. Is this possible?
The latest build of this product (v4.0.59) was released 13 years ago, which was after the last post in this thread.