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