newLISP-TK with syntax highlighting
newLISP-TK with syntax highlighting
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:
The line numbering is a little side effect! ;-)
Now is there a list what commands are grouped together in what color?
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:
The line numbering is a little side effect! ;-)
Now is there a list what commands are grouped together in what color?
Hans-Peter
ctext has the following highlight commands:
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 .....]
So I start with the first one.ctext::addHighlightClass $txt commands blue
- #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\_\-]+}
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 .....]
Hans-Peter
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
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
TCL/TK has grown over years and has a lot of extensions.How does the TK version highlight the syntax anyway? It seems a function within TCL/TK itself?
ctext is a megawidget and part of TKlib.
http://tcllib.sourceforge.net/doc/ctext.html
Hans-Peter
A bit more work:
You get:
set Ide(newLISPCommands) [list ! != $ % & * + - / < << <= = > >= >> NaN? ^ abs ..... ]
Put in newlsip-tk.config:
Other ideas for regexpressions for highlighting?
Modified sources (TK V1.34?) here:
http://www.hpwsoft.de//anmeldung//html1 ... Khighl.zip
Code: Select all
;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))
set Ide(newLISPCommands) [list ! != $ % & * + - / < << <= = > >= >> NaN? ^ abs ..... ]
Put in newlsip-tk.config:
Using now in newlisp-tk.tcl:set Ide(newLISPCommands) [list ! != $ % & * + - / < << <= = > >= >> NaN? ^ abs ..... ]
set Ide(CommandColor) blue
set Ide(StringColor) orange
set Ide(CommentColor) turquoise4
Code: Select all
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) {;.*}
Other ideas for regexpressions for highlighting?
Modified sources (TK V1.34?) here:
http://www.hpwsoft.de//anmeldung//html1 ... Khighl.zip
Hans-Peter
Added ctext to the editor:
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 ... Khighl.zip
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 ... Khighl.zip
Hans-Peter
I added to the newlisp-tk.config:
(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 ... Khighl.zip
Enable/Disable the linemap in console and editor.set Ide(ConsoleLineMap) 1
set Ide(EditLineMap) 0
(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 ... Khighl.zip
Hans-Peter
Not absolute sure.Is ctext part of the normal Tcl/Tk 8.4 library?
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).
It could be so. Give it a simple try first.I mean do I get it with the Freewrap distribution? Or would it be an add-on like BWidget?
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.
Hans-Peter
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 ;-)
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 ;-)
-- (define? (Cornflakes))