#
# A X11 multi-window text editor based on TK/TCL
#  keybindings are Emacs-like
#
# Dave Clemans: 5/29
# dave_clemans@mentorg.com
#

#
# Establish a basic runtime environment, get our utilities, etc.
#
set tke_library [file dirname [info script]]
source $tke_library/utils.tk

#
# get a file selector
#
source $tke_library/tkfs.tk

#
# the editor itself
#
source $tke_library/tkedit.tk

wm withdraw .

#
# Set up any additional requested windows
#
set tkeGeometry ${tkutWindowCols}x${tkutWindowRows}
if {[info globals geometry] != ""} {
   if {"$geometry" != ""} {
      set tkeGeometry $geometry
      scan $tkeGeometry %dx%d tkutWindowCols tkutWindowRows
   }
}
set tkeFirstWindow ""
for {set ai 0} {$ai < $argc} {incr ai} {
   set av [lindex $argv $ai]
   case "$av" in {
      -g* {
         incr ai
         set tkeGeometry [lindex $argv $ai]
         scan $tkeGeometry %dx%d tkutWindowCols tkutWindowRows
      }
      default {
         set w [tkeEditFile dummy $av]
         if {"$tkeFirstWindow" == ""} {
            wm geometry $w $tkeGeometry
            set tkeFirstWindow $w
         } else {
            wm geometry $w ${tkutWindowCols}x${tkutWindowRows}
         }
      }
   }
}
if {"$tkeFirstWindow" == ""} {
   set w [tkeEditFile dummy "*UNNAMED*"]
   wm geometry $w $tkeGeometry
}

#
# and wait for termination
#
tkutWaitForNoWindows
exit 0
