|
-
Feb 25th, 2011, 01:18 AM
#1
Thread Starter
Junior Member
-
Feb 25th, 2011, 01:45 AM
#2
Re: Auto Indent?!
2 ways. Either manually or using a XMLWriter class which can auto-indent its output.
-
Feb 25th, 2011, 01:56 PM
#3
Thread Starter
Junior Member
Re: Auto Indent?!
No i mean while typing... like visual studio does while typing, i'm not looking to autoindent saves, i'm looking to autoindent while editing, get me?
-
Feb 25th, 2011, 02:07 PM
#4
Re: Auto Indent?!
Oh, that. That's quite a trick. You should analyze the input as the user types in the text and then format it on the fly. That's quite a project all by itself.
It should be syntax dependable (be that XML or something else).
Basically you will need a complete parser which can recognize syntax elements (even incomplete ones) and perform formatting with each keypress. That puts an additional requirement - the routine should be fast. No, it should be FASTER. As far as I know, there are no ready-to-use solutions for this. You should develop it yourself.
For XML you'll need to recognize opening tags, attributes and nesting level. For complete tags you will need regular expressions. Once you recognize an opening tag you increment the nesting level and once the tag is closed you decrement it. Also remember that even Visual Studio doesn't format XML code immediately. You should invoke 'Format Document' menu command to format it.
I suggest you follow the same path. Wait for the user to complete typing and then format the complete XML fragment using XMLWriter. It will be much easier and less time-consuming.
-
Feb 25th, 2011, 02:42 PM
#5
Thread Starter
Junior Member
Re: [RESOLVED] Auto Indent?!
I could just do the XMLwriter method each time the user inputs a character. Put it in a try method incase the user didnt finish a tag, and it'll format wen the user has finished typing an unfinished tag. Any example on how to use the XMLWriter? I'm guessing its in System.XML namespace...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|