home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / EDITOR / NVI179B / NVI179B.ZIP / tk / init.tcl next >
Text File  |  1996-07-19  |  35KB  |  1,097 lines

  1. #    @(#)init.tcl    8.10 (Berkeley) 7/19/96
  2. proc screen {} {
  3.     global tk_ssize_row
  4.     global tk_ssize_col
  5.  
  6.     # Build menubar with File, Options and Help entries.
  7.     frame .menu -relief raised -borderwidth 1
  8.     pack append . .menu {top fillx}
  9.  
  10.     # File pull-down menu
  11.     menubutton .menu.file -text "File" \
  12.         -menu .menu.file.fileops -underline 0
  13.     menu .menu.file.fileops
  14.     .menu.file.fileops add command -label "Edit ..." \
  15.         -command "tk_edit" -underline 0
  16.     .menu.file.fileops add command -label "Save File" \
  17.         -command "tk_write" -underline 0
  18.     .menu.file.fileops add command -label "Save File as ..." \
  19.         -command "tk_writeas" -underline 1
  20.     .menu.file.fileops add command -label "Save and Quit" \
  21.         -command "tk_writequit" -underline 7
  22.     .menu.file.fileops add command -label "Quit" \
  23.         -command "tk_quit" -underline 0
  24.  
  25.     # Options pull-down menu
  26.     menubutton .menu.option -text "Options" \
  27.         -menu .menu.option.optionops -underline 0
  28.     menu .menu.option.optionops
  29.     .menu.option.optionops add command -label "Set all" \
  30.         -command tk_options -underline 0
  31.  
  32.     # Help pull-down menu
  33.     menubutton .menu.help -text "Help" \
  34.         -menu .menu.help.helpops -underline 0
  35.     menu .menu.help.helpops
  36.     .menu.help.helpops add command -label "On Help" -underline 3 \
  37.         -command tk_help
  38.     .menu.help.helpops add command -label "On Version" -underline 3 \
  39.         -command tk_version
  40.  
  41.     pack append .menu \
  42.         .menu.file {left} .menu.option {left} .menu.help {right}
  43.  
  44.     # Set up for keyboard-based menu traversal
  45.     tk_bindForTraversal .
  46.     bind . <Any-Enter> {focus .}
  47.     focus .
  48.     tk_menuBar .menu .menu.file .menu.help
  49.  
  50.     # Create text window
  51.     text .t -relief raised -bd 1 -setgrid true -yscrollcommand ".s set"
  52.     scrollbar .s -relief flat -command ".t yview"
  53.     pack append . .s {right filly} .t {expand fill}
  54.  
  55.     # Use tags to build a cursor for the text window.
  56.     set bg [lindex [.t config -background] 4]
  57.     set fg [lindex [.t config -foreground] 4]
  58.     .t tag configure tk_cursor -background $fg -foreground $bg
  59.     .t mark set tk_cursor_indx insert
  60.     .t tag add tk_cursor tk_cursor_indx
  61.  
  62.     # Bind the keys.
  63.     bind .t <Any-KeyPress>    {tk_flash; break}
  64.     bind .t 0        {tk_key_enter "0"; break}
  65.     bind .t 1        {tk_key_enter "1"; break}
  66.     bind .t 2        {tk_key_enter "2"; break}
  67.     bind .t 3        {tk_key_enter "3"; break}
  68.     bind .t 4        {tk_key_enter "4"; break}
  69.     bind .t 5        {tk_key_enter "5"; break}
  70.     bind .t 6        {tk_key_enter "6"; break}
  71.     bind .t 7        {tk_key_enter "7"; break}
  72.     bind .t 8        {tk_key_enter "8"; break}
  73.     bind .t 9        {tk_key_enter "9"; break}
  74.     bind .t <BackSpace>    {tk_key_enter "\010"; break}
  75.     bind .t <Control-a>    {tk_key_enter "\001"; break}
  76.     bind .t <Control-b>    {tk_key_enter "\002"; break}
  77.     bind .t <Control-c>    {tk_key_enter "\003"; break}
  78.     bind .t <Control-d>    {tk_key_enter "\004"; break}
  79.     bind .t <Control-e>    {tk_key_enter "\005"; break}
  80.     bind .t <Control-f>    {tk_key_enter "\006"; break}
  81.     bind .t <Control-g>    {tk_key_enter "\007"; break}
  82.     bind .t <Control-h>    {tk_key_enter "\010"; break}
  83.     bind .t <Control-i>    {tk_key_enter "\011"; break}
  84.     bind .t <Control-j>    {tk_key_enter "\012"; break}
  85.     bind .t <Control-k>    {tk_key_enter "\013"; break}
  86.     bind .t <Control-l>    {tk_key_enter "\014"; break}
  87.     bind .t <Control-m>    {tk_key_enter "\015"; break}
  88.     bind .t <Control-n>    {tk_key_enter "\016"; break}
  89.     bind .t <Control-o>    {tk_key_enter "\017"; break}
  90.     bind .t <Control-p>    {tk_key_enter "\020"; break}
  91.     bind .t <Control-q>    {tk_key_enter "\021"; break}
  92.     bind .t <Control-r>    {tk_key_enter "\022"; break}
  93.     bind .t <Control-s>    {tk_key_enter "\023"; break}
  94.     bind .t <Control-t>    {tk_key_enter "\024"; break}
  95.     bind .t <Control-u>    {tk_key_enter "\025"; break}
  96.     bind .t <Control-v>    {tk_key_enter "\026"; break}
  97.     bind .t <Control-w>    {tk_key_enter "\027"; break}
  98.     bind .t <Control-x>    {tk_key_enter "\030"; break}
  99.     bind .t <Control-y>    {tk_key_enter "\031"; break}
  100.     bind .t <Control-z>    {tk_key_enter "\032"; break}
  101.     bind .t <Control_L>    {tk_noop; break}
  102.     bind .t <Control_R>    {tk_noop; break}
  103.     bind .t <Delete>    {tk_key_enter "x"; break}
  104.     bind .t <Down>        {tk_key_enter "j"; break}
  105.     bind .t <End>        {tk_key_enter "G"; break}
  106.     bind .t <Escape>    {tk_key_enter "\033"; break}
  107.     bind .t <Home>        {tk_key_enter "1G"; break}
  108.     bind .t <Insert>    {tk_key_enter "i"; break}
  109.     bind .t <Left>        {tk_key_enter "h"; break}
  110.     bind .t <Next>        {tk_key_enter "\006"; break}
  111.     bind .t <Prior>        {tk_key_enter "\002"; break}
  112.     bind .t <Return>    {tk_key_enter "\015"; break}
  113.     bind .t <Right>        {tk_key_enter "l"; break}
  114.     bind .t <Shift_L>    {tk_noop; break}
  115.     bind .t <Shift_Lock>    {tk_noop; break}
  116.     bind .t <Shift_R>    {tk_noop; break}
  117.     bind .t <Tab>        {tk_key_enter "\011"; break}
  118.     bind .t <Up>        {tk_key_enter "k"; break}
  119.     bind .t <ampersand>    {tk_key_enter "&"; break}
  120.     bind .t <asciicircum>    {tk_key_enter "^"; break}
  121.     bind .t <asciitilde>    {tk_key_enter "~"; break}
  122.     bind .t <asterisk>    {tk_key_enter "*"; break}
  123.     bind .t <at>        {tk_key_enter "@"; break}
  124.     bind .t <backslash>    {tk_key_enter "\\"; break}
  125.     bind .t <bar>        {tk_key_enter "|"; break}
  126.     bind .t <braceleft>    {tk_key_enter "{"; break}
  127.     bind .t <braceright>    {tk_key_enter "; break}"}
  128.     bind .t <bracketleft>    {tk_key_enter "\["; break}
  129.     bind .t <bracketright>    {tk_key_enter "]"; break}
  130.     bind .t <colon>        {tk_key_enter ":"; break}
  131.     bind .t <comma>        {tk_key_enter ","; break}
  132.     bind .t <dollar>    {tk_key_enter "$"; break}
  133.     bind .t <equal>        {tk_key_enter "="; break}
  134.     bind .t <exclam>    {tk_key_enter "!"; break}
  135.     bind .t <greater>    {tk_key_enter ">"; break}
  136.     bind .t <less>        {tk_key_enter "<"; break}
  137.     bind .t <minus>        {tk_key_enter "-"; break}
  138.     bind .t <numbersign>    {tk_key_enter "#"; break}
  139.     bind .t <parenleft>    {tk_key_enter "("; break}
  140.     bind .t <parenright>    {tk_key_enter ")"; break}
  141.     bind .t <percent>    {tk_key_enter "%"; break}
  142.     bind .t <period>    {tk_key_enter "."; break}
  143.     bind .t <plus>        {tk_key_enter "+"; break}
  144.     bind .t <question>    {tk_key_enter "?"; break}
  145.     bind .t <quotedbl>    {tk_key_enter "\""; break}
  146.     bind .t <quoteright>    {tk_key_enter "'"; break}
  147.     bind .t <semicolon>    {tk_key_enter ";"; break}
  148.     bind .t <slash>        {tk_key_enter "/"; break}
  149.     bind .t <space>        {tk_key_enter " "; break}
  150.     bind .t <underscore>    {tk_key_enter "_"; break}
  151.     bind .t A        {tk_key_enter "A"; break}
  152.     bind .t B        {tk_key_enter "B"; break}
  153.     bind .t C        {tk_key_enter "C"; break}
  154.     bind .t D        {tk_key_enter "D"; break}
  155.     bind .t E        {tk_key_enter "E"; break}
  156.     bind .t F        {tk_key_enter "F"; break}
  157.     bind .t G        {tk_key_enter "G"; break}
  158.     bind .t H        {tk_key_enter "H"; break}
  159.     bind .t I        {tk_key_enter "I"; break}
  160.     bind .t J        {tk_key_enter "J"; break}
  161.     bind .t K        {tk_key_enter "K"; break}
  162.     bind .t L        {tk_key_enter "L"; break}
  163.     bind .t M        {tk_key_enter "M"; break}
  164.     bind .t N        {tk_key_enter "N"; break}
  165.     bind .t O        {tk_key_enter "O"; break}
  166.     bind .t P        {tk_key_enter "P"; break}
  167.     bind .t Q        {tk_key_enter "Q"; break}
  168.     bind .t R        {tk_key_enter "R"; break}
  169.     bind .t S        {tk_key_enter "S"; break}
  170.     bind .t T        {tk_key_enter "T"; break}
  171.     bind .t U        {tk_key_enter "U"; break}
  172.     bind .t V        {tk_key_enter "V"; break}
  173.     bind .t W        {tk_key_enter "W"; break}
  174.     bind .t X        {tk_key_enter "X"; break}
  175.     bind .t Y        {tk_key_enter "Y"; break}
  176.     bind .t Z        {tk_key_enter "Z"; break}
  177.     bind .t a        {tk_key_enter "a"; break}
  178.     bind .t b        {tk_key_enter "b"; break}
  179.     bind .t c        {tk_key_enter "c"; break}
  180.     bind .t d        {tk_key_enter "d"; break}
  181.     bind .t e        {tk_key_enter "e"; break}
  182.     bind .t f        {tk_key_enter "f"; break}
  183.     bind .t g        {tk_key_enter "g"; break}
  184.     bind .t h        {tk_key_enter "h"; break}
  185.     bind .t i        {tk_key_enter "i"; break}
  186.     bind .t j        {tk_key_enter "j"; break}
  187.     bind .t k        {tk_key_enter "k"; break}
  188.     bind .t l        {tk_key_enter "l"; break}
  189.     bind .t m        {tk_key_enter "m"; break}
  190.     bind .t n        {tk_key_enter "n"; break}
  191.     bind .t o        {tk_key_enter "o"; break}
  192.     bind .t p        {tk_key_enter "p"; break}
  193.     bind .t q        {tk_key_enter "q"; break}
  194.     bind .t r        {tk_key_enter "r"; break}
  195.     bind .t s        {tk_key_enter "s"; break}
  196.     bind .t t        {tk_key_enter "t"; break}
  197.     bind .t u        {tk_key_enter "u"; break}
  198.     bind .t v        {tk_key_enter "v"; break}
  199.     bind .t w        {tk_key_enter "w"; break}
  200.     bind .t x        {tk_key_enter "x"; break}
  201.     bind .t y        {tk_key_enter "y"; break}
  202.     bind .t z        {tk_key_enter "z"; break}
  203.  
  204.     # XXX
  205.     # I haven't been able to make Tcl/Tk write uninitialized portions
  206.     # of the text window.  Fill in the screen.
  207.     tk_ssize
  208.     .t mark set insert 1.0
  209.     for {set i 1} {$i <= $tk_ssize_row} {incr i} {
  210.         for {set j 1} {$j <= $tk_ssize_col} {incr j} {
  211.             .t insert insert " "
  212.         }
  213.         .t insert insert "\n"
  214.     }
  215. }
  216.  
  217. # tk_noop --
  218. #    Do nothing.
  219. #
  220. # XXX
  221. # I can't figure out how to get a binding that does nothing without
  222. # calling a function, so this stub does it for me.
  223. proc tk_noop {} {
  224. }
  225.  
  226. # tk_key_enter --
  227. #    Enter a key.
  228. proc tk_key_enter {val} {
  229.     global newkey
  230.     global waiting
  231.  
  232.     set waiting 0
  233.     tk_key $val
  234.     set newkey 1
  235. }
  236.  
  237. # tk_key_wait --
  238. #    Wait for a key.
  239. proc tk_key_wait {timeout} {
  240.     global newkey
  241.     global waiting
  242.  
  243.     if { $timeout != 0 } {
  244.         after $timeout "set newkey 1"
  245.     }
  246.     set waiting 1
  247.     tkwait variable newkey
  248. }
  249.  
  250. # Callback functions for the File menu.
  251. # tk_edit
  252. #    Edit another file.
  253. proc tk_edit {} {
  254. }
  255.  
  256. # tk_quit
  257. #    Quit.
  258. proc tk_quit {} {
  259.     global newkey
  260.     global waiting
  261.  
  262.     tk_op quit
  263.     if { $waiting != 0 } {
  264.         set newkey 1
  265.     }
  266. }
  267.  
  268. # tk_write
  269. #    Write the edit buffer.
  270. proc tk_write {} {
  271.     global newkey
  272.     global waiting
  273.  
  274.     tk_op write
  275.     if { $waiting != 0 } {
  276.         set newkey 1
  277.     }
  278. }
  279.  
  280. # tk_writeas
  281. #    Write the edit buffer to a named file.
  282. proc tk_writeas {} {
  283. }
  284.  
  285. # tk_writequit
  286. #    Write and quit.
  287. proc tk_writequit {} {
  288.     global newkey
  289.     global waiting
  290.  
  291.     tk_op writequit
  292.     if { $waiting != 0 } {
  293.         set newkey 1
  294.     }
  295. }
  296.  
  297. # Callback functions for the Help menu.
  298. #
  299. # tk_help --
  300. #    Present a help screen.
  301. proc tk_help {} {
  302.     tk_dialog .d {} "No help screen currently available." {} 0 Continue
  303. }
  304.  
  305. # tk_options
  306. # Contains the option selector box. It is divided into three parts, the
  307. # checkbuttons for the boolean options, the entry fields for the string
  308. # numeric options, and a control area containing buttons.  There is only
  309. # one function.
  310. proc tk_options {} {
  311.  
  312.     # Build option selector box with three subframes for boolean,
  313.     # numeric, and string options.  Make it a toplevel window.
  314.     toplevel .os
  315.     wm title .os options
  316.  
  317.     # Option variables.
  318.     global tko_altwerase
  319.     global tko_autoindent
  320.     global tko_autoprint
  321.     global tko_autowrite
  322.     global tko_backup
  323.     global tko_beautify
  324.     global tko_cdpath
  325.     global tko_cedit
  326.     global tko_columns
  327.     global tko_comment
  328.     global tko_directory
  329.     global tko_edcompatible
  330.     global tko_escapetime
  331.     global tko_errorbells
  332.     global tko_exrc
  333.     global tko_extended
  334.     global tko_filec
  335.     global tko_flash
  336.     global tko_hardtabs
  337.     global tko_iclower
  338.     global tko_ignorecase
  339.     global tko_keytime
  340.     global tko_leftright
  341.     global tko_lines
  342.     global tko_lisp
  343.     global tko_list
  344.     global tko_lock
  345.     global tko_magic
  346.     global tko_matchtime
  347.     global tko_mesg
  348.     global tko_modeline
  349.     global tko_msgcat
  350.     global tko_noprint
  351.     global tko_number
  352.     global tko_octal
  353.     global tko_open
  354.     global tko_optimize
  355.     global tko_paragraphs
  356.     global tko_print
  357.     global tko_prompt
  358.     global tko_readonly
  359.     global tko_recdir
  360.     global tko_redraw
  361.     global tko_remap
  362.     global tko_report
  363.     global tko_ruler
  364.     global tko_scroll
  365.     global tko_searchincr
  366.     global tko_sections
  367.     global tko_secure
  368.     global tko_shell
  369.     global tko_shellmeta
  370.     global tko_shiftwidth
  371.     global tko_showmatch
  372.     global tko_showmode
  373.     global tko_sidescroll
  374.     global tko_slowopen
  375.     global tko_sourceany
  376.     global tko_tabstop
  377.     global tko_taglength
  378.     global tko_tags
  379.     global tko_term
  380.     global tko_terse
  381.     global tko_tildeop
  382.     global tko_timeout
  383.     global tko_ttywerase
  384.     global tko_verbose
  385.     global tko_warn
  386.     global tko_window
  387.     global tko_windowname
  388.     global tko_wraplen
  389.     global tko_wrapmargin
  390.     global tko_wrapscan
  391.     global tko_writeany
  392.  
  393.     # Initialize option values.
  394.     tk_opt_init
  395.  
  396.     # Build subframe for boolean options.
  397.     frame .os.bopts
  398.  
  399.     # This is the width of the edcompatible button.
  400.     set buttonwidth 13
  401.  
  402.     # Pack the boolean os, 5 to a frame.
  403.     frame .os.bopts.f1
  404.     pack append .os.bopts .os.bopts.f1 {top}
  405.     checkbutton .os.bopts.f1.b1 \
  406.         -variable tko_altwerase -text "altwerase" \
  407.         -command "tk_opt_set altwerase $tko_altwerase" \
  408.         -width $buttonwidth -anchor w
  409.     checkbutton .os.bopts.f1.b2 \
  410.         -variable tko_autoindent -text "autoindent" \
  411.         -command "tk_opt_set autoindent $tko_autoindent" \
  412.         -width $buttonwidth -anchor w
  413.     checkbutton .os.bopts.f1.b3 \
  414.         -variable tko_autoprint -text "autoprint" \
  415.         -command "tk_opt_set autoprint $tko_autoprint" \
  416.         -width $buttonwidth -anchor w
  417.     checkbutton .os.bopts.f1.b4 \
  418.         -variable tko_autowrite -text "autowrite" \
  419.         -command "tk_opt_set autowrite $tko_autowrite" \
  420.         -width $buttonwidth -anchor w
  421.     checkbutton .os.bopts.f1.b5 \
  422.         -variable tko_beautify -text "beautify" \
  423.         -command "tk_opt_set beautify $tko_beautify" \
  424.         -width $buttonwidth -anchor w
  425.     pack append .os.bopts.f1 \
  426.         .os.bopts.f1.b1 {left frame w} \
  427.         .os.bopts.f1.b2 {left frame w} \
  428.         .os.bopts.f1.b3 {left frame w} \
  429.         .os.bopts.f1.b4 {left frame w} \
  430.         .os.bopts.f1.b5 {left frame w}
  431.  
  432.     frame .os.bopts.f2
  433.     pack append .os.bopts .os.bopts.f2 {top}
  434.     checkbutton .os.bopts.f2.b1 \
  435.         -variable tko_comment -text "comment" \
  436.         -command "tk_opt_set comment $tko_comment" \
  437.         -width $buttonwidth -anchor w
  438.     checkbutton .os.bopts.f2.b2 \
  439.         -variable tko_edcompatible -text "edcompatible" \
  440.         -command "tk_opt_set edcompatible $tko_edcompatible" \
  441.         -width $buttonwidth -anchor w
  442.     checkbutton .os.bopts.f2.b3 \
  443.         -variable tko_errorbells -text "errorbells" \
  444.         -command "tk_opt_set errorbells $tko_errorbells" \
  445.         -width $buttonwidth -anchor w
  446.     checkbutton .os.bopts.f2.b4 \
  447.         -variable tko_exrc -text "exrc" \
  448.         -command "tk_opt_set exrc $tko_exrc" \
  449.         -width $buttonwidth -anchor w
  450.     checkbutton .os.bopts.f2.b5 \
  451.         -variable tko_extended -text "extended" \
  452.         -command "tk_opt_set extended $tko_extended" \
  453.         -width $buttonwidth -anchor w
  454.     pack append .os.bopts.f2 \
  455.         .os.bopts.f2.b1 {left frame w} \
  456.         .os.bopts.f2.b2 {left frame w} \
  457.         .os.bopts.f2.b3 {left frame w} \
  458.         .os.bopts.f2.b4 {left frame w} \
  459.         .os.bopts.f2.b5 {left frame w}
  460.  
  461.     frame .os.bopts.f3
  462.     pack append .os.bopts .os.bopts.f3 {top}
  463.     checkbutton .os.bopts.f3.b1 \
  464.         -variable tko_flash -text "flash" \
  465.         -command "tk_opt_set flash $tko_flash" \
  466.         -width $buttonwidth -anchor w
  467.     checkbutton .os.bopts.f3.b2 \
  468.         -variable tko_iclower -text "iclower" \
  469.         -command "tk_opt_set iclower $tko_iclower" \
  470.         -width $buttonwidth -anchor w
  471.     checkbutton .os.bopts.f3.b3 \
  472.         -variable tko_ignorecase -text "ignorecase" \
  473.         -command "tk_opt_set ignorecase $tko_ignorecase" \
  474.         -width $buttonwidth -anchor w
  475.     checkbutton .os.bopts.f3.b4 \
  476.         -variable tko_leftright -text "leftright" \
  477.         -command "tk_opt_set leftright $tko_leftright" \
  478.         -width $buttonwidth -anchor w
  479.     checkbutton .os.bopts.f3.b5 \
  480.         -variable tko_lisp -text "lisp" \
  481.         -command "tk_opt_set lisp $tko_lisp" \
  482.         -width $buttonwidth -anchor w
  483.     pack append .os.bopts.f3 \
  484.         .os.bopts.f3.b1 {left frame w} \
  485.         .os.bopts.f3.b2 {left frame w} \
  486.         .os.bopts.f3.b3 {left frame w} \
  487.         .os.bopts.f3.b4 {left frame w} \
  488.         .os.bopts.f3.b5 {left frame w}
  489.  
  490.     frame .os.bopts.f4
  491.     pack append .os.bopts .os.bopts.f4 {top}
  492.     checkbutton .os.bopts.f4.b1 \
  493.         -variable tko_list -text "list" \
  494.         -command "tk_opt_set list $tko_list" \
  495.         -width $buttonwidth -anchor w
  496.     checkbutton .os.bopts.f4.b2 \
  497.         -variable tko_lock -text "lock" \
  498.         -command "tk_opt_set lock $tko_lock" \
  499.         -width $buttonwidth -anchor w
  500.     checkbutton .os.bopts.f4.b3 \
  501.         -variable tko_magic -text "magic" \
  502.         -command "tk_opt_set magic $tko_magic" \
  503.         -width $buttonwidth -anchor w
  504.     checkbutton .os.bopts.f4.b4 \
  505.         -variable tko_mesg -text "mesg" \
  506.         -command "tk_opt_set mesg $tko_mesg" \
  507.         -width $buttonwidth -anchor w
  508.     checkbutton .os.bopts.f4.b5\
  509.         -variable tko_number -text "number" \
  510.         -command "tk_opt_set number $tko_number" \
  511.         -width $buttonwidth -anchor w
  512.     pack append .os.bopts.f4 \
  513.         .os.bopts.f4.b1 {left frame w} \
  514.         .os.bopts.f4.b2 {left frame w} \
  515.         .os.bopts.f4.b3 {left frame w} \
  516.         .os.bopts.f4.b4 {left frame w} \
  517.         .os.bopts.f4.b5 {left frame w}
  518.  
  519.     frame .os.bopts.f5
  520.     pack append .os.bopts .os.bopts.f5 {top}
  521.     checkbutton .os.bopts.f5.b1 \
  522.         -variable tko_octal -text "octal" \
  523.         -command "tk_opt_set octal $tko_octal" \
  524.         -width $buttonwidth -anchor w
  525.     checkbutton .os.bopts.f5.b2 \
  526.         -variable tko_open -text "open" \
  527.         -command "tk_opt_set open $tko_open" \
  528.         -width $buttonwidth -anchor w
  529.     checkbutton .os.bopts.f5.b3 \
  530.         -variable tko_optimize -text "optimize" \
  531.         -command "tk_opt_set optimize $tko_optimize" \
  532.         -width $buttonwidth -anchor w
  533.     checkbutton .os.bopts.f5.b4 \
  534.         -variable tko_prompt -text "prompt" \
  535.         -command "tk_opt_set prompt $tko_prompt" \
  536.         -width $buttonwidth -anchor w
  537.     checkbutton .os.bopts.f5.b5 \
  538.         -variable tko_readonly -text "readonly" \
  539.         -command "tk_opt_set readonly $tko_readonly" \
  540.         -width $buttonwidth -anchor w
  541.     pack append .os.bopts.f5 \
  542.         .os.bopts.f5.b1 {left frame w} \
  543.         .os.bopts.f5.b2 {left frame w} \
  544.         .os.bopts.f5.b3 {left frame w} \
  545.         .os.bopts.f5.b4 {left frame w} \
  546.         .os.bopts.f5.b5 {left frame w}
  547.  
  548.     frame .os.bopts.f6
  549.     pack append .os.bopts .os.bopts.f6 {top}
  550.     checkbutton .os.bopts.f6.b1 \
  551.         -variable tko_remap -text "remap" \
  552.         -command "tk_opt_set remap $tko_remap" \
  553.         -width $buttonwidth -anchor w
  554.     checkbutton .os.bopts.f6.b2 \
  555.         -variable tko_ruler -text "ruler" \
  556.         -command "tk_opt_set ruler $tko_ruler" \
  557.         -width $buttonwidth -anchor w
  558.     checkbutton .os.bopts.f6.b3 \
  559.         -variable tko_searchincr -text "searchincr" \
  560.         -command "tk_opt_set searchincr $tko_searchincr" \
  561.         -width $buttonwidth -anchor w
  562.     checkbutton .os.bopts.f6.b4 \
  563.         -variable tko_secure -text "secure" \
  564.         -command "tk_opt_set secure $tko_secure" \
  565.         -width $buttonwidth -anchor w
  566.     checkbutton .os.bopts.f6.b5 \
  567.         -variable tko_showmatch -text "showmatch" \
  568.         -command "tk_opt_set showmatch $tko_showmatch" \
  569.         -width $buttonwidth -anchor w
  570.     pack append .os.bopts.f6 \
  571.         .os.bopts.f6.b1 {left frame w} \
  572.         .os.bopts.f6.b2 {left frame w} \
  573.         .os.bopts.f6.b3 {left frame w} \
  574.         .os.bopts.f6.b4 {left frame w} \
  575.         .os.bopts.f6.b5 {left frame w}
  576.  
  577.     frame .os.bopts.f7
  578.     pack append .os.bopts .os.bopts.f7 {top}
  579.     checkbutton .os.bopts.f7.b1 \
  580.         -variable tko_showmode -text "showmode" \
  581.         -command "tk_opt_set showmode $tko_showmode" \
  582.         -width $buttonwidth -anchor w
  583.     checkbutton .os.bopts.f7.b2 \
  584.         -variable tko_slowopen -text "slowopen" \
  585.         -command "tk_opt_set slowopen $tko_slowopen" \
  586.         -width $buttonwidth -anchor w
  587.     checkbutton .os.bopts.f7.b3 \
  588.         -variable tko_sourceany -text "sourceany" \
  589.         -command "tk_opt_set sourceany $tko_sourceany" \
  590.         -width $buttonwidth -anchor w
  591.     checkbutton .os.bopts.f7.b4 \
  592.         -variable tko_terse -text "terse" \
  593.         -command "tk_opt_set terse $tko_terse" \
  594.         -width $buttonwidth -anchor w
  595.     checkbutton .os.bopts.f7.b5 \
  596.         -variable tko_tildeop -text "tildeop" \
  597.         -command "tk_opt_set tildeope $tko_tildeop" \
  598.         -width $buttonwidth -anchor w
  599.     pack append .os.bopts.f7 \
  600.         .os.bopts.f7.b1 {left frame w} \
  601.         .os.bopts.f7.b2 {left frame w} \
  602.         .os.bopts.f7.b3 {left frame w} \
  603.         .os.bopts.f7.b4 {left frame w} \
  604.         .os.bopts.f7.b5 {left frame w}
  605.  
  606.     frame .os.bopts.f8
  607.     pack append .os.bopts .os.bopts.f8 {top fillx}
  608.     checkbutton .os.bopts.f8.b1 \
  609.         -variable tko_timeout -text "timeout" \
  610.         -command "tk_opt_set timeout $tko_timeout" \
  611.         -width $buttonwidth -anchor w
  612.     checkbutton .os.bopts.f8.b2 \
  613.         -variable tko_ttywerase -text "ttywerase" \
  614.         -command "tk_opt_set ttywerase $tko_ttywerase" \
  615.         -width $buttonwidth -anchor w
  616.     checkbutton .os.bopts.f8.b3 \
  617.         -variable tko_verbose -text "verbose" \
  618.         -command "tk_opt_set verbose $tko_verbose" \
  619.         -width $buttonwidth -anchor w
  620.     checkbutton .os.bopts.f8.b4 \
  621.         -variable tko_warn -text "warn" \
  622.         -command "tk_opt_set warn $tko_warn" \
  623.         -width $buttonwidth -anchor w
  624.     checkbutton .os.bopts.f8.b5 \
  625.         -variable tko_windowname -text "windowname" \
  626.         -command "tk_opt_set windowname $tko_windowname" \
  627.         -width $buttonwidth -anchor w
  628.     pack append .os.bopts.f8 \
  629.         .os.bopts.f8.b1 {left frame w} \
  630.         .os.bopts.f8.b2 {left frame w} \
  631.         .os.bopts.f8.b3 {left frame w} \
  632.         .os.bopts.f8.b4 {left frame w} \
  633.         .os.bopts.f8.b5 {left frame w}
  634.  
  635.     frame .os.bopts.f9
  636.     pack append .os.bopts .os.bopts.f9 {top fillx}
  637.     checkbutton .os.bopts.f9.b1 \
  638.         -variable tko_wrapscan -text "wrapscan" \
  639.         -command "tk_opt_set wrapscan $tko_wrapscan" \
  640.         -width $buttonwidth -anchor w
  641.     checkbutton .os.bopts.f9.b2 \
  642.         -variable tko_writeany -text "writeany" \
  643.         -command "tk_opt_set writeany $tko_writeany" \
  644.         -width $buttonwidth -anchor w
  645.     pack append .os.bopts.f9 \
  646.         .os.bopts.f9.b1 {left frame w} \
  647.         .os.bopts.f9.b2 {left frame w}
  648.  
  649.     # Build frame for number options:
  650.     frame .os.nopts
  651.  
  652.     # Label and entry widths.
  653.     set lwidth 12
  654.     set ewidth  3
  655.  
  656.     frame .os.nopts.n1
  657.     label .os.nopts.n1.l -text "column:" -width $lwidth -anchor w
  658.     entry .os.nopts.n1.e -width $ewidth -relief raised \
  659.         -textvariable tko_columns
  660.     trace variable tko_columns w tk_opt_ew
  661.     pack append .os.nopts.n1 \
  662.         .os.nopts.n1.l {left} .os.nopts.n1.e {left frame w}
  663.  
  664.     frame .os.nopts.n2
  665.     label .os.nopts.n2.l -text "escapetime:" -width $lwidth -anchor w
  666.     entry .os.nopts.n2.e -width $ewidth -textvariable tko_escapetime \
  667.         -relief raised
  668.     trace variable tko_escapetime w tk_opt_ew
  669.     pack append .os.nopts.n2 \
  670.         .os.nopts.n2.l {left} .os.nopts.n2.e {left frame w}
  671.  
  672.     frame .os.nopts.n3
  673.     label .os.nopts.n3.l -text "hardtabs:" -width $lwidth -anchor w
  674.     entry .os.nopts.n3.e -width $ewidth -textvariable tko_hardtabs \
  675.         -relief raised
  676.     trace variable tko_hardtabs w tk_opt_ew
  677.     pack append .os.nopts.n3 \
  678.         .os.nopts.n3.l {left} .os.nopts.n3.e {left frame w}
  679.  
  680.     frame .os.nopts.n4
  681.     label .os.nopts.n4.l -text "keytime:" -width $lwidth -anchor w
  682.     entry .os.nopts.n4.e -width $ewidth -textvariable tko_keytime \
  683.         -relief raised
  684.     trace variable tko_keytime w tk_opt_ew
  685.     pack append .os.nopts.n4 \
  686.         .os.nopts.n4.l {left} .os.nopts.n4.e {left frame w}
  687.  
  688.     frame .os.nopts.n5
  689.     label .os.nopts.n5.l -text "lines:" -width $lwidth -anchor w
  690.     entry .os.nopts.n5.e -width $ewidth -textvariable tko_lines \
  691.         -relief raised
  692.     trace variable tko_lines w tk_opt_ew
  693.     pack append .os.nopts.n5 \
  694.         .os.nopts.n5.l {left} .os.nopts.n5.e {left frame w}
  695.  
  696.     frame .os.nopts.n6
  697.     label .os.nopts.n6.l -text "matchtime:" -width $lwidth -anchor w
  698.     entry .os.nopts.n6.e -width $ewidth -textvariable tko_matchtime \
  699.         -relief raised
  700.     trace variable tko_matchtime w tk_opt_ew
  701.     pack append .os.nopts.n6 \
  702.         .os.nopts.n6.l {left} .os.nopts.n6.e {left frame w}
  703.  
  704.     frame .os.nopts.n7
  705.     label .os.nopts.n7.l -text "report:" -width $lwidth -anchor w
  706.     entry .os.nopts.n7.e -width $ewidth -textvariable tko_report \
  707.         -relief raised
  708.     trace variable tko_report w tk_opt_ew
  709.     pack append .os.nopts.n7 \
  710.         .os.nopts.n7.l {left} .os.nopts.n7.e {left frame w}
  711.  
  712.     frame .os.nopts.n8
  713.     label .os.nopts.n8.l -text "scroll:" -width $lwidth -anchor w
  714.     entry .os.nopts.n8.e -width $ewidth -textvariable tko_scroll \
  715.         -relief raised
  716.     trace variable tko_scroll w tk_opt_ew
  717.     pack append .os.nopts.n8 \
  718.         .os.nopts.n8.l {left} .os.nopts.n8.e {left frame w}
  719.  
  720.     frame .os.nopts.n9
  721.     label .os.nopts.n9.l -text "shiftwidth:" -width $lwidth -anchor w
  722.     entry .os.nopts.n9.e -width $ewidth -textvariable tko_shiftwidth \
  723.         -relief raised
  724.     trace variable tko_shiftwidth w tk_opt_ew
  725.     pack append .os.nopts.n9 \
  726.         .os.nopts.n9.l {left} .os.nopts.n9.e {left frame w}
  727.  
  728.     frame .os.nopts.n10
  729.     label .os.nopts.n10.l -text "sidescroll:" -width $lwidth -anchor w
  730.     entry .os.nopts.n10.e -width $ewidth -textvariable tko_sidescroll \
  731.         -relief raised
  732.     trace variable tko_sidescroll w tk_opt_ew
  733.     pack append .os.nopts.n10 \
  734.         .os.nopts.n10.l {left} .os.nopts.n10.e {left frame w}
  735.  
  736.     frame .os.nopts.n11
  737.     label .os.nopts.n11.l -text "tabstop:" -width $lwidth -anchor w
  738.     entry .os.nopts.n11.e -width $ewidth -textvariable tko_tabstop \
  739.         -relief raised
  740.     trace variable tko_tabstop w tk_opt_ew
  741.     pack append .os.nopts.n11 \
  742.         .os.nopts.n11.l {left} .os.nopts.n11.e {left frame w}
  743.  
  744.     frame .os.nopts.n12
  745.     label .os.nopts.n12.l -text "taglength:" -width $lwidth -anchor w
  746.     entry .os.nopts.n12.e -width $ewidth -textvariable tko_taglength \
  747.         -relief raised
  748.     trace variable tko_taglength w tk_opt_ew
  749.     pack append .os.nopts.n12 \
  750.         .os.nopts.n12.l {left} .os.nopts.n12.e {left frame w}
  751.  
  752.     frame .os.nopts.n13
  753.     label .os.nopts.n13.l -text "window:" -width $lwidth -anchor w
  754.     entry .os.nopts.n13.e -width $ewidth -textvariable tko_window \
  755.         -relief raised
  756.     trace variable tko_window w tk_opt_ew
  757.     pack append .os.nopts.n13 \
  758.         .os.nopts.n13.l {left} .os.nopts.n13.e {left frame w}
  759.  
  760.     frame .os.nopts.n14
  761.     label .os.nopts.n14.l -text "wraplen:" -width $lwidth -anchor w
  762.     entry .os.nopts.n14.e -width $ewidth -textvariable tko_wraplen \
  763.         -relief raised
  764.     trace variable tko_wraplen w tk_opt_ew
  765.     pack append .os.nopts.n14 \
  766.         .os.nopts.n14.l {left} .os.nopts.n14.e {left frame w}
  767.  
  768.     frame .os.nopts.n15
  769.     label .os.nopts.n15.l -text "wrapmargin:" -width $lwidth -anchor w
  770.     entry .os.nopts.n15.e -width $ewidth -textvariable tko_wrapmargin \
  771.         -relief raised
  772.     trace variable tko_wrapmargin w tk_opt_ew
  773.     pack append .os.nopts.n15 \
  774.         .os.nopts.n15.l {left} .os.nopts.n15.e {left frame w}
  775.  
  776.     pack append .os.nopts \
  777.         .os.nopts.n1 {top fillx} \
  778.         .os.nopts.n3 {top expand fillx} \
  779.         .os.nopts.n4 {top expand fillx} \
  780.         .os.nopts.n5 {top expand fillx} \
  781.         .os.nopts.n6 {top expand fillx} \
  782.         .os.nopts.n7 {top expand fillx} \
  783.         .os.nopts.n8 {top expand fillx} \
  784.         .os.nopts.n9 {top expand fillx} \
  785.         .os.nopts.n10 {top expand fillx} \
  786.         .os.nopts.n11 {top expand fillx} \
  787.         .os.nopts.n12 {top expand fillx} \
  788.         .os.nopts.n13 {top expand fillx} \
  789.         .os.nopts.n14 {top expand fillx} \
  790.         .os.nopts.n15 {top expand fillx}
  791.  
  792.     # Build frame for string options
  793.     frame .os.sopts
  794.  
  795.     # Entry width.
  796.     set ewidth  40
  797.  
  798.     frame .os.sopts.s1
  799.     label .os.sopts.s1.l -text "backup:" -width $lwidth -anchor w
  800.     entry .os.sopts.s1.e -width $ewidth -textvariable tko_backup \
  801.         -relief raised
  802.     pack append .os.sopts.s1 \
  803.         .os.sopts.s1.l {left} .os.sopts.s1.e {left frame w}
  804.  
  805.     frame .os.sopts.s2
  806.     label .os.sopts.s2.l -text "cdpath:" -width $lwidth -anchor w
  807.     entry .os.sopts.s2.e -width $ewidth -textvariable tko_cdpath \
  808.         -relief raised
  809.     pack append .os.sopts.s2 \
  810.         .os.sopts.s2.l {left} .os.sopts.s2.e {left frame w}
  811.  
  812.     frame .os.sopts.s3
  813.     label .os.sopts.s3.l -text "directory:" -width $lwidth -anchor w
  814.     entry .os.sopts.s3.e -width $ewidth -textvariable tko_directory \
  815.         -relief raised
  816.     pack append .os.sopts.s3 \
  817.         .os.sopts.s3.l {left} .os.sopts.s3.e {left frame w}
  818.  
  819.     frame .os.sopts.s4
  820.     label .os.sopts.s4.l -text "cedit:" -width $lwidth -anchor w
  821.     entry .os.sopts.s4.e -width $ewidth -textvariable tko_cedit \
  822.         -relief raised
  823.     pack append .os.sopts.s4 \
  824.         .os.sopts.s4.l {left} .os.sopts.s4.e {left frame w}
  825.  
  826.     frame .os.sopts.s5
  827.     label .os.sopts.s5.l -text "filec:" -width $lwidth -anchor w
  828.     entry .os.sopts.s5.e -width $ewidth -textvariable tko_filec \
  829.         -relief raised
  830.     pack append .os.sopts.s5 \
  831.         .os.sopts.s5.l {left} .os.sopts.s5.e {left frame w}
  832.  
  833.     frame .os.sopts.s6
  834.     label .os.sopts.s6.l -text "msgcat:" -width $lwidth -anchor w
  835.     entry .os.sopts.s6.e -width $ewidth -textvariable tko_msgcat \
  836.         -relief raised
  837.     pack append .os.sopts.s6 \
  838.         .os.sopts.s6.l {left} .os.sopts.s6.e {left frame w}
  839.  
  840.     frame .os.sopts.s7
  841.     label .os.sopts.s7.l -text "noprint:" -width $lwidth -anchor w
  842.     entry .os.sopts.s7.e -width $ewidth -textvariable tko_noprint \
  843.         -relief raised
  844.     pack append .os.sopts.s7 \
  845.         .os.sopts.s7.l {left} .os.sopts.s7.e {left frame w}
  846.  
  847.     frame .os.sopts.s8
  848.     label .os.sopts.s8.l -text "paragraphs:" -width $lwidth -anchor w
  849.     entry .os.sopts.s8.e -width $ewidth -textvariable tko_paragraphs \
  850.         -relief raised
  851.     pack append .os.sopts.s8 \
  852.         .os.sopts.s8.l {left} .os.sopts.s8.e {left frame w}
  853.  
  854.     frame .os.sopts.s9
  855.     label .os.sopts.s9.l -text "print:" -width $lwidth -anchor w
  856.     entry .os.sopts.s9.e -width $ewidth -textvariable tko_print \
  857.         -relief raised
  858.     pack append .os.sopts.s9 \
  859.         .os.sopts.s9.l {left} .os.sopts.s9.e {left frame w}
  860.  
  861.     frame .os.sopts.s10
  862.     label .os.sopts.s10.l -text "recdir:" -width $lwidth -anchor w
  863.     entry .os.sopts.s10.e -width $ewidth -textvariable tko_recdir \
  864.         -relief raised
  865.     pack append .os.sopts.s10 \
  866.         .os.sopts.s10.l {left} .os.sopts.s10.e {left frame w}
  867.  
  868.     frame .os.sopts.s11
  869.     label .os.sopts.s11.l -text "sections:" -width $lwidth -anchor w
  870.     entry .os.sopts.s11.e -width $ewidth -textvariable tko_sections \
  871.         -relief raised
  872.     pack append .os.sopts.s11 \
  873.         .os.sopts.s11.l {left} .os.sopts.s11.e {left frame w}
  874.  
  875.     frame .os.sopts.s12
  876.     label .os.sopts.s12.l -text "shell:" -width $lwidth -anchor w
  877.     entry .os.sopts.s12.e -width $ewidth -textvariable tko_shell \
  878.         -relief raised
  879.     pack append .os.sopts.s12 \
  880.         .os.sopts.s12.l {left} .os.sopts.s12.e {left frame w}
  881.  
  882.     frame .os.sopts.s13
  883.     label .os.sopts.s13.l -text "shellmeta:" -width $lwidth -anchor w
  884.     entry .os.sopts.s13.e -width $ewidth -textvariable tko_shellmeta \
  885.         -relief raised
  886.     pack append .os.sopts.s13 \
  887.         .os.sopts.s13.l {left} .os.sopts.s13.e {left frame w}
  888.  
  889.     frame .os.sopts.s14
  890.     label .os.sopts.s14.l -text "tags:" -width $lwidth -anchor w
  891.     entry .os.sopts.s14.e -width $ewidth -textvariable tko_tags \
  892.         -relief raised
  893.     pack append .os.sopts.s14 \
  894.         .os.sopts.s14.l {left} .os.sopts.s14.e {left frame w}
  895.  
  896.     frame .os.sopts.s15
  897.     label .os.sopts.s15.l -text "term:" -width $lwidth -anchor w
  898.     entry .os.sopts.s15.e -width $ewidth -textvariable tko_term \
  899.         -relief raised
  900.     pack append .os.sopts.s15 \
  901.         .os.sopts.s15.l {left} .os.sopts.s15.e {left frame w}
  902.  
  903.     pack append .os.sopts \
  904.         .os.sopts.s1 {top expand fillx} \
  905.         .os.sopts.s2 {top expand fillx} \
  906.         .os.sopts.s3 {top expand fillx} \
  907.         .os.sopts.s4 {top expand fillx} \
  908.         .os.sopts.s5 {top expand fillx} \
  909.         .os.sopts.s6 {top expand fillx} \
  910.         .os.sopts.s7 {top expand fillx} \
  911.         .os.sopts.s8 {top expand fillx} \
  912.         .os.sopts.s9 {top expand fillx} \
  913.         .os.sopts.s10 {top expand fillx} \
  914.         .os.sopts.s11 {top expand fillx} \
  915.         .os.sopts.s12 {top expand fillx} \
  916.         .os.sopts.s13 {top expand fillx} \
  917.         .os.sopts.s14 {top expand fillx} \
  918.         .os.sopts.s15 {top expand fillx}
  919.  
  920.     # Build frame for continue button.
  921.     frame .os.control -bd 4
  922.     button .os.control.quit -text "Continue" -command "destroy .os"
  923.     bind .os <Return> ".os.control.quit flash; destroy .os"
  924.     pack append .os.control .os.control.quit {left}
  925.  
  926.     # Pack everything together.
  927.     pack append .os \
  928.         .os.bopts {top} \
  929.         .os.control {bottom fillx} \
  930.         .os.nopts {left fillx padx 4m pady 4m} \
  931.         .os.sopts {left fillx pady 4m}
  932.  
  933.     grab .os
  934.     focus .os
  935. }
  936.  
  937. # tk_opt_ew --
  938. #    Handle a change to an option entry widget.
  939. proc tk_opt_ew {name element op} {
  940.     upvar $name x
  941.     tk_opt_set "$name=$x"
  942. }
  943.  
  944. # tk_err --
  945. #    Display a Tcl/Tk error message.
  946. proc tk_err {msg} {
  947.     tk_dialog .d {} "$msg" {} 0 Continue
  948.  
  949.     #puts "msg: $msg"
  950. }
  951.  
  952. # tk_addstr --
  953. #    Add a string to the screen.
  954. proc tk_addstr {len str} {
  955.     global tk_cursor_row
  956.     global tk_cursor_col
  957.     
  958.     # Delete the current characters, then insert the new ones.
  959.     .t mark set insert $tk_cursor_row.$tk_cursor_col
  960.     .t delete insert "insert + $len chars"
  961.     .t insert insert "$str"
  962.     incr tk_cursor_col $len
  963.  
  964.     #puts "tk_addstr: row $tk_cursor_row col $tk_cursor_col: insert $str"
  965. }
  966.  
  967. # tk_clrtoeol --
  968. #    Clear to the end of the line.
  969. proc tk_clrtoeol {} {
  970.     global tk_cursor_row
  971.     global tk_cursor_col
  972.     global tk_ssize_col
  973.  
  974.     # Overwrite to the end of the line with spaces.
  975.     .t mark set insert $tk_cursor_row.$tk_cursor_col
  976.     .t delete insert "insert lineend"
  977.     for {set j $tk_cursor_col} {$j < $tk_ssize_col} {incr j} {
  978.         .t insert insert " "
  979.     }
  980.  
  981.     #puts "tk_clrtoel: row $tk_cursor_row col $tk_cursor_col"
  982. }
  983.  
  984. # tk_deleteln --
  985. #    Delete the line.
  986. proc tk_deleteln {} {
  987.     global tk_cursor_row
  988.     global tk_cursor_col
  989.     global tk_ssize_col
  990.  
  991.     # Delete the line.
  992.     .t mark set insert $tk_cursor_row.$tk_cursor_col
  993.     .t delete insert "insert lineend + 1 chars"
  994.  
  995.     # Append a new, blank line at the end of the screen.
  996.     .t mark set insert end
  997.     for {set j 1} {$j <= $tk_ssize_col} {incr j} {
  998.         .t insert insert " "
  999.     }
  1000.     .t insert insert "\n"
  1001.  
  1002.     #puts "tk_deleteln: row $tk_cursor_row"
  1003. }
  1004.  
  1005. # tk_flash --
  1006. #    Flash the screen.
  1007. proc tk_flash {} {
  1008.     set bg [lindex [.t config -background] 4]
  1009.     set fg [lindex [.t config -foreground] 4]
  1010.     .t configure -background $fg -foreground $bg
  1011.     update idletasks
  1012.     .t configure -background $bg -foreground $fg
  1013.     update idletasks
  1014. }
  1015.  
  1016. # tk_insertln --
  1017. #    Insert the line.
  1018. proc tk_insertln {} {
  1019.     global tk_cursor_row
  1020.     global tk_cursor_col
  1021.     global tk_ssize_row
  1022.     global tk_ssize_col
  1023.  
  1024.     # Delete the last line on the screen.
  1025.     .t mark set insert $tk_ssize_row.0
  1026.     .t delete insert "insert lineend + 1 chars"
  1027.  
  1028.     # Insert a new, blank line.
  1029.     .t mark set insert $tk_cursor_row.$tk_cursor_col
  1030.     for {set j 1} {$j <= $tk_ssize_col} {incr j} {
  1031.         .t insert insert " "
  1032.     }
  1033.     .t insert insert "\n"
  1034.  
  1035.     #puts "tk_insertln: row $tk_cursor_row"
  1036. }
  1037.  
  1038. # tk_move --
  1039. #    Move the cursor.
  1040. proc tk_move {row col} {
  1041.     global tk_cursor_row
  1042.     global tk_cursor_col
  1043.  
  1044.     # Convert to Tcl/Tk coordinates, update the insert cursor.
  1045.     set tk_cursor_row [ expr $row + 1 ]
  1046.     set tk_cursor_col $col
  1047.     .t mark set insert $tk_cursor_row.$tk_cursor_col
  1048.  
  1049.     # Update the screen cursor.
  1050.     .t tag remove tk_cursor tk_cursor_indx
  1051.     .t mark set tk_cursor_indx insert
  1052.     .t tag add tk_cursor tk_cursor_indx
  1053.  
  1054.     #puts "tk_move: row $tk_cursor_row col $tk_cursor_col"
  1055. }
  1056.  
  1057. # tk_rename --
  1058. #    Rename the screen.
  1059. proc tk_rename {name} {
  1060.     wm title . "$name"
  1061. }
  1062.  
  1063. # tk_ssize --
  1064. #    Return the window size.
  1065. proc tk_ssize {} {
  1066.     global tk_ssize_col
  1067.     global tk_ssize_row
  1068.  
  1069.     set s [ .t configure -width ]
  1070.     set tk_ssize_col [ lindex $s [ expr [ llength $s ] -1 ] ]
  1071.     set s [ .t configure -height ]
  1072.     set tk_ssize_row [ lindex $s [ expr [ llength $s ] -1 ] ]
  1073.  
  1074.     #puts "tk_ssize: rows $tk_ssize_row, cols $tk_ssize_col"
  1075. }
  1076.  
  1077. # tk_standout --
  1078. #    Change into standout mode.
  1079. proc tk_standout {} {
  1080. }
  1081.  
  1082. # tk_standend --
  1083. #    Change out of standout mode.
  1084. proc tk_standend {} {
  1085. }
  1086.  
  1087. # Cursor
  1088. set tk_cursor_row    1
  1089. set tk_cursor_col    0
  1090.  
  1091. # Screen size
  1092. set tk_ssize_row    0
  1093. set tk_ssize_col    0
  1094.  
  1095. screen
  1096. #tkwait window .
  1097.