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