codeTag... that's right, another one

Volte
02-04-2002, 04:03 PM
:rolleyes: :rolleyes: :rolleyes:

Anyone who's been here for a few months, I'm sure that's your reaction.

This time, it's very fast. It can take from about 10-20ms (for small code) to about 3-4 seconds (for very large code). Now, I haven't totally tested this completely, so any bugs -- report to me.

Now, there's some stuff I gotta explain here. The keywords that need to be colored are now stored internally inside a RES file. That's good for most people. However, if you feel the need to customize it, then create a file containing your keywords called 'keyword.dat' in the exe's path. Each word goes on one line, seperated by linebreaks. Keep in mind that this will cause the program to ignore the internal keywords. If you want a copy of the keyword file as it is, it is attached.

Download Here (http://www.kwic.com/~junior/codetag-new.zip)

[EDIT - ACKKKK!!!!! Now I'm getting reports of out of memory errors... Try it, see if it works. If it doesn't, I'll have to return to the drawing board... :(]

Bucky
02-04-2002, 04:07 PM
Ooh! Ooh! I found a bug! I found a bug!

LOL the link doesn't work. Or is the file not up there yet and I'm being too impatient?

Spike
02-04-2002, 04:10 PM
Originally posted by bucky
Ooh! Ooh! I found a bug! I found a bug!

LOL the link doesn't work. Or is the file not up there yet and I'm being too impatient?

I was able to get it just fine...*shrug*

Volte
02-04-2002, 04:12 PM
I had made a typo in the link -- it should work fine now though. Sorry about that.

As I said above, this may crash on you, not sure. I am using WinXP with 128MB of memory... I wonder if there's a memory leak somewhere.

[EDIT - Ah, stupid me. I was using a normal textbox instead of RichTextBox. On Win2000 and below, there's a limit of 32K, but not in Win2K and XP.]

[EDIT 2 - It's fixed now, download it above]

Sorry about that :)

Bucky
02-04-2002, 04:13 PM
I got it now... Apparently the file wan't uploaded yet when I tried it.

Spike
02-04-2002, 04:17 PM
Seems to work great...tried a large chunk of code, and it did it fine.
*edit: i am on win XP with 128 MB of ram

STATISTICS
----------
No. of Lines: 1488
No. of Comments: 273
No. of Strings: 470
Time to Process Strings: 3024 ms.
Time to Process Comments: 1352 ms.
Time to Process Keywords: 3856 ms.
Time to Complete: 13339 ms.

Squirm
02-04-2002, 04:23 PM
Largest chunk of code I have :

STATISTICS
----------
No. of Lines: 2382
No. of Comments: 171
No. of Strings: 120
Time to Process Strings: 560 ms.
Time to Process Comments: 695 ms.
Time to Process Keywords: 1126 ms.
Time to Complete: 4711 ms.

:)
750Mhz 512Mb

Garrett Sever
02-04-2002, 09:02 PM
I'm sorry - I have to do this.

You guys realize that the posting limit is 10000 characters, which is alot less than 1000 lines (especially color-coded).

And even if it weren't I'd have to hunt you down and beat you if you ever posted anything that large. ZIP FILE. ZIP FILE.

Yes, it has some merit in the "my code is faster than your code" category, but come on - his replace function is from vbSpeed. Of course its fast :p

[/egosquashing]

JDT
02-04-2002, 11:29 PM
Hi VF

I changed my preview to RTF just the other day. It is almost exactly like yours. Anyways, I had a bug in mine which you also have.

Try adding tags and previewing this:

If \

The slash will screw up the RTF.

I fixed it like this:

SomeString = Replace$(SomeString, "\", "\\")

I know you're using Replace9 instead of VB'S Replace$() but you get the idea.

RTF uses double slashes to represent a single slash so you need to swap them out before you add any Rich text formatting.


JDT

Robby
02-05-2002, 12:08 AM
Very cool...


STATISTICS
----------
No. of Lines: 2580
No. of Comments: 351
No. of Strings: 860
Time to Process Strings: 3716 ms.
Time to Process Comments: 1202 ms.
Time to Process Keywords: 2032 ms.
Time to Complete: 14862 ms.

900Mhz 512 Megs

Garrett Sever
02-05-2002, 05:58 AM
Hey Volte- here's a block of code that doesn't seem to work.

It misses all of the "Private"s and all of the "Public Events"

Private mCurPic As Integer
Private mBackground As StdPicture
Private mPicture As StdPicture
Private mHighlightPic As StdPicture
Private mHPicsDC(0 To 3) As Long
Private mHPics(0 To 3) As Long
Private mCaption As String
Private mHighlightColor As OLE_COLOR
Private mHighlightStyle As chcHighlightStyle
Private mDepressStyle As chcDepressStyle
Private mBackgroundStyle As chcBackgroundStyle
Private mImageAlignment As chcImageAlignment
Private mBorderStyle As chcBorderStyle
Private mIsHighlighted As Boolean
Private mHeight As Integer
Private mWidth As Integer
Private mRegeneratePics As Boolean
Private mRotateDeg As Integer
Private mPicOffset As Integer
Private mAlignment As chcAlignConstant
Private mHLOffset As Integer
Private mAlignmentOffset As Integer
Private mDitherLevel As Byte
Private mRetainInMemory As Boolean
Private mGenerateAll As Boolean
Private mUpraisedStyle As chcUpraisedStyle
Private mDepressBG As Boolean

[code]
' ***************************************************
' Declare events
' ***************************************************
Public Event Click()
Public Event MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single, Override As Boolean)
Public Event MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single, Override As Boolean)
Public Event MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Public Event MouseLeft()
Public Event Changed()
Public Event KeyDown(KeyCode As Integer, Shift As Integer)
Public Event KeyUp(KeyCode As Integer, Shift As Integer)
Public Event KeyPress(KeyAscii As Integer)


JDT - Yours worked perfectly.

Volte
02-05-2002, 03:41 PM
Hey, leave my ego alone! :) I've known from the start that coloring more than 150+ lines is pretty pointless, but you can also use it for other stuff. It can color into HTML tags as well (well, not at the moment, but it easily could be added). Basically, I set my mind to something, I tried and tried, and I accomplished it. It feels good.

Enough of my ranting. The link at the top has been updated to a version that works. It turns out it's because I wasn't Trim$()ing the words that come from the resource file, meaning some words had extra spaces, meaning the parser didn't recognize them.

Also, I have turned my code into a class. I will be releasing the source. It will be fully usable as is (I think), so you could drop it in your project and use it for coloring anything.

Volte
02-17-2002, 11:05 AM
It's over.... it's finally over.

codeTag v3.1 Source Code

Here it is. Included are:

The two forms (main and preview), the form's binary files (icons), the resource file containing the keywords and one class. The class is layed out as follows:

Properties
TagOpenKeyWord, TagCloseKeyWord, TagOpenComment, TagCloseComment, TagOpenString, TagCloseString
These are the tags used for coloring.

TagOpenPreserve, TagClosePreserve
The [code] tags on the forum. Can be <PRE> for HTML etc.

NewLineChar
Character used to represent a vbCrLf -- in most cases this is a vbCrLf.

KeyWordList
The list of keywords, one long string delimited by KeyWordDelimeter

KeyWordDelimeter
The character used to separate the list of keywords in KeyWordList

CommentCount, KeyWordCount, StringCount
Used for statistical purposes. Counts the number of comments, keywords and string it processed. Option Explicit is treated as one keyword, for example.

KeyWordTime, CommentTime, StringTime, TotalTime
Used for benchmarking. Returns the amount of time (in ms) taken to process keywords, comments and strings. TotalTime returns the length of the entire process.

Error
Returns True if there was an error in the colorizing

Methods
Colorize
ColorizedText = Class.Colorize(inText, [doBenchmarking = True])

Returns a string containing the colorized text.

- inText [string]
The source, uncolorized text to be tagged.

- doBenchmarking [boolean]
Defaults to True. Sets whether the benchmarking properties of the class are set.




Attached is the source.

Robby
02-17-2002, 11:12 AM
Just did a quick test...

Number of Keywords: 465
Number of Comments: 18
Number of Strings: 74
Time to Process Keywords: 360ms
Time to Process Comments: 10ms
Time to Process Strings: 20ms
Total Time to Process: 450ms

COOOOOL
:rolleyes:

John
02-17-2002, 11:38 AM
Pretty cool. I will be using this for sure, of course I will be making my own little changes to the interface for my own use ;)

Thanks


This is exactly what I was looking for in my other post

John
02-17-2002, 11:52 AM
Here is the results on my largest code file of 54.2KB

Number of Keywords: 523
Number of Comments: 155
Number of Strings: 58
Time to Process Keywords: 360ms

This is on an Atlhon 750 with 256mb or RAM

Works great for me.

Nice Work

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum