Work on GRS.
[ir-tcl-moved-to-github.git] / formats / line.tcl
1 # IR toolkit for tcl/tk
2 # (c) Index Data 1995
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
5 #
6 # $Log: line.tcl,v $
7 # Revision 1.7  1995-09-20 11:37:06  adam
8 # Work on GRS.
9 #
10 # Revision 1.6  1995/06/29  12:34:20  adam
11 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
12 #
13 # Revision 1.5  1995/06/22  13:16:28  adam
14 # Feature: SUTRS. Setting getSutrs implemented.
15 # Work on display formats.
16 #
17 # Revision 1.4  1995/06/19  08:10:21  adam
18 # Inverse highligt colours in monochrome mode.
19 #
20 # Revision 1.3  1995/06/16  12:29:00  adam
21 # Use insertWithTags on diagnostic errors.
22 #
23 # Revision 1.2  1995/06/13  14:39:06  adam
24 # Fix: if {$var != ""} doesn't work if var is a large numerical!
25 # Highlight when line format is used.
26 #
27 # Revision 1.1  1995/06/12  15:18:10  adam
28 # Work on presentation formats. These are used in the main window as well
29 # as popup windows.
30 #
31 #
32 proc display-grs-line {w r i} {
33     foreach e $r {
34         for {set j 0} {$j < $i} {incr j} {
35             insertWithTags $w "  " {}
36         }
37         insertWithTags $w "([lindex $e 0]:[lindex $e 2])" marc-tag
38         if {[lindex $e 3] == "string"} {
39             insertWithTags $w [lindex $e 4] {}
40             insertWithTags $w "\n" {}
41         } elseif {[lindex $e 3] == "subtree"} {
42             insertWithTags $w "\n" {}
43             display-grs-line $w [lindex $e 4] [expr $i+1]
44         } else {
45             insertWithTags [lindex $e 4] {}
46             insertWithTags $w " ?\n" {}
47         }
48     }
49 }
50
51 proc display-line {sno no w hflag} {
52     global monoFlag
53     set type [z39.$sno type $no] 
54     if {$hflag} {
55         if {! $monoFlag} {
56             $w tag bind r$no <Any-Enter> \
57                 [list $w tag configure r$no -background gray80]
58             $w tag bind r$no <Any-Leave> \
59                 [list $w tag configure r$no -background {}]
60         } else {
61             $w tag bind r$no <Any-Enter> \
62                 [list $w tag configure r$no -background black -foreground white]
63             $w tag bind r$no <Any-Leave> \
64                 [list $w tag configure r$no -background {} -foreground {}]
65         }
66     } else {
67         $w delete 0.0 end
68     }
69     if {$hflag} {
70         set nostr [format "%5d " $no]
71         insertWithTags $w $nostr marc-tag
72     }
73     if {$type == "DB"} {
74         set rtype [z39.$sno recordType $no]
75         if {$rtype == "SUTRS"} {
76             insertWithTags $w [join [z39.$sno getSutrs $no]]
77         } elseif {$rtype == "GRS1"} {
78             display-grs-line $w [z39.$sno getGrs $no] 6
79         } else {
80             if {[catch {
81                 set title [lindex [z39.$sno getMarc $no field 245 * a] 0]
82                 set year  [lindex [z39.$sno getMarc $no field 260 * c] 0]
83                 insertWithTags $w "$title - $year\n" marc-data
84             }]} {
85                 insertWithTags $w "Unknown record type: $rtype\n" marc-id
86             }
87         }
88     } elseif {$type == "SD"} {
89         set err [lindex [z39.$sno diag $no] 1]
90         set add [lindex [z39.$sno diag $no] 2]
91         if {$add != {}} {
92             set add " :${add}"
93         }
94         insertWithTags $w "Error ${err}${add}\n" marc-id
95     } 
96 }