#!/usr/local/bin/wish -f
# jedit - Tk-based text editor
# 
# Copyright 1992-1994 by Jay Sekora.  All rights reserved, except 
# that this file may be freely redistributed in whole or in part 
# for non-profit, noncommercial use.

## begin boiler_header

global VERSION
set VERSION {3.6/3.0}

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

# 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

# TO DO
#   abbrev fixes:
#     maybe some heuristics for things like plurals
#     maybe a syntax for suffixes (e.g., commit;t -> commitment)
#   file_modes panel
#   documentation for keybindings (automatic documentation?)
#   problem with filename getting set when you cancel Save 
#     for the first time on a new unnamed file
#   improve find panel
#     have find wrap around (if last time didn't match)
#     regex search/replace
#     find all at once (mark) and cycle through with tag nextrange
#   gesture commands
#   autobreaking space a problem if you use two spaces betw sentences
#   word-end punctuation (and heuristics) sd be mode-specific
#
#   PROBLEM WITH CHANGING BINDINGS ON THE FLY!               (urgent)

# CHANGES:
#   lots of binding changes (jbind*.tcl consistency)
#     app-specific Emacs and vi bindings
#   house(s) the s won't expand
#   return key checkpoints!
#   improved mode handling (hooks)

######################################################################
# 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}
}

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.)
# 
if {$argc > 0} {			;# multiple filenames specified
  foreach file $argv {
    jedit:jedit -mode $mode -file $file
  }
} else {				;# argc <= 0; no filenames specified
  jedit:jedit -mode $mode
}
