Welcome to Changhai Lu's Homepage

I know nothing except the fact of my ignorance.

- Socrates

 
INFO
 
 
 
Email Me
All English Contents
 
STATS
 
 
 
Article Views:
6,953
Site Views:
32,143,117

▷▷▷▷▷▷ Follow My Threads Account ◁◁◁◁◁◁

TCL2HTML

- by Changhai Lu -

中文版

1. Introduction

Tcl2Html is a software I wrote that converts Tcl/Tk source code into HTML documents with customizable syntax hightlight. Tcl2Html 1.0 recognizes language features and keywords of Tcl/Tk 8.3.2, BWidgets 1.3.1 and Incr Widgets 3.0.0. Users can easily extend this list by adding new packages or new keywords into the existing packages (see the in-program FAQ for details).

There are several freeware or shareware programs that convert C++ and Java code into syntax highlighted HTML files. Due to the smaller size of the community, there seems no similar utility available for Tcl/Tk. The purpose of writing Tcl2Html is to provide Tcl community a freeware tool for code publishing.

No installation is needed for Tcl2Html, simply download tcl2html.zip, unzip it and double-click tcl2html.exe to launch the program. Tcl2Html runs on all versions of Windows.

2. Screenshots

The Main Screen

The Main Screen

The Font/Color Preference

The Font/Color Preference

The Style Preference

The Style Preference

The Indentation Preference

The Indentation Preference

3. Demo:

Sample code generated by Tcl2Html (more sample code can be found in my article Selected Topics in Tcl/Tk is which all the code is generated by Tcl2Html):

#!/bin/sh
# the next line restarts using wish
exec wish "$0" "$@"

# timer --
# This script generates a counter with start and stop buttons.

label .counter -text 0.00 -relief raised -width 10
button .start -text Start -command {
    if $stopped {
        set stopped 0
        tick
    }
}
button .stop -text Stop -command {set stopped 1}
pack .counter -side bottom -fill both
pack .start -side left -fill both -expand yes
pack .stop -side right -fill both -expand yes

set seconds 0
set hundredths 0
set stopped 1

proc tick {} {
    global seconds hundredths stopped
    if $stopped return
    after 50 tick
    set hundredths [expr $hundredths + 5]
    if {$hundredths >= 100} {
        set hundredths 0
        set seconds [expr $seconds + 1]
    }
    .counter config -text [format "%d.%02d" $seconds $hundredths]
}

bind . <Control-c> {destroy .}
bind . <Control-q> {destroy .}
focus .