"#!/usr/local/bin/wish -f\n"
"###############################################################################\n"
"#\n"
"# This Tcl script gets the setup information for the m68681 DUART device.\n"
"#\n"
"# Notes: - All Procedures and global variables begin with \"DeviceSetup\".  This\n"
"#          should be true for all device scripts.\n"
"#        - The toplevel window should be .device for all device scripts.\n"
"#        - The script must return a valid argument for the device's\n"
"#          constructor.\n"
"#\n"
"#        - If the cancel button is pressed the empty string should be\n"
"#          returned\n"
"#        - All device scripts should be modal dialogs\n"
"#\n"
"# Copyright (c) 1993\n"
"# By: Bradford W. Mott\n"
"# November 26,1993\n"
"#\n"
"###############################################################################\n"
"# $Id: M68681.tcl,v 1.1 1996/08/02 15:02:11 bwmott Exp $\n"
"###############################################################################\n"
"###############################################################################\n"
"# This procedure builds the argument for the device's constructor\n"
"###############################################################################\n"
"proc DeviceSetupGetValues {} {\n"
"  global DevicePortAStd\n"
"  global DevicePortBStd\n"
"  set base [.device.base.entry get]\n"
"  set offset_to_first [.device.offsetToFirst get]\n"
"  set offset_between [.device.offsetBetween get]\n"
"  set interrupt_level [.device.interruptLevel get]\n"
"  set port_a_command [.device.portA.entry get]\n"
"  if {$DevicePortAStd == 1} {set port_a_std 1} else {set port_a_std 0}\n"
"  set port_b_command [.device.portB.entry get] \n"
"  if {$DevicePortBStd == 1} {set port_b_std 1} else {set port_b_std 0}\n"
"  set result \"BaseAddress = $base OffsetToFirstRegister = $offset_to_first OffsetBetweenRegisters = $offset_between InterruptLevel = $interrupt_level PortAStandardInputOutputFlag = $port_a_std PortBStandardInputOutputFlag = $port_b_std PortACommand = $port_a_command PortBCommand = $port_b_command\"\n"
"  return \"$result\"\n"
"}\n"
"###############################################################################\n"
"# Make sure they entered a good address\n"
"###############################################################################\n"
"proc DeviceSetupCheckValues {} {\n"
"  set base [.device.base.entry get]\n"
"  if {[regexp {^[0-9A-Fa-f]+$} $base]} {\n"
"    destroy .device \n"
"  }\n"
"}\n"
"###############################################################################\n"
"# This is the procedure the User Interface calls\n"
"###############################################################################\n"
"proc DeviceSetup {} {\n"
"  global DeviceSetupReturnValue\n"
"  global DevicePortAStd\n"
"  global DevicePortBStd\n"
"  catch {destroy .device}\n"
" \n"
"  toplevel .device\n"
"  wm title .device \"M68681 Setup\"\n"
"  wm iconname .device \"M68681 Setup\"\n"
"  message .device.message \
    -text \"Please enter appropriate values for the M68681's options\" \
    -width 4i -justify left -relief raised -pady 4\n"
"  frame .device.base -relief groove -borderwidth 2\n"
"    label .device.base.label -text \"Base Address:\"\n"
"    entry .device.base.entry -width 10 -relief sunken\n"
"    bind .device.base.entry <Return> { focus .device.portA.entry }\n"
"    pack .device.base.label -side left\n"
"    pack .device.base.entry -side left -fill x -expand 1 -pady 2 -padx 2\n"
"  scale .device.offsetToFirst -from 0 -to 8 -showvalue 0 -orient horizontal \
      -tickinterval 1 -relief groove -label \"Offset to first register (MRxA):\" \n"
"  scale .device.offsetBetween -from 1 -to 8 -showvalue 0 -orient horizontal \
      -tickinterval 1 -relief groove -label \"Offset between registers:\"\n"
"  scale .device.interruptLevel -from 1 -to 7 -showvalue 0 -orient horizontal \
      -tickinterval 1 -relief groove -label \"Interrupt level:\"\n"
"  frame .device.portA -relief groove -borderwidth 2 \n"
"    label .device.portA.label -text \"Port A Command:\"\n"
"    entry .device.portA.entry -width 10 -relief sunken\n"
"    bind .device.portA.entry <Return> { focus .device.portB.entry }\n"
"    checkbutton .device.portA.stdin -relief flat -variable DevicePortAStd \
        -text \"Attach port to command's STDIN/STDOUT?\"\n"
"    pack .device.portA.stdin -side bottom -fill x -expand 1\n"
"    pack .device.portA.label -side left\n"
"    pack .device.portA.entry -side left -fill x -expand 1 -pady 4 -padx 4\n"
"  frame .device.portB -relief groove -borderwidth 2 \n"
"    label .device.portB.label -text \"Port B Command:\"\n"
"    entry .device.portB.entry -width 10 -relief sunken\n"
"    bind .device.portB.entry <Return> { focus .device.base.entry }\n"
"    checkbutton .device.portB.stdin -relief flat -variable DevicePortBStd \
        -text \"Attach port to command's STDIN/STDOUT?\"\n"
"    pack .device.portB.stdin -side bottom -fill x -expand 1\n"
"    pack .device.portB.label -side left\n"
"    pack .device.portB.entry -side left -fill x -expand 1 -pady 4 -padx 4\n"
"  frame .device.buttons\n"
"    button .device.buttons.ok -text \"Okay\" \
      -command {set DeviceSetupReturnValue [DeviceSetupGetValues]\n"
"                DeviceSetupCheckValues}\n"
"    button .device.buttons.cancel -text \"Cancel\" \
      -command {set DeviceSetupReturnValue \"\"; destroy .device}\n"
"    pack .device.buttons.ok -side left -expand 1 -fill x -padx 4\n"
"    pack .device.buttons.cancel -side right -expand 1 -fill x -padx 4\n"
"  pack .device.message -side top -fill x -pady 4 -padx 4\n"
"  pack .device.base -side top -fill x -pady 4 -padx 4\n"
"  pack .device.offsetToFirst -side top -fill x -pady 4 -padx 4 \
      -ipadx 4 -ipady 4\n"
"  pack .device.offsetBetween -side top -fill x -pady 4 -padx 4 \
      -ipadx 4 -ipady 4\n"
"  pack .device.interruptLevel -side top -fill x -pady 4 -padx 4 \
      -ipadx 4 -ipady 4\n"
"  pack .device.portA -side top -fill x -pady 4 -padx 4\n"
"  pack .device.portB -side top -fill x -pady 4 -padx 4\n"
"  pack .device.buttons -side top -fill x -pady 4\n"
"  # Set some defaults\n"
"  .device.offsetToFirst set 1\n"
"  .device.offsetBetween set 2\n"
"  .device.interruptLevel set 4\n"
"  set DevicePortAStd 0\n"
"  set DevicePortBStd 0\n"
"  # Set focus to the first entry widget\n"
"  tkwait visibility .device\n"
"  focus .device.base.entry\n"
"  # Make this a modal dialog\n"
"  grab set .device\n"
"  tkwait window .device\n"
"  return $DeviceSetupReturnValue\n"
"}\n"
