xref: /OpenGrok/opengrok-indexer/src/test/resources/sources/tcl/test.tcl (revision 2bcacabbe843448903326d34ff21a265b5f37596)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# See LICENSE.txt included in this distribution for the specific
9# language governing permissions and limitations under the License.
10#
11# When distributing Covered Code, include this CDDL HEADER in each
12# file and include the License file at LICENSE.txt.
13# If applicable, add the following below this CDDL HEADER, with the
14# fields enclosed by brackets "[]" replaced with your own identifying
15# information: Portions Copyright [yyyy] [name of copyright owner]
16#
17# CDDL HEADER END
18#
19
20proc printHelloWorld {} {
21   puts "Hello world"
22}
23
24proc viewSource { f } {
25   global filesVisited EB
26   set EB(curFile) $f
27   lappend filesVisited $f
28
29   # change window title to show the current file
30   set wt [wm title .eb]
31   if { [string first : $wt] != -1 } {
32	set idx [string first : $wt]
33	set base [string range $wt 0 $idx]
34	set wtn [concat $base $f]
35	 } else {
36		  set wtn [concat ${wt}: $f]
37	 }
38    wm title .eb $wtn
39    .eb.f.t config -state normal
40    .eb.f.t delete 1.0 end
41    if [catch {open $f} in] {
42	.eb.f.t insert end $in
43     } else {
44	.eb.f.t insert end [read $in]
45	close $in
46     }
47    .eb.f.t config -state normal
48    .eb.buttons.apply config -command [list applySource $f]
49}