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
|
# Copyright (C) 1987-2005 by Jeffery P. Hansen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Last edit by hansen on Wed Apr 19 17:05:18 2000
#
#
# List of ttys
#
set tkg_ttylist {}
image create bitmap txtcurs -file "$bd/txtcurs.b"
proc tkg_mktty {n} {
global tkg_ttys tkg_ttygat tkg_ttylist
set i 0
set w ""
while { [catch { set w [toplevel .tty$i] }] } {
incr i
}
set tkg_ttys($n) $w
set tkg_ttygat($w) $n
lappend tkg_ttylist $w
wm resizable $w 0 0
wm title $w "TkGate: TTY $n"
wm geometry $w [offsetgeometry . [expr 50 * ( $i + 1 )] [expr 50 * ( $i + 1 )]]
text $w.txt -state disabled
pack $w.txt
$w.txt image create end -image txtcurs
bind $w <KeyPress> " if { \[string length %A \] > 0 } { scan %A %%c c; tkg_simWrite \"command $tkg_ttygat($w) key \$c\" } "
}
proc tkg_rmttys {} {
global tkg_ttys tkg_ttygat tkg_ttylist
catch {
unset tkg_ttys
unset tkg_ttygat
foreach t $tkg_ttylist {
destroy $t
}
}
}
proc tkg_ttyChar {n c} {
global tkg_ttys
set w $tkg_ttys($n)
if { $c == 7 } {
bell
return
} elseif { $c == 127 } {
$w.txt configure -state normal
$w.txt delete "end - 3 chars"
$w.txt see end
$w.txt configure -state disabled
return
}
set x [format %c $c]
$w.txt configure -state normal
$w.txt insert "end - 2 chars" $x
$w.txt see end
$w.txt configure -state disabled
}
|