Inspired from:
http://www.alh.net/newlisp/phpbb/viewtopic.php?t=941
I gave it a try and get it working with a few changes to ctext:

(//%3C/s%3E%3CURL%20url=%22http://www.hpwsoft.de//anmeldung//html1//newLISP//ctext.png%22%3E%3CLINK_TEXT%20text=%22http://www.hpwsoft.de//anmeldung//html1%20...%20/ctext.png%22%3Ehttp://www.hpwsoft.de//anmeldung//html1//newLISP//ctext.png%3C/LINK_TEXT%3E%3C/URL%3E%3Ce%3E)
The line numbering is a little side effect! ;-)
Now is there a list what commands are grouped together in what color?
Nice! I see my GTK version gets competition :-)
For the syntax highlighting I used more or less the VIM scheme. So texts between double quotes are highlighted, keywords, and parenthesis. VIM also highlights numbers.
Peter
ctext has the following highlight commands:
Quote
ctext::addHighlightClass $txt commands blue [list set setq list ]
#ctext::addHighlightClass $txt flags color [list ???]
#ctext::addHighlightClassWithOnlyCharStart $txt vars color "$"
#ctext::addHighlightClassForSpecialChars $txt brackets green {[]{}}
#ctext::addHighlightClassForRegexp $txt paths lightblue {.[a-zA-Z0-9_-]+}
So I start with the first one.
Another idea is to put the keywords in groups with their own color.
That could happen external in newlisp-tk.config so:
set Ide(newLISPCommands) [list set setq list .....]
set Ide(newLISPControl) [list if while for .....]
Hm, grouping commands will maybe lead you into problems? There are commands which can be used for strings, but also for lists...? So which criteria you have to use?
How does the TK version highlight the syntax anyway? It seems a function within TCL/TK itself? In the GTK version I have to perform the low-level coloring myself.
Peter
Quote
How does the TK version highlight the syntax anyway? It seems a function within TCL/TK itself?
TCL/TK has grown over years and has a lot of extensions.
ctext is a megawidget and part of TKlib.
http://tcllib.sourceforge.net/doc/ctext.html
A bit more work:
;Helperlisp for getting keywords
(device (open "keywords.txt" "w"))
(dolist (s (symbols)) (if (primitive? (eval s)) (println s)))
(close (device))
(device (open "keywords.tcl" "w"))
(setq commandstring "set Ide(newLISPCommands) [list ")
(dolist (s (symbols)) (if (primitive? (eval s)) (setq commandstring (string commandstring s " "))))
(setq commandstring (string commandstring "]"))
(println commandstring)
(close (device))
You get:
set Ide(newLISPCommands) [list ! != $ % & * + - / < << <= = > >= >> NaN? ^ abs ..... ]
Put in newlsip-tk.config:
Quote
set Ide(newLISPCommands) [list ! != $ % & * + - / < << <= = > >= >> NaN? ^ abs ..... ]
set Ide(CommandColor) blue
set Ide(StringColor) orange
set Ide(CommentColor) turquoise4
Using now in newlisp-tk.tcl:
ctext::addHighlightClass $txt commands $Ide(CommandColor) $Ide(newLISPCommands)
ctext::addHighlightClassForSpecialChars $txt paranthesis red {()}
ctext::addHighlightClassForSpecialChars $txt brackets darkred {[]}
ctext::addHighlightClassForRegexp $txt dstrings $Ide(StringColor) {".*"}
ctext::addHighlightClassForRegexp $txt cstrings $Ide(StringColor) {{.*}}
ctext::addHighlightClassForRegexp $txt tstrings $Ide(StringColor) {[text].*[/text]}
ctext::addHighlightClassForRegexp $txt comments $Ide(CommentColor) {;.*}

(//%3C/s%3E%3CURL%20url=%22http://www.hpwsoft.de//anmeldung//html1//newLISP//ctext1.png%22%3E%3CLINK_TEXT%20text=%22http://www.hpwsoft.de//anmeldung//html1%20...%20ctext1.png%22%3Ehttp://www.hpwsoft.de//anmeldung//html1//newLISP//ctext1.png%3C/LINK_TEXT%3E%3C/URL%3E%3Ce%3E)
Other ideas for regexpressions for highlighting?
Modified sources (TK V1.34?) here:
http://www.hpwsoft.de//anmeldung//html1//newLISP//newlispTKhighl.zip
Added ctext to the editor:

(//%3C/s%3E%3CURL%20url=%22http://www.hpwsoft.de//anmeldung//html1//newLISP//ctext2.png%22%3E%3CLINK_TEXT%20text=%22http://www.hpwsoft.de//anmeldung//html1%20...%20ctext2.png%22%3Ehttp://www.hpwsoft.de//anmeldung//html1//newLISP//ctext2.png%3C/LINK_TEXT%3E%3C/URL%3E%3Ce%3E)
Don't know why line 1 is not highlighting correctly on a fresh view.
When I edit it then it does it.
I updated:
http://www.hpwsoft.de//anmeldung//html1//newLISP//newlispTKhighl.zip
I added to the newlisp-tk.config:
Quote
set Ide(ConsoleLineMap) 1
set Ide(EditLineMap) 0
Enable/Disable the linemap in console and editor.
(As a workaround I add a n to the editor-content-begin. Then highlighting does work on the whole content)
There still is a problem with the initial focus, which does not work as before.
I updated:
http://www.hpwsoft.de//anmeldung//html1//newLISP//newlispTKhighl.zip
Very nice! This could go into one of the next versions. Is ctext part of the normal Tcl/Tk 8.4 library? I mean do I get it with the Freewrap distribution? Or would it be an add-on like BWidget?
Lutz
Quote
Is ctext part of the normal Tcl/Tk 8.4 library?
Not absolute sure.
TKlib 0.4 is part of the ActiveState free TCL-distribution.
Freewrap 6.2 states that it is based on 8.4.12 (latest version).
Quote
I mean do I get it with the Freewrap distribution? Or would it be an add-on like BWidget?
It could be so. Give it a simple try first.
Anyway it should be easy since it only is a 24 KB pure tcl source.
But there are still the 2 problems with:
Not highlighting first line in editor (my workaround isn't really good)
Initial focus not in console/editor window.
Without that it could get real nice.
TKlib is a standallown package and not part of the default TclTK distribution.
Though indeed ActiveState links it (as it links all kinds of tk stuff with its distribitions)..
But I think it should not be too difficult to create yours own
Highlighting "widget" inside tk.. (perhaps wiki.tk has some topics..)
Or!! even better.. Rip-out the Ctext part from the TKLib and distribute it
with the newlisp-tk version.. that better i think..
Btw...Nice going HPW ;-)
On MacOS X 10.4 it seems to be part of the standard install and is just one file of about 24k: /System/Library/Tcl/tklib0.2/ctext/ctext.tcl
I guess it will work everywhere, not only MacOS X.
Lutz