auto-create OutliningNode end?

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Karl Grambow
Version: 4.0.0237
Avatar
Hi, I'm looking for a bit of advice after spending hours looking at this and getting no where. I'll offer a bit of background so bear with the explanation.

I'm trying to auto-create the ending for an outlining node whenever the user presses Enter after having typed out the beginning of an outlining node.

For example, if an outlining node consists of BEGIN....END then after typing BEGIN, followed by enter, I want to auto-type the END keyword so as to close the node.

If kind of got this working by handling the SmartIndent event. Essentially, what I do is (starting from the end of the document), I iterate backwards looking for EndToken. If I find one, I check to see if it has a matching BeginToken, in which case I move on. If I find no EndToken then I know that I should create one automatically.

The problem comes when working with nested outlining nodes.

For example:


begin

begin

end


What happens here is that when pressing enter at the inner BeginToken, the EndToken that previously was paired up with the outer BeginToken is now paired up with the inner one. And as a result the EndToken is never created.

Has anyone implemented this type of functionality successfully, if so could please provide me with some pointers?

Thanks,

Karl

Comments (4)

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

What about looking at the existing outlining nodes. For instance if you see that the "end" is already assigned as the end to another node, and that's the first "end" you hit then assume there isn't a matching "end" and insert it yourself.


Actipro Software Support

Posted 18 years ago by Karl Grambow
Avatar
Thanks for the reply.

I'm not sure your suggestion would work - unless I misunderstood it.

In the example I posted, after writing out the inner "begin" it suddenly becomes the start of a new outlining node. So the first "end" I hit would be assigned to the end of this new node, rather than another node. Does that make sense?

Karl
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The other thing you could do is go up the outlining node tree to see if there is a "begin" outlining node that doesn't have an end and if that is the case you would probably know that there is a mismatch and you should insert an "end" yourself.


Actipro Software Support

Posted 18 years ago by Karl Grambow
Avatar
Thanks,

That would probably work. I think there might be some instances were it wouldn't work perfectly but for the most part it should work.

Karl

[Modified at 01/15/2007 11:56 AM]
The latest build of this product (v24.1.1) was released 28 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.