41 namespace eval Bibliography {
49 proc Ref2ISBD { Ref Biblio} {
53 set key [
lindex $Ref 0]
55 set address ""
set author ""
set editor ""
set number ""
56 set isbn ""
set issn ""
set issue ""
set pages ""
57 set publisher ""
set title ""
set volume ""
set year ""
58 set edition ""
set keywords ""
60 foreach tag { type address author editor number isbn issn issue pages publisher title volume year edition keywords } {
61 set $tag [
lindex [
lindex $Ref [lsearch -exact -index 0 $Ref $tag]] 1]
63 regsub -all -nocase { and } $author "; " author
66 $w.f.tree insert {} end -id $key -text "$type: $author ($key)" -open true
67 $w.f.tree insert $key end -id "l2$key" -text "$author" -tags {author}
68 $w.f.tree insert $key end -id "l3$key" -text "$title" -tags {title}
69 $w.f.tree insert $key end -id "l4$key" -text "$Biblio" -tags {reference}
71 $w.f.tree insert $key end -id "l5$key" -text "Ed. $editor"
74 $w.f.tree insert $key end -id "l6$key" -text "$edition"
76 $w.f.tree insert $key end -id "l7$key" -text "$address : $publisher, $year. - "
78 $w.f.tree insert $key end -id "l8$key" -text "$pages"
81 $w.f.tree insert $key end -id "l9$key" -text "$isbn"
82 }
elseif {$issn != ""} {
83 $w.f.tree insert $key end -id "l9$key" -text "$issn"
85 if {$keywords != ""} {
86 $w.f.tree insert $key end -id "l0$key" -text "$keywords"
99 if {$type == "BOOK"} {
100 set isbd "$author:\n$title / $author. Ed. $editor.\n- $edition -\n$address : $publisher, $year. - $pages\n$isbn\n\n$keywords\n"
101 }
elseif {$type == "PERIODICAL"} {
103 set isbd "\[Journal\]\n$title / publ. $editor\n$address : $publisher, $year. - $pages\n$issn\n\n$keywords\n"
106 set isbd "\[$type\]\n$author:\n$title / $author. Ed. $editor.\n - $edition - $address : $publisher, $year. - $pages\n$isbn ($issn)\n\n$keywords\n"
117 proc ReadBibTeX { bibfile } {
118 set fd [open $bibfile]
124 set address ""
set author ""
set editor ""
set number ""
125 set isbn ""
set issn ""
set issue ""
set pages ""
126 set publisher ""
set title ""
set volume ""
set year ""
127 set edition ""
set keywords ""
129 while { [
gets $fd line] >= 0} {
130 if {[regexp -- "@" $line]} {
132 lappend Bibentries [list \
134 [list "type" $type] \
135 [list "title" $title] \
136 [list "editor" $editor] \
137 [list "author" $author] \
138 [list "publisher" $publisher] \
139 [list "pages" $pages] \
140 [list "address" $address] \
141 [list "isbn" $isbn] \
142 [list "issn" $issn] \
143 [list "volume" $volume] \
144 [list "issue" $issue] \
145 [list "number" $number] \
146 [list "edition" $edition] \
147 [list "keywords" $keywords] \
150 regsub {\{.*} $line "" type
151 regsub {\@} $type "" type
153 regsub {.*\{} $line "" key
154 regsub {,} $key "" key
156 set key [
string trim $key]
157 set type [
string trim $type]
159 set address ""
set author ""
set editor ""
set number ""
160 set isbn ""
set issn ""
set issue ""
set pages ""
161 set publisher ""
set title ""
set volume ""
set year ""
162 set edition ""
set keywords ""
164 regsub -all { "} $line {} line
165 regsub -all {" } $line {} line
166 regsub -all {,$} $line {} line
167 regsub -all {[\{\}]} $line {} line
170 if {[regexp -- {[ \t]title[ \t=]} $line]} {
171 regsub -all {title .*= } $line {} title
172 set title [
string trim $title]
174 if {[regexp -- {[ \t]author[ \t=]} $line]} {
175 regsub -all {author .*= } $line {} author
176 set author [
string trim $author]
178 if {[regexp -- {[ \t]editor[ \t=]} $line]} {
179 regsub -all {editor .*= } $line {} editor
180 set editor [
string trim $editor]
182 if {[regexp -- {[ \t]year[ \t=]} $line]} {
183 regsub -all {year .*= } $line {} year
184 set year [
string trim $year]
186 if {[regexp -- {[ \t]publisher[ \t=]} $line]} {
187 regsub -all {publisher .*= } $line {} publisher
188 set publisher [
string trim $publisher]
190 if {[regexp -- {[ \t]address[ \t=]} $line]} {
191 regsub -all {address .*= } $line {} address
192 set address [
string trim $address]
194 if {[regexp -- {[ \t]isbn[ \t=]} $line]} {
195 regsub -all {isbn.*= } $line {} isbn
196 set isbn [
string trim $isbn]
198 if {[regexp -- {[ \t]issn[ \t=]} $line]} {
199 regsub -all {issn.*= } $line {} issn
200 set issn [
string trim $issn]
202 if {[regexp -- {[ \t]issue[ \t=]} $line]} {
203 regsub -all {issue.*= } $line {} issue
204 set issue [
string trim $issue]
206 if {[regexp -- {[ \t]volume[ \t=]} $line]} {
207 regsub -all {volume.*= } $line {} volume
208 set volume [
string trim $volume]
210 if {[regexp -- {[ \t]number[ \t=]} $line]} {
211 regsub -all {number.*= } $line {} number
212 set number [
string trim $number]
214 if {[regexp -- {[ \t]edition[ \t=]} $line]} {
215 regsub -all {edition.*= } $line {} edition
216 set edition [
string trim $edition]
218 if {[regexp -- {[ \t]keywords[ \t=]} $line]} {
219 regsub -all {keywords.*= } $line {} keywords
220 set keywords [
string trim $keywords]
232 proc ExtractRef { bibfile } {
236 set Extra [
sc_game tags get Extra]
237 set extraTagsList [
split $Extra "\n"]
241 foreach i $extraTagsList {
242 if { [
string equal -nocase [
lindex $i 0] "Bib"] } {
243 set ref [
string range $i 5 end-1]
245 regsub -all { ; } $ref {|} ref
248 set ref [
split $ref "|"]
253 regsub -all {, .*} $r {} BibKey
254 regsub -all {.*, } $r {} Biblio
255 set BibKey [
string trim $BibKey]
256 set Biblio [
string trim $Biblio]
257 set idx [lsearch -exact -index 0 $BibEntries $BibKey]
258 set BibDta [
lindex $BibEntries $idx]
261 set literature "$literature\n$isbd\n$Biblio\n\n"
265 set lit [
string trim $literature]
278 if { [
winfo exists $w] } {
289 pack $w.f -fill both -expand 1
291 ttk::treeview $w.f.tree -xscrollcommand "$w.f.xbar set" -yscrollcommand "$w.f.ybar set" -show tree -selectmode none
292 ttk::scrollbar $w.f.xbar -command "$w.f.tree xview" -orient horizontal
293 ttk::scrollbar $w.f.ybar -command "$w.f.tree yview" -orient vertical
294 $w.f.tree column #0 -minwidth 1200
296 $w.f.tree tag configure author -foreground blue
297 $w.f.tree tag configure title -foreground blue
298 $w.f.tree tag configure reference -foreground red
300 pack $w.f.xbar -side bottom -fill x
301 pack $w.f.ybar -side right -fill y
302 pack $w.f.tree -side left -expand 1 -fill both
305 set bibfile [
file nativename [
file join $scidDataDir "Bookshelf.bib"]]
307 if {[
file readable "[
sc_base filename $::curr_db].bib"]} {
308 set bibfile "[
sc_base filename $::curr_db].bib"
312 bind $w <Escape> { destroy .showRef}
313 bind $w <Configure> {
314 recordWinSize .showRef
317 bind $w <Control-Insert> { clipboard clear; clipboard append $::Bibliography::literature }
318 bind $w <Control-c> { clipboard clear; clipboard append $::Bibliography::literature }