#!/usr/local/bin/wish -f
## begin boiler_header

global VERSION
set VERSION {3.6/2.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

j:jstools_init

frame .emacs
label .emacs.l -text emacs
entry .emacs.e -relief sunken
text .emacs.t -height 10 -yscroll {.emacs.s set}
scrollbar .emacs.s -command {.emacs.t yview}
pack .emacs.l .emacs.e -side top -fill x
pack .emacs.t .emacs.s -side right -fill y

frame .vi
label .vi.l -text vi
entry .vi.e -relief sunken
text .vi.t -height 10 -yscroll {.vi.s set}
scrollbar .vi.s -command {.vi.t yview}
pack .vi.l .vi.e -side top -fill x
pack .vi.t .vi.s -side right -fill y

frame .edt
label .edt.l -text edt
entry .edt.e -relief sunken
text .edt.t -height 10 -yscroll {.edt.s set}
scrollbar .edt.s -command {.edt.t yview}
pack .edt.l .edt.e -side top -fill x
pack .edt.t .edt.s -side right -fill y

frame .basic
label .basic.l -text basic
entry .basic.e -relief sunken
text .basic.t -height 10 -yscroll {.basic.s set}
scrollbar .basic.s -command {.basic.t yview}
pack .basic.l .basic.e -side top -fill x
pack .basic.t .basic.s -side right -fill y

pack \
  .emacs \
  [j:rule .] \
  .vi \
  [j:rule .] \
  .edt \
  [j:rule .] \
  .basic \
  -fill x


j:tb:emacs_init .emacs.t
j:eb:emacs_init .emacs.e

j:tb:vi_init .vi.t
j:eb:vi_init .vi.e

j:tb:basic_init .basic.t
j:eb:basic_init .basic.e

j:eb:edt_init .edt.e
j:tb:edt_init .edt.t

.basic.e insert end {Why don't text mouse bindings work?}

.emacs.t insert insert [j:fileio:read /etc/passwd]
.vi.t insert insert [j:fileio:read /etc/sendmail.cf]
.edt.t insert insert [j:fileio:read /etc/services]
.basic.t insert insert [j:fileio:read /etc/hosts]

j:tkb:mkmap .vi.t vi-command vi-command {
  {q			exit 0 ;#}
}
