News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Technicolor 2 for script kiddies :)

Started by hutch--, December 06, 2006, 10:36:34 AM

Previous topic - Next topic

hutch--

I have written a new test piece that uses the basics of Iczelion's technique of JIT text colouring rather than the API method that is so slow. This differs from Iczelion's method in that it uses a very fast hash table instead of the linked list he used and it is able to handle large word counts with no loss in speed.

It uses richedit 3 so it will need win2000 or later, I don't know if it will run on richedit 2 that was available in some versions of win9x. Any feedback would be appreciated.

www.movsd.com/demo/technicolor2.zip
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zooba

Wow. That's great.  :8)

All I have to say is, if you do integrate this into QE or a similar editor, make sure the colours are easily customisable - Technicolor, while good for movies is not so good for syntax highlighting.

May I ask, how does Iczelion's technique work? Or can you provide a link to his code?

Cheers,

Zooba :U

hutch--

Here is the version of Iczelions code that I fixed up and used as a prototype for the version posted here.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ramguru

Good work, Hutch. One thing I can notice is that most good edit controls that support syntax highlighting doesn't highlight anything in selection, but maybe it's not up to you, so this observation wouldn't apply.

zooba

Ah. AFAICT it simply writes over the text with the new colour. Any idea how well this will work with other fonts or font smoothing/ClearType? Possibly the original text would need to be cleared before drawing the coloured one.

I agree with ramguru, most editors offer highlighted text as a colour option separate from commands and stuff, especially when the command highlights are the same colour as the selection background :bg

Cheers,

Zooba :U

hutch--

I think from memory that selection is an XOR operation so it will simply invert the existing colour of selected text.

The basic technique from Iczelion's example is that all of the processing is done in a subclass of the edit control in the WM_PAINT message processing. It calls the default process first to handle the normal repaints then it overwrites the words that are to be coloured using the DrawText() API.

The way I have done it is to grab the text displayed in the edit control client area, scan it on a word by word basis with exceptions for comments and quotes, pass each word  past a hash table to get individual word colours them overwrite the displayed text with its coloured version. The content of the keywords.txt file dictates what word types have colours as the internal algorithm works on a series of text colour classes that are controlled by the specified number in the text file.

Comments and quotes are controlled by the first character of the text passed as the scanner I am using has dedicated handling of both comments and quotes. This has allowed me to handle both single and double quotes in the same manner.

Something I would appreciate if anyone has the time is to test this editor on a win9x box that has richedit 2 installed on it as I have no way of testing it here. I would be interested to see if it runs correctly on richedit 2.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jdoe


What I think is funny about this topic is that hutch always wrote pejorative words about syntax highlighting and now he is working on it. Even the topic title is pejorative.

Personnally, I like it and use Notepad2 as my code editor. This program make not too much use of highlighting and colors used are just enough in the default scheme.

Not very constructive post but I couldn't resist.

BTW hutch, what make you work on this. Are you suddenly open to others preference and not taking yours as a reference anymore.





hutch--

 :bg

jdoe,

I dislike syntax hiliting with a vengance and will not use it but many prefer to use it so I am exploring adding it as an option to an editor. For my preference, I read code far faster without the distraction of colour based information as in fact do many of the older programmers and while this technique is fast enough, it still loads a meg of word data plus any leftover overhead from the hash table so its no longer a minimum memory footprint editor that can run it.

The hash table design I am using uses 4 bytes for each empty hash slot so with the table about half full it is storing about 1 meg or so as data and has nominally about 64k of unused 4 byte slots which is another 256k of memory so for no gain in performance or capacity, syntax hiliting adds about 1.25 meg of memory overhead to an existing editor.

The keywords.txt file has just over 50 thousand entries and could use more for things like structure names and anything else apart from a high speed dynamic tree or hash table would be pathetically slow on word counts of this magnitude so you are stuck with this overhead if you want the word range for colouring.

I have added this capacity to a copy of QE and it seems to work fine with the richedit 1 control that QE uses but it destroys what QE was designed to do, run on ancient hardware or low performance laptops and notebooks with a minimum memory footprint.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jdoe

Quote from: hutch-- on December 07, 2006, 02:08:28 AM
I dislike syntax hiliting with a vengance and will not use it but many prefer to use it so I am exploring adding it as an option to an editor. For my preference, I read code far faster without the distraction of colour based information as in fact do many of the older programmers...

I was sure you would mention "old programmers" somewhere in your reply. I understand anyway what you are saying. Coding habits are not a question of what is good or not but what we are used to or not. I think we must use what we feel confortable with and not what others saying is good for us. I hope your are thinking this way.   :thumbu





hutch--

It seems to be a context issue, when I first started the masm32 project, most guys were coding assembler in notepad and here the average age was under 20. My generation grew up with things like the Microsoft PWB and there were syntax hiliting editors even back then in DOS so it nothing new. The first VC IDE dated about 1994 had text colouring from memory and I hated it back then for much the same reason, it gave me eyestrain and it slows down how fast I read code.

I have always encouraged programmers to select or write their own editors / IDEs as no-one can cater for such a wide taste. I supply QE simply because I own it and I am not beholding to anyone for it but it does reflect the way I prefer to code. The reason for investigating syntax colouring is because enough people are interested in using it so if its no big deal, I will add it as an option to an editor for anyone who wants to use it.

I have not suddenly seen the light so I can code as slow as script kiddies in technicolor, it is simply a matter of catering for demand. What I in fact DO need is some useful feedback on the technique to make it more reliable. It seems to be up and working OK at the moment but there will be various aspects of it that need to be tweaked here and there.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zooba

Is a low memory option a possibility? Maybe you can fold the hash values and reduce the overall table size without increasing collisions too badly? I can't say I've noticed any performance issues, but I'm hardly running a low end machine (if I could find a 5-pin keyboard and a serial mouse then I could be :bdg )

Highlighting isn't a simple xor in an edit box, it's based on system colours and is drawn in the default processing (before highlighting) anyway. An example:



Even if text between the selection start and end points is simply ignored and left as the default colours (a suitable solution IMHO), but it's somewhat annoying to not be able to read dark blue text on not-quite-as-dark blue background.

hutch--

I am just having a play with an idea at the moment to handle the selected text so it can be seen when selected. The idea is to get the selection after the text has been coloured and set the selected text to a decent contrast against the hilite colour.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zooba

Works fine in Windows 98 (just got a VM going) :U

Vortex


jhkdiy

When i use this app to open  an asm file, if i scroll text, it will show error messagebox for me , I don't know what happen with it.

my system:Windows2000(sp4 Chinese Version).

This is the screen show:





[attachment deleted by admin]