File: tkinit

package info (click to toggle)
trn4 4.0-test77-18
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 4,016 kB
  • sloc: ansic: 48,332; sh: 6,795; tcl: 1,696; yacc: 662; perl: 108; makefile: 26
file content (90 lines) | stat: -rw-r--r-- 2,469 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#startup script for trntk

#XXX Later have some automatic directory?
if [info exists env(DOTDIR) ] {
  set script_dir $env(DOTDIR)/.trn
} else {
   set script_dir ~/.trn
}

set win_pos_file $script_dir/tkwinpos

set tcl_interactive 0

############### REQUIRED ###############
set ttk_keymod 0
#Required procedures ttk_addkey and ttk_finalize
#Add the key to the trn input if it has an ASCII code.
proc ttk_addkey {akey codekey} {
    global ttk_keys ttk_keymod
    if {$codekey == "120"} {
	append ttk_keys "n"
    } elseif {$akey != "{}"} {append ttk_keys $akey}
}

#quasi-replacement for idle handlers.
#Count is for debugging--to make sure I'm not spinning wildly...
set ttk_idlepending_cnt 0
set ttk_idlepending_list {}
#Use the dolist copy so that items can reschedule themselves
proc ttk_idlepending {} {
    global ttk_idlepending_cnt ttk_idlepending_list ttk_idle_flag
    incr ttk_idlepending_cnt
    set dolist $ttk_idlepending_list
    set ttk_idlepending_list {}
    set ttk_idle_flag 0
    foreach val $dolist {
	eval $val
    }
}

proc ttk_idle_add {cmd} {
    global ttk_idlepending_list ttk_idle_flag
    lappend ttk_idlepending_list $cmd
    set ttk_idle_flag 1
}


#Called just before deleting the TCL interpreter
#Later?: add a procedure that is called a little before the very end.
proc ttk_finalize {} {
     global win_pos_file
#    puts "Bye from Tk!"
     catch {TrnModule_savesizes $win_pos_file}
}

#Default debug procedure: does nothing, is overridden if debug is sourced
proc dbg {txt} { }
############# END REQUIRED #############

#Default behavior, add ASCII code to trn input stream.
#Consider key_handled variable--if set to eventID, no other handlers
#for the key will be called.
bind all <Any-KeyPress> {ttk_addkey "%A" "%k"}

#Don't show the default toplevel window
wm withdraw .

#object-oriented setup
source $script_dir/obtcl.tcl
source $script_dir/TrnModule.tcl

#Show debug window
#source $script_dir/debug.tcl

#Old article tree (*incompatable with object-oriented version*)
#source $script_dir/atree.tcl

#New article tree (with object-oriented stuff)
source $script_dir/objatree.tcl

#New score display (object-oriented)
#source $script_dir/ScoreBar.tcl
#ScoreBar .scorebar -toplevel 1

#load and set old window sizes--to disable, comment the next 3 commands
TrnModule_loadsizes $win_pos_file
#Give the window manager a chance to create decorations...
update
#...and then set the window positions and sizes
TrnModule_setsizes