FordLawnmower commented on a Page, CodeMirror : mIRC mode  -  Feb 23, 2013

I was looking at some mIRC scripts and they seemed to have colors but with no real rhyme or reason so I decided to make this.
The scripts I tested on it were much easier to follow with this codemirror.

Hawkee  -  Feb 24, 2013

Perfect, this was a shortcoming of CodeMirror. Thank you for putting this together!

Hawkee  -  Feb 25, 2013

I've implemented it but there seems to be an issue. Most snippets aren't highlighted. Maybe it's a problem with the way it interprets the start and end of scope.

FordLawnmower  -  Feb 25, 2013

@Hawkee I just updated this to the code I'm using now. It should be mostly the same with a few minor changes.
I'm not sure why it doesn't highlight the same as it did in testing, but maybe try the new code.
Is there a way I could test this and get the same result you do here?

Hawkee  -  Feb 25, 2013

It still doesn't seem to be working. You can view the source of this page to see how I'm calling Codemirror. It's a pretty basic call from a textarea. Do you have a working example online?

FordLawnmower  -  Feb 26, 2013

Here is a link to a basic example: http://lawnmower.asuscomm.com/codemirror/mode/mIRC/

FordLawnmower  -  Feb 26, 2013

I think I found the issue. It looks like a case sensitive issue @Hawkee
If I change

CodeMirror.defineMode("mIRC", function() {

to

CodeMirror.defineMode("mirc", function() {

It breaks and doesn't work at all.

So what I've found is that this:

CodeMirror.defineMIME("text/mIRC", "mIRC");

must match this:

CodeMirror.defineMode("mIRC", function() {

The case in the defineMode must be exactly the same as the defineMIME

I also found that the defineMIME should be at the top of the script.
I will update this code now to all lowercase and move the defineMIME to the top

Hawkee  -  Feb 26, 2013

That did it! Thank you. Looks great!

FordLawnmower  -  Feb 26, 2013

Is that the version of the script from the top here, because I still see an unmatched quote issue that I'm not getting on my tests.
You can see it here: http://www.hawkee.com/snippet/9837/

Note I also found that "text/mIRC" has to match the mode: on the html. I changed it above to "text/mirc" to make it uniform.

Edit I'm pretty sure the site is running an older version, because I see several other glitches that I already fixed.

Hawkee  -  Feb 26, 2013

I updated to the latest version. How is that?

FordLawnmower  -  Feb 26, 2013

It looks good, but I found another issue. I added support for mult-line comments, as mIRC does support / /
and lots of people use this type of comment. The problem was, there wasn't a check for / inside a function or if statement.
ie. if (/
iswm %bla)
You can see what it does here: http://www.hawkee.com/snippet/9858/
It basically just comments out the rest of the script and it looks pretty stupid.
Anyway @Hawkee , I updated the script and this issue should be fixed.

Hawkee  -  Feb 26, 2013

Good fix.

FordLawnmower  -  Feb 26, 2013

Cool . It looks good.

FordLawnmower  -  Feb 26, 2013

Updated Found a typo preventing "writeini" from being highlighted. I had "writeint"
You can see it here: http://www.hawkee.com/snippet/8545/

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.