# From the Tcl Wiki

#------------------------------------------------------
#  Tkcon isn't packaged in a library, so we have to
#  source the code, but it provides a package, and
#  the commands [tkcon show] and [tkcon hide]
#------------------------------------------------------

source lib/tkcon.tcl
package require tkcon

#------------------------------------------------------
#  The console doesn't exist yet.  If we create it
#  with show/hide, then it flashes on the screen.
#  So we cheat, and call tkcon internals to create
#  the console and customize it to our application.
#------------------------------------------------------

set tkcon::PRIV(showOnStartup) 0
set tkcon::PRIV(root) .console
set tkcon::PRIV(protocol) {tkcon hide}
set tkcon::OPT(exec) ""
tkcon::Init
tkcon title "JStrack Console"

wm protocol .console WM_DELETE_WINDOW { set tkcon_up 0 ; tkcon hide }
set tkcon_up 0
tkcon hide

proc toggle_tkcon {} {
   if {[winfo ismapped .console]} {
      catch { tkcon hide }
   } else {
      catch {
         wm geometry .console +200+200 ; tkcon show
         wm attributes .console -topmost true
      }
   }
}


