︙ | | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
-
+
+
|
set res [format "%*s" $maxlen $res]
}
return $res
}
# Process the line numbers from the line number widget into a list
# of "linestarters"
proc ProcessLineno {w maxlen} {
set tdump [$w dump -tag -text 1.0 end]
proc ProcessLineno {W maxlen} {
set tdump [$W dump -tag -text 1.0 end]
set tag ""
set line ""
set lines {}
foreach {key value index} $tdump {
if {$key eq "tagon"} {
if {$value eq "change" || [string match "new*" $value]} {
set tag $value
|
︙ | | |
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
-
-
+
+
-
+
|
set n [expr {(- $i - $index - 1) % 8 + 1}]
set text [string replace $text $i $i [format %*s $n ""]]
}
return $text
}
# Find the lastnumber in a text widget
proc FindLastNumber {w} {
set index [$w search -backwards -regexp {\d} end]
proc FindLastNumber {W} {
set index [$W search -backwards -regexp {\d} end]
if {$index eq ""} {
# There where no numbers there, treat it like 0
return 0
}
set line [$w get "$index linestart" "$index lineend"]
set line [$W get "$index linestart" "$index lineend"]
#puts "X '$line' '$index'"
regexp {\d+} $line number
return $number
}
# Main print function
proc PrintDiffs {top {quiet 0}} {
|
︙ | | |
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
-
+
-
+
|
if {$::eskil($top,printFile) != ""} {
set pdfFile $::eskil($top,printFile)
} else {
set pdfFile ~/eskil.pdf
}
if {![regexp {^(.*)( \(.*?\))$} $::eskil($top,leftLabel) -> lfile lrest]} {
if { ! [regexp {^(.*)( \(.*?\))$} $::eskil($top,leftLabel) -> lfile lrest]} {
set lfile $::eskil($top,leftLabel)
set lrest ""
}
set lfile [file tail $lfile]$lrest
if {![regexp {^(.*)( \(.*?\))$} $::eskil($top,rightLabel) -> rfile rrest]} {
if { ! [regexp {^(.*)( \(.*?\))$} $::eskil($top,rightLabel) -> rfile rrest]} {
set rfile $::eskil($top,rightLabel)
set rrest ""
}
set rfile [file tail $rfile]$rrest
set pdf [eskilprint %AUTO% -file $pdfFile -cpl $cpl -cpln $cpln \
-headleft $lfile -headright $rfile -headsize 10]
|
︙ | | |
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
-
+
|
for {set i 0} {$i < $linesPerPage && $i2 < $len2} {incr i ; incr i2} {
$pdf drawTextLine [lindex $wraplines2 $i2]
$pdf newLine
}
}
$pdf endPrint
if {!$quiet} {
if { ! $quiet} {
tk_messageBox -title "Eskil Print" -parent $top \
-message "Printed $npages pages to $pdfFile" -type ok
}
}
# Count the length of a line during a text dump
proc AccumulateMax {top key value index} {
|
︙ | | |
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
-
-
+
+
-
+
-
+
-
+
-
+
|
set ::eskil($top,currentCharsPerLine) \
[lsort -integer $::eskil($top,currentCharsPerLine)]
return [lindex $::eskil($top,currentCharsPerLine) end]
}
# In a sorted list of integers, figure out where val fits
# In 8.6 this could use lsearch -bisect
proc FindPercentile {l val} {
set len [llength $l]
proc FindPercentile {lst val} {
set len [llength $lst]
# No elements, so all are covered in a way
if {$len == 0} { return 100 }
# Above range, so 100%
if {[lindex $l end] <= $val} { return 100 }
if {[lindex $lst end] <= $val} { return 100 }
# Under range, so 0%
if {[lindex $l 0] > $val} { return 0 }
if {[lindex $lst 0] > $val} { return 0 }
# Single element should not slip through...
if {$len <= 1} { return 0 }
set i [lsearch -integer -all $l $val]
set i [lsearch -integer -all $lst $val]
set i [lindex $i end]
if {$i >= 0} {
return [expr {100 * $i / ($len - 1)}]
}
# To keep search down, just look at multiples of 1%
set prev 0
for {set t 0} {$t <= 100} {incr t} {
set i [expr {$t * ($len - 1) / 100}]
if {$val < [lindex $l $i]} {
if {$val < [lindex $lst $i]} {
return $prev
}
set prev $t
}
return 99
}
|
︙ | | |
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
|
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
|
-
+
-
+
-
-
+
+
-
-
+
+
-
+
|
}
set ::eskil($top,printFile) $apa
$entry xview end
}
# Fix to give spinbox nicer appearance
proc MySpinBox {w args} {
proc MySpinBox {W args} {
# Handle if ttk::spinbox is not there since it was introduced later
if {[info commands ttk::spinbox] eq ""} {
set cmd [list tk::spinbox $w]
set cmd [list tk::spinbox $W]
} else {
set cmd [list ttk::spinbox $w]
lappend cmd -command [list $w selection clear] -state readonly
set cmd [list ttk::spinbox $W]
lappend cmd -command [list $W selection clear] -state readonly
}
lappend cmd {*}$args
{*}$cmd
}
proc PrintTracePrefs {W args} {
set ::Pref(printColorChange) \
[list $::TmpPref(chr) $::TmpPref(chg) $::TmpPref(chb)]
set ::Pref(printColorNew1) \
[list $::TmpPref(n1r) $::TmpPref(n1g) $::TmpPref(n1b)]
set ::Pref(printColorNew2) \
[list $::TmpPref(n2r) $::TmpPref(n2g) $::TmpPref(n2b)]
if {![winfo exists $W.cf.l1e]} return
foreach w {1 2 3} p {ch n1 n2} {
if { ! [winfo exists $W.cf.l1e]} return
foreach num {1 2 3} p {ch n1 n2} {
set r [expr {int(255*$::TmpPref(${p}r))}]
set g [expr {int(255*$::TmpPref(${p}g))}]
set b [expr {int(255*$::TmpPref(${p}b))}]
set col [format \#%02X%02X%02X $r $g $b]
$W.cf.l${w}e configure -background $col
$W.cf.l${num}e configure -background $col
}
}
# Create a print dialog for PDF.
proc doPrint {top {quiet 0}} {
if {$quiet} {
PrintDiffs $top 1
|
︙ | | |