Building the Right Environment to Support AI, Machine Learning and Deep Learning
HTML syntax highlighting can be done easier than other languages because it follows a set pattern. You have tags, attributes, comments, and text. That's about it...So to make highlighting faster, I created a routine that works just for HTML. It's faster because it follows the set pattern for HTML instead of just finding keywords and highlighting those.
Don't try using TagBold, TagItalics, etc. b/c in some configurations it will cause it to freeze and I don't know why yet. I will work on that. But it does work fine w/ any color configuration. You can use common dialogs to allow the user to select a color and it will work fine w/ those. It automattically interprets the colors and applies them to the RTF.
If you use the supplied owner created RichText box, you need to download the SSubTimer.DLL - great subclassing control/activex dll from vbAccelerator. The supplied project uses the standard RichTextBox control that comes with VB - if you want to change the DLL to use the supplied RTF control, you'll need to change the code slightly - see below.
It's rather simple, actually...I have it set up w/ an RTB made through code, but you can easily switch it to a normal RTB by changing the "Public RichTxtBox As HSRichEdit" to "Public RichTxtBox As RichTextBox". After that, to highlight, just use two lines of code:
set syntaxHighlight1.RichTxtBox = RichTextBox1 syntaxHighlight1.Highlight
To get it to color properly while typing, use the following code:
Private Sub RichTextBox1_KeyPress(KeyAscii As Integer) KeyAscii = syntaxHighlight1.KeyPressEvent(KeyAscii) End Sub
That's all it takes to set it up! Good luck! (c;