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