Work on target setup in client.tcl.
[ir-tcl-moved-to-github.git] / client.tcl
index 7b528c9..f08a26b 100644 (file)
@@ -4,7 +4,40 @@
 # Sebastian Hammer, Adam Dickmeiss
 #
 # $Log: client.tcl,v $
-# Revision 1.70  1995-10-12 14:46:52  adam
+# Revision 1.80  1995-10-18 17:20:32  adam
+# Work on target setup in client.tcl.
+#
+# Revision 1.79  1995/10/18  16:42:37  adam
+# New settings: smallSetElementSetNames and mediumSetElementSetNames.
+#
+# Revision 1.78  1995/10/18  15:45:36  quinn
+# *** empty log message ***
+#
+# Revision 1.77  1995/10/18  15:37:46  adam
+# Piggy-back present.
+#
+# Revision 1.76  1995/10/18  15:15:20  adam
+# Fixed bug.
+#
+# Revision 1.75  1995/10/17  14:18:05  adam
+# Minor changes in presentation formats.
+#
+# Revision 1.74  1995/10/17  12:18:57  adam
+# Bug fix: when target connection closed, the connection was not
+# properly reestablished.
+#
+# Revision 1.73  1995/10/17  10:58:06  adam
+# More work on presentation formats.
+#
+# Revision 1.72  1995/10/16  17:00:52  adam
+# New setting: elementSetNames.
+# Various client improvements. Medium presentation format looks better.
+#
+# Revision 1.71  1995/10/13  15:35:27  adam
+# Relational operators may be used in search entries - changes
+# in proc index-query.
+#
+# Revision 1.70  1995/10/12  14:46:52  adam
 # Better record popup windows. Next/prev buttons in popup record windows.
 # The record position in the raw format is much more visible.
 #
@@ -313,6 +346,7 @@ set displayFormat 1
 set popupMarcdf 0
 set textWrap word
 set recordSyntax None
+set elementSetNames None
 set delayRequest {}
 
 set queryTypes {Simple}
@@ -369,6 +403,7 @@ proc set-wrap {m} {
 }
 
 proc dputs {m} {
+    puts $m
 }
 
 proc set-display-format {f} {
@@ -774,6 +809,16 @@ proc popup-marc {sno no b df} {
                 -font -Adobe-Times-Medium-R-Normal-*-180-* \
                 -background black -foreground white
 
+        $w.top.record tag configure marc-pref \
+                -font -Adobe-Times-Medium-R-Normal-*-180-* \
+                -foreground blue
+        $w.top.record tag configure marc-text \
+                -font -Adobe-Times-Medium-R-Normal-*-180-* \
+                -foreground black
+        $w.top.record tag configure marc-it \
+                -font -Adobe-Times-Medium-I-Normal-*-180-* \
+                -foreground black
+
         pack $w.top.s -side right -fill y
         pack $w.top.record -expand yes -fill both
         
@@ -1045,6 +1090,7 @@ proc init-response {} {
     global cancelFlag
     global scanEnable
 
+    dputs {init-reponse}
     if {$cancelFlag} {
         close-target
         return
@@ -1073,9 +1119,13 @@ proc search-request {bflag} {
     global cancelFlag
     global delayRequest
     global recordSyntax
+    global elementSetNames
 
     set target $hostid
 
+    if {[z39 connect] == ""} {
+        return
+    }
     dputs "search-request"
     show-message {}
     if {!$bflag && $busy} {
@@ -1118,6 +1168,15 @@ proc search-request {bflag} {
     } else {
         z39.$setNo preferredRecordSyntax $recordSyntax
     }
+    if {$elementSetNames == "None" } {
+        z39.$setNo elementSetNames {}
+        z39.$setNo smallSetElementSetNames {}
+        z39.$setNo mediumSetElementSetNames {}
+    } else {
+        z39.$setNo elementSetNames $elementSetNames
+        z39.$setNo smallSetElementSetNames $elementSetNames
+        z39.$setNo mediumSetElementSetNames $elementSetNames
+    }
     z39 callback {search-response}
     z39.$setNo search $query
     show-status Searching 1 0
@@ -1437,6 +1496,10 @@ proc search-response {} {
     if {$setMax > 20} {
         set setMax 20
     }
+    set no [z39.$setNo numberOfRecordsReturned]
+    dputs "Returned $no records, setOffset $setOffset"
+    add-title-lines $setNo $no $setOffset
+    set setOffset [expr $setOffset + $no]
     z39 callback {present-response}
     z39.$setNo present $setOffset 1
     show-status Retrieving 1 0
@@ -1503,12 +1566,14 @@ proc add-title-lines {setno no offset} {
     global setNo
     global busy
 
+    dputs "add-title-lines offset=${offset} no=${no}"
     if {$setno != -1} {
         set setNo $setno
     } else {
         set setno $setNo
     }
     if {$offset == 1} {
+        
         .bot.a.set configure -text $setno
         .data.record delete 0.0 end
     }
@@ -1519,6 +1584,7 @@ proc add-title-lines {setno no offset} {
         set o [expr $i + $offset]
         set type [z39.$setno type $o]
         if {$type == ""} {
+            dputs "no more at $o"
             break
         }
         .data.record tag bind r$o <Any-Enter> {}
@@ -1647,15 +1713,13 @@ proc define-target-dialog {} {
     top-down-ok-cancel $w {define-target-action} 1
 }
 
-proc protocol-setup-delete {target} {
+proc protocol-setup-delete {target w} {
     global profile
     global settingsChanged
 
     set a [alert "Are you sure you want to delete the target \
 definition $target ?"]
     if {$a} {
-        set wno [lindex $profile($target) 12]
-        set w .setup-${wno}
         destroy $w
         unset profile($target)
         set settingsChanged 1
@@ -1664,7 +1728,7 @@ definition $target ?"]
     }
 }
 
-proc protocol-setup-action {target} {
+proc protocol-setup-action {target w} {
     global profile
     global csRadioType
     global protocolRadioType
@@ -1673,15 +1737,14 @@ proc protocol-setup-action {target} {
     global CCLCheck
     global ResultSetCheck
 
-    set wno [lindex $profile($target) 12]
-    set w .setup-${wno}
-    
     set b {}
     set settingsChanged 1
     set len [$w.top.databases.list size]
     for {set i 0} {$i < $len} {incr i} {
         lappend b [$w.top.databases.list get $i]
     }
+    set wno [lindex $profile($target) 12]
+
     set profile($target) [list [$w.top.description.entry get] \
             [$w.top.host.entry get] \
             [$w.top.port.entry get] \
@@ -1713,26 +1776,22 @@ proc place-force {window parent} {
     wm geometry $window +${x}+${y}
 }
 
-proc add-database-action {target} {
+proc add-database-action {target w} {
     global profile
 
-    set wno [lindex $profile($target) 12]
-    set w .setup-${wno}
-
     $w.top.databases.list insert end \
             [.database-select.top.database.entry get]
     destroy .database-select
 }
 
-proc add-database {target} {
+proc add-database {target wp} {
     global profile
 
     set w .database-select
     toplevel $w
     set oldFocus [focus]
  
-    set wno [lindex $profile($target) 12]
-    place-force $w .setup-${wno}
+    place-force $w $wp
 
     top-down-window $w
 
@@ -1742,17 +1801,15 @@ proc add-database {target} {
     
     entry-fields $w.top {database} \
             {{Database to add:}} \
-            [list add-database-action $target] {destroy .database-select}
+            [list add-database-action $target $wp] {destroy .database-select}
 
-    top-down-ok-cancel $w [list add-database-action $target] 1
+    top-down-ok-cancel $w [list add-database-action $target $wp] 1
     focus $oldFocus
 }
 
-proc delete-database {target} {
+proc delete-database {target w} {
     global profile
 
-    set wno [lindex $profile($target) 12]
-    set w .setup-${wno}
     set l {}
     foreach i [$w.top.databases.list curselection] {
         set b [$w.top.databases.list get $i]
@@ -1774,9 +1831,12 @@ proc protocol-setup {target} {
     global RPNCheck
     global CCLCheck
     global ResultSetCheck
-
-    set wno [lindex $profile($target) 12]
-    set w .setup-${wno}
+    
+    set bno 0
+    while {[winfo exists .setup-$bno]} {
+        incr bno
+    }
+    set w .setup-$bno
 
     toplevelG $w
 
@@ -1810,13 +1870,13 @@ proc protocol-setup {target} {
             maximumRecordSize preferredMessageSize} \
             {{Description:} {Host:} {Port:} {Id Authentication:} \
             {Maximum Record Size:} {Preferred Message Size:}} \
-            [list protocol-setup-action $target] [list destroy $w]
+            [list protocol-setup-action $target $w] [list destroy $w]
     
     foreach sub {description host port idAuthentication \
             maximumRecordSize preferredMessageSize} {
         dputs $sub
-        bind $w.top.$sub.entry <Control-a> [list add-database $target]
-        bind $w.top.$sub.entry <Control-d> [list delete-database $target]
+        bind $w.top.$sub.entry <Control-a> [list add-database $target $w]
+        bind $w.top.$sub.entry <Control-d> [list delete-database $target $w]
     }
     $w.top.description.entry insert 0 [lindex $profile($target) 0]
     $w.top.host.entry insert 0 [lindex $profile($target) 1]
@@ -1837,10 +1897,10 @@ proc protocol-setup {target} {
     pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
 
     label $w.top.databases.label -text "Databases"
-    button $w.top.databases.add -text "Add" \
-            -command [list add-database $target]
-    button $w.top.databases.delete -text "Delete" \
-            -command [list delete-database $target]
+    button $w.top.databases.add -text Add \
+            -command [list add-database $target $w]
+    button $w.top.databases.delete -text Delete \
+            -command [list delete-database $target $w]
     if {! [tk4]} {
         listbox $w.top.databases.list -geometry 14x6 \
                 -yscrollcommand "$w.top.databases.scroll set"
@@ -1900,11 +1960,61 @@ proc protocol-setup {target} {
             -padx 2 -side top -fill x
 
     # Ok-cancel
-    bottom-buttons $w [list {Ok} [list protocol-setup-action $target] \
-            {Delete} [list protocol-setup-delete $target] \
+    bottom-buttons $w [list {Ok} [list protocol-setup-action $target $w] \
+            {Delete} [list protocol-setup-delete $target $w] \
+            {Advanced} [list advanced-setup $target $bno] \
             {Cancel} [list destroy $w]] 0   
 }
 
+
+proc advanced-setup {target b} {
+    global profile
+
+    set w .advanced-setup-$b
+    
+    toplevelG $w
+    
+    wm title $w "Advanced setup $target"
+    
+    top-down-window $w
+    
+    if {$target == ""} {
+        set target Default
+    }
+    dputs target
+    dputs $profile($target)
+    
+    frame $w.top.largeSetLowerBound
+    frame $w.top.smallSetUpperBound
+    frame $w.top.mediumSetPresentNumber
+    frame $w.top.presentChunk
+    frame $w.top.maximumRecordSize
+    frame $w.top.preferredMessageSize
+
+    pack $w.top.largeSetLowerBound $w.top.smallSetUpperBound \
+            $w.top.mediumSetPresentNumber $w.top.presentChunk \
+            $w.top.maximumRecordSize $w.top.preferredMessageSize \
+            -side top -anchor e -pady 2
+    
+    entry-fields $w.top {largeSetLowerBound smallSetUpperBound \
+            mediumSetPresentNumber presentChunk maximumRecordSize \
+            preferredMessageSize} \
+            {{Large Set Lower Bound:} {Small Set Upper Bound:} \
+            {Medium Set Present Number:} {Present Chunk:} \
+            {Maximum Record Size:} {Preferred Message Size:}} \
+            [list advanced-setup-action $target $b] [list destroy $w]
+    
+    bottom-buttons $w [list {Ok} [list advanced-setup-action $target $b] \
+            {Cancel} [list destroy $w]] 0   
+}
+
+proc advanced-setup-action {target b} {
+    set w .advanced-setup-$b
+
+    dputs "advanced-setup-action"
+    destroy $w
+}
+
 proc database-select-action {} {
     set w .database-select.top
     set b {}
@@ -2093,7 +2203,8 @@ proc save-geometry {} {
     global displayFormat
     global popupMarcdf
     global recordSyntax
-    
+    global elementSetNames
+
     set windowGeometry(.) [wm geometry .]
 
     if {[catch {set f [open ~/.clientrc.tcl w]}]} {
@@ -2104,6 +2215,7 @@ proc save-geometry {} {
     puts $f "set displayFormat $displayFormat"
     puts $f "set popupMarcdf $popupMarcdf"
     puts $f "set recordSyntax $recordSyntax"
+    puts $f "set elementSetNames $elementSetNames"
     foreach n [array names windowGeometry] {
         puts -nonewline $f "set \{windowGeometry($n)\} \{"
         puts -nonewline $f $windowGeometry($n)
@@ -2573,6 +2685,14 @@ proc index-setup {attr queryNo indexNo} {
     set completenessTmpValue 0
     set useTmpValue 0
 
+    catch {destroy $w}
+    toplevelG $w
+
+    set n [lindex $attr 0]
+    wm title $w "Index setup $n"
+
+    top-down-window $w
+
     set len [llength $attr]
     for {set i 1} {$i < $len} {incr i} {
         set q [lindex $attr $i]
@@ -2596,15 +2716,6 @@ proc index-setup {attr queryNo indexNo} {
             }
         }
     }
-    if {[winfo exists $w]} {
-        destroy $w
-    }
-    toplevelG $w
-
-    set n [lindex $attr 0]
-    wm title $w "Index setup $n"
-
-    top-down-window $w
 
     frame $w.top.use -relief ridge -border 2
     frame $w.top.relation -relief ridge -border 2
@@ -2753,7 +2864,7 @@ proc query-setup {queryNo} {
     listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
     scrollbar $w.top.index.scroll -orient vertical -border 1 \
         -command [list $w.top.index.list yview]
-    bind $w.top.index.list <2> [list query-edit-index $queryNo]
+    bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
 
     pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
     pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
@@ -2769,13 +2880,14 @@ proc query-setup {queryNo} {
     foreach x $queryInfoTmp {
         $w.top.index.list insert end [lindex $x 0]
     }
+
     # Bottom
     bottom-buttons $w [list \
-            {Ok} [list query-setup-action $queryNo] \
-            {Add index} [list query-add-index $queryNo] \
-            {Edit index} [list query-edit-index $queryNo] \
-            {Delete index} [list query-delete-index $queryNo] \
-            {Cancel} [list destroy $w]] 0
+            Ok [list query-setup-action $queryNo] \
+            Add [list query-add-index $queryNo] \
+            Edit [list query-edit-index $queryNo] \
+            Delete [list query-delete-index $queryNo] \
+            Cancel [list destroy $w]] 0
 }
 
 proc index-clear {} {
@@ -2800,6 +2912,32 @@ proc index-query {} {
         if {$term != ""} {
             set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
 
+            set relation ""
+            set len [string length $term]
+            incr len -1
+
+            if {$len > 1} {
+                if {[string index $term 0] == ">"} {
+                    if {[string index $term 1] == "=" } {
+                        set term [string trim [string range $term 2 $len]]
+                        set relation 4
+                    } else {
+                        set term [string trim [string range $term 1 $len]]
+                        set relation 5
+                    }
+                } elseif {[string index $term 0] == "<"} {
+                    if {[string index $term 1] == "=" } {
+                        set term [string trim [string range $term 2 $len]]
+                        set relation 2
+                    } elseif {[string index $term 1] == ">"} {
+                        set term [string trim [string range $term 2 $len]]
+                        set relation 6
+                    } else {
+                        set term [string trim [string range $term 1 $len]]
+                        set relation 1
+                    }
+                }
+            } 
             set len [string length $term]
             incr len -1
             set left 0
@@ -2820,6 +2958,9 @@ proc index-query {} {
             } elseif {$left} {
                 set term "@attr 5=2 ${term}"
             }
+            if {$relation != ""} {
+                set term "@attr 2=${relation} ${term}"
+            }
             foreach a $attr {
                 set term "@attr $a ${term}"
             }
@@ -3002,6 +3143,7 @@ menu .top.options.m
 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
+.top.options.m add cascade -label "Elements" -menu .top.options.m.elements
 
 menu .top.options.m.query
 .top.options.m.query add cascade -label "Select" \
@@ -3059,6 +3201,14 @@ menu .top.options.m.syntax
 .top.options.m.syntax add radiobutton -label "GRS1" \
         -value GRS1 -variable recordSyntax
 
+menu .top.options.m.elements
+.top.options.m.elements add radiobutton -label "Unspecified" \
+        -value None -variable elementSetNames
+.top.options.m.elements add radiobutton -label "Full" \
+        -value F -variable elementSetNames
+.top.options.m.elements add radiobutton -label "Brief" \
+        -value B -variable elementSetNames
+
 menubutton .top.help -text "Help" -menu .top.help.m
 menu .top.help.m
 
@@ -3102,8 +3252,18 @@ if {! $monoFlag} {
 }
 .data.record tag configure marc-data -foreground black
 .data.record tag configure marc-head \
-        -font -Adobe-Times-Medium-R-Normal-*-180-* \
-        -foreground white -background black
+        -font -Adobe-Times-Bold-R-Normal-*-140-* \
+        -foreground brown -relief raised -borderwidth 1
+.data.record tag configure marc-small-head -foreground brown
+.data.record tag configure marc-pref \
+        -font -Adobe-Times-Medium-R-Normal-*-140-* \
+        -foreground blue
+.data.record tag configure marc-text \
+        -font -Adobe-Times-Medium-R-Normal-*-140-* \
+        -foreground black
+.data.record tag configure marc-it \
+        -font -Adobe-Times-Medium-I-Normal-*-140-* \
+        -foreground black
 
 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
 if {[tk4]} {
@@ -3133,6 +3293,8 @@ if {[catch {ir z39}]} {
     ir z39
     puts "ok"
 }
-#z39 logLevel all
+z39 largeSetLowerBound 20
+z39 smallSetUpperBound 2
+z39 mediumSetPresentNumber 2
+z39 logLevel all
 show-logo 1
-