|
-
Jan 27th, 2012, 10:37 AM
#1
Thread Starter
Member
Code editor(Help)
I'm trying to make an HTML editor for my school project.
I need help color coding the text so if they type <html>, <b>, <body> in any case it'll color code it to turn blue.
-
Jan 27th, 2012, 11:12 AM
#2
Re: Code editor(Help)
How much of this do you need to do yourself?
There's a great library out there for this, with tons of examples, FastColoredTextBox, but if it's a school project it might not be appropriate. Anyway, this is the one I'd recommend.
Otherwise, writing your own TextBox is probably out of the question, so you'd be pretty much stuck with a RichTextBox in that case, which is terrible for highlighting.
-
Feb 9th, 2012, 02:08 PM
#3
Thread Starter
Member
Re: Code editor(Help)
Yeah that won't work for me.
I need to make it so if someone types < it changes the forecolor to blue, and if they finish it with > then it makes the color black again.
-
Feb 9th, 2012, 03:22 PM
#4
Junior Member
Re: Code editor(Help)
they have some gui components for that but you could just show them web browser control and feed it html code and keep refreshing the preview everytime they type code.
-
Feb 9th, 2012, 03:50 PM
#5
Hyperactive Member
Re: Code editor(Help)
You really could use a RichTextBox easily. I did this a few years ago for my AIM client software I created. When your typing your keys check for ">", while using .SelColor() to change the color of the text you want. Everytime the user types a ">" (that isn't enclosed in quotes) should signify there is a matching "<" to go with it. Find both, and select the angle brackets and everything in between and set the color with .SelColor(). If you can't find a matching "<" then the user mistyped and no colors should be changed.
There will be a lot of work to do to make sure everything is handled correctly for whatever the user might type in the RichTextBox, but that's usually the case for any word processing. There are loads of condition that have to be taken into consideration. The biggest being quotes, where you should always be checking for open and closing quotes to not highlight anything within them that may be key words. While also coloring the whole quoted statement if you choose too.
Unfortunately as it has been said before, this process can get slow-based on the RichTextBox's performance.. If you want and know the way, only color whats visible. This could speed things up dramatically.
Last edited by DavesChillaxin; Feb 9th, 2012 at 03:59 PM.
-
Feb 9th, 2012, 05:59 PM
#6
Re: Code editor(Help)
 Originally Posted by Slushi
Yeah that won't work for me.
I need to make it so if someone types < it changes the forecolor to blue, and if they finish it with > then it makes the color black again.
Specifically, though, why won't it work for you? It can easily do what you describe, not just what's shown in the examples.
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
|