#!/usr/local/bin/wish4.2
# jedit - Tk-based text editor
#
######################################################################
# Copyright 1992-1997 by Jay Sekora.  This file may be freely distributed,
# modified or unmodified, for any purpose, provided that this copyright
# notice is retained verbatim in all copies and no attempt is made to
# obscure the authorship of this file.  If you distribute any modified
# versions, I ask, but do not require, that you clearly mark any changes
# you make as such and that you provide your users with instructions for
# getting the original sources.
######################################################################
## begin boiler_header

if {[info exists env(JSTOOLS_LIB)]} {
  set jstools_library $env(JSTOOLS_LIB)
} else {
  set jstools_library /home/js/jstools/lib
}

# add the jstools library to the library search path:

set auto_path [concat [list $jstools_library] $auto_path]

# check for ~/.tk and prepend it to the auto_path if it exists.
# that way the user can override and customise the jstools libraries.

if {[file isdirectory ~/.tk]} then {
  set auto_path [concat [list [glob ~/.tk]] $auto_path]
}

## end boiler_header

######################################################################
# all procedure definitions are autoloaded
######################################################################

# we're not using the main window
#
wm withdraw .

# process arguments, if any

j:parse_argv {
  {mode default}
  {for NONE}
  {width {}}
  {height {}}
}

set JEDIT_CALLER $for			;# used if we use send to communicate
					;# with a calling application

# open windows---note that the name of the first window will end up
# being ".jedit0" (subsequent windows ".jedit1" etc.)
# 
set line {}				;# this tells jedit:jedit not to jump
					;# (may be different from specifying 0
					;# if tags/marks are saved)
if {$argc > 0} {			;# multiple filenames specified
  foreach file $argv {
    if [string match +* $file] {	;# then it's really a position instead
      set line [string trimleft $file +]
    } else {
      jedit:jedit -width $width -height $height -mode $mode -line $line \
        -file $file
      set line {}			;# reset for following files
    }
  }
} else {				;# argc <= 0; no filenames specified
  jedit:jedit -width $width -height $height -mode $mode
}







