#!/usr/local/bin/wish4.2
set zircon(lib) [pwd]
#
#	ZIRCON - an X11 interface to the Internet Relay Chat
#
#	Written by Lindsay (Lindsay F. Marshall)
#
#	Copyright (c) 1993, 1994, 1995, 1996
#
#	See the file COPYRIGHT for details
#
if {[string match {7.[567]} [info tclversion]] &&
   ![string match {} [info commands socket]]} {
    set auto_path [linsert $auto_path 0 [file join $zircon(lib) lib]]
    source [file join $zircon(lib) lib interp tcl[info tclversion].tcl]
#
    switch $tcl_platform(platform) {
    macintosh { source [file join $zircon(lib) lib platform Macintosh.tcl] }
    unix -
    default { source [file join $zircon(lib) lib platform Unix.tcl] }
    }
} \
elseif [info exists dp_version] {
    set auto_path [linsert $auto_path 0 $zircon(lib)/lib]
    source $zircon(lib)/lib/interp/tcldp.tcl
    source $zircon(lib)/lib/Unix.tcl
} \
elseif {[info exists tclx_library] && [infox have_sockets]} {
    set auto_path [linsert $auto_path 0 $zircon(lib)/lib]
    source $zircon(lib)/lib/interp/tclx.tcl
    source $zircon(lib)/lib/Unix.tcl
} {
    tk_dialog .err Error \
      {*** Your tcl/tk interpreter does not have a suitable networking extension!!} \
      error 0 OK
    exit 1
}
set USINGIRC 0
#
wm withdraw .
#
foreach ty {Entry Text Button} {
    foreach x [bind $ty] { bind $ty $x {+ notIdle %W} }
}
#
Initialise
set current(net) [Net default]
InitGlobals
#
# save some space!!! it will reload if necessary.
#
rename Initialise {}
rename InitGlobals {}
#
if $zircon(C) {
    $current(net) show
    if {$zircon(C) == 2} {
	mkInfoBox WARNING .@h$current(net) {Server Host Error} \
	  {No server selected for this network. Use the "Server"\
menu button to select one.}
    }
} \
elseif {[string compare [set hst [$current(net) hostid]] nil]} {
    set s [$current(net) servers]
    set v [lsearch $s $hst]
    listdel s $v
    while {![$current(net) startIRC]} {
	if [string match {} $s] break
	$current(net) configure -hostid [lindex $s 0]
	set s [lrange $s 1 end]
	update
    }
}
