︙ | | | ︙ | |
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
return "\n "
} else {
return "\0bggray\{1.0\}\n \0bggray\{$gray\}"
}
}
# Prepare a text block for printing
proc FixTextBlock {text index} {
# Remove any form feed
if {[regsub -all "\f" $text {} apa]} {
set text $apa
}
regexp {\d+\.(\d+)} $index -> index
|
>
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
return "\n "
} else {
return "\0bggray\{1.0\}\n \0bggray\{$gray\}"
}
}
# Prepare a text block for printing
# Index denotes where this text starts. It is used to get tab expansion right.
proc FixTextBlock {text index} {
# Remove any form feed
if {[regsub -all "\f" $text {} apa]} {
set text $apa
}
regexp {\d+\.(\d+)} $index -> index
|
︙ | | | ︙ | |
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
}
set tdump1 [$::widgets($top,wDiff1) dump -tag -text 1.0 end]
set tdump2 [$::widgets($top,wDiff2) dump -tag -text 1.0 end]
set lineNo1 [ProcessLineno $::widgets($top,wLine1)]
set lineNo2 [ProcessLineno $::widgets($top,wLine2)]
foreach tdump [list $tdump1 $tdump2] \
lineName {lines1 lines2} wrapName {wrap1 wrap2} \
lineNo [list $lineNo1 $lineNo2] {
##nagelfar variable lineName varName
##nagelfar variable wrapName varName
set lines {}
set wraps {}
|
>
>
>
|
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
}
set tdump1 [$::widgets($top,wDiff1) dump -tag -text 1.0 end]
set tdump2 [$::widgets($top,wDiff2) dump -tag -text 1.0 end]
set lineNo1 [ProcessLineno $::widgets($top,wLine1)]
set lineNo2 [ProcessLineno $::widgets($top,wLine2)]
# Loop over left and right displays, collecting lines from each.
# Line numbers and text are put together and lines are wrapped if needed.
foreach tdump [list $tdump1 $tdump2] \
lineName {lines1 lines2} wrapName {wrap1 wrap2} \
lineNo [list $lineNo1 $lineNo2] {
##nagelfar variable lineName varName
##nagelfar variable wrapName varName
set lines {}
set wraps {}
|
︙ | | | ︙ | |
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
}
}
}
set $lineName $lines
set $wrapName $wraps
}
set wraplines1 {}
set wraplines2 {}
foreach l1 $lines1 l2 $lines2 w1 $wrap1 w2 $wrap2 {
if {$w1 > 0} {
set apa [split $l1 "\n"]
set wraplines1 [concat $wraplines1 $apa]
|
>
>
>
|
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
}
}
}
set $lineName $lines
set $wrapName $wraps
}
# Go through both lists and pad with empty lines as needed to accomodate
# for wrapped lines in the other side.
set wraplines1 {}
set wraplines2 {}
foreach l1 $lines1 l2 $lines2 w1 $wrap1 w2 $wrap2 {
if {$w1 > 0} {
set apa [split $l1 "\n"]
set wraplines1 [concat $wraplines1 $apa]
|
︙ | | | ︙ | |
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
}
} elseif {$w2 > $w1} {
for {set t $w1} {$t < $w2} {incr t} {
lappend wraplines1 ""
}
}
}
set ch [open $tmpFile "w"]
set len1 [llength $wraplines1]
set len2 [llength $wraplines2]
set i1 0
|
>
>
>
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
}
} elseif {$w2 > $w1} {
for {set t $w1} {$t < $w2} {incr t} {
lappend wraplines1 ""
}
}
}
# Write all lines to a file, taking one page at a time from each
# side.
set ch [open $tmpFile "w"]
set len1 [llength $wraplines1]
set len2 [llength $wraplines2]
set i1 0
|
︙ | | | ︙ | |
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
for {set i 0} {$i < $linesPerPage && $i2 < $len2} {incr i ; incr i2} {
puts $ch [lindex $wraplines2 $i2]
}
if {$i < $linesPerPage} {puts -nonewline $ch "\f"}
}
close $ch
if {$::tcl_platform(platform) eq "windows" &&\
![info exists ::env(ENSCRIPT_LIBRARY)]} {
set ::env(ENSCRIPT_LIBRARY) [pwd]
}
set enscriptCmd [list enscript -2jcre -L $linesPerPage -M A4]
if {$::Pref(wideLines)} {
|
>
>
|
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
for {set i 0} {$i < $linesPerPage && $i2 < $len2} {incr i ; incr i2} {
puts $ch [lindex $wraplines2 $i2]
}
if {$i < $linesPerPage} {puts -nonewline $ch "\f"}
}
close $ch
# Run enscript to generate postscript
if {$::tcl_platform(platform) eq "windows" &&\
![info exists ::env(ENSCRIPT_LIBRARY)]} {
set ::env(ENSCRIPT_LIBRARY) [pwd]
}
set enscriptCmd [list enscript -2jcre -L $linesPerPage -M A4]
if {$::Pref(wideLines)} {
|
︙ | | | ︙ | |
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
if {[catch {eval exec $enscriptCmd} result]} {
if {[string index $result 0] != "\["} {
tk_messageBox -message "Enscript error: $result"
return
}
}
normalCursor $top
if {!$quiet} {
destroy .dp
toplevel .dp
wm title .dp "Eskil Print"
button .dp.b -text "Close" -command {destroy .dp}
|
>
>
|
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
if {[catch {eval exec $enscriptCmd} result]} {
if {[string index $result 0] != "\["} {
tk_messageBox -message "Enscript error: $result"
return
}
}
# Finished
normalCursor $top
if {!$quiet} {
destroy .dp
toplevel .dp
wm title .dp "Eskil Print"
button .dp.b -text "Close" -command {destroy .dp}
|
︙ | | | ︙ | |