#!/usr/bin/env wish8.3
# jdoc - multi-font document display
#
###############################################################################
#  Copyright 1992-2001 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(AQTOOLS_LIB)]} {
  set aq_library $env(AQTOOLS_LIB)
  set aq_pkg [file join $env(AQTOOLS_LIB) pkg]
} else {
  set aq_library /usr/lib/aq
  set aq_pkg [file join $aq_library pkg]
}

# add the aq library to the library search path:

set auto_path  [concat  [list $aq_pkg]  [list $aq_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 aq libraries.

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

## end boiler_header

# the import IS A BIG PROBLEM until this whole file gets wrapped in its own
# namespace:

catch {
  package require jldb
  # following likely to fail, because done by other libraries too
  namespace import ::jldb::shortcuts::*
}

catch {
  package require aq
  namespace eval ::aq { }			;# so namespace is defined
}

##############################################################################
# FINAL SETUP
##############################################################################

jdoc:init


###############################################################################
###############################################################################
### WHY DOES THIS HAVE TO BE HERE?  IT'S CALLED IN ::aq::aq_init! ###
###############################################################################
###############################################################################

                        # set user's text bindings:
                        global J_PREFS
                        switch -exact $J_PREFS(bindings) {
                          basic {
                            j:eb:basic_bind Entry
                          }
                          emacs {
                            j:eb:emacs_bind Entry
                          }
                          vi {
                            j:eb:vi_bind Entry
                          }
                        }

# read in user's .tk/aqdocrc.tcl and .tk/aqdoc-defaults files:
#
j:source_config aqdocrc.tcl		;# just source the file, if any
j:read_global_prefs			;# get defaults from ~/.tk/defaults
j:read_prefs -array JDOC_PREFS -file aqdoc-defaults {
  {textwidth 70}
  {textheight 24}
  {textwrap char}
  {textbg white}
  {textfg black}
  {textsb black}
  {textsf white}
  {textbw 2}
  {textsbw 2}
  {tkman 0}
}

jdoc:mkmenus
jdoc:mkbuttons
jdoc:mktext					;# (sets focus)
jdoc:first_doc_file				;# read in first help file

