Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | First working pdf print. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1d6b23a0da413e80c3be6daba928c8b0 |
User & Date: | peter 2007-02-17 04:28:27.000 |
Context
2007-02-17
| ||
04:30 | Mount kits readonly. Added pdf print check-in: ae384b8408 user: peter tags: trunk | |
04:28 | First working pdf print. check-in: 1d6b23a0da user: peter tags: trunk | |
04:26 | Removed dependency on external pdf4tcl. check-in: 76569fcd88 user: peter tags: trunk | |
Changes
Changes to src/print.tcl.
︙ | ︙ | |||
114 115 116 117 118 119 120 | append result "\0bggray\{$gray\}$text\0bggray\{1.0\}" } } return $result } # Main print function | | > > | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | append result "\0bggray\{$gray\}$text\0bggray\{1.0\}" } } return $result } # Main print function proc PrintDiffs {top {quiet 0} {pdfprint 0}} { busyCursor $top update idletasks set tmpFile [file nativename ~/eskil.enscript] if {$::diff($top,printFile) != ""} { set tmpFile2 [file nativename $::diff($top,printFile)] } else { set tmpFile2 [file nativename ~/eskil.ps] } set lines1 {} set lines2 {} if {[info exists ::Pref(printCharsPerLine)]} { set wraplength $::Pref(printCharsPerLine) } elseif {$::Pref(wideLines)} { set wraplength 100 set linesPerPage 74 } else { set wraplength 85 set linesPerPage 66 } |
︙ | ︙ | |||
237 238 239 240 241 242 243 | } elseif {$w2 > $w1} { for {set t $w1} {$t < $w2} {incr t} { lappend wraplines1 {} } } } | | | | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | } elseif {$w2 > $w1} { for {set t $w1} {$t < $w2} {incr t} { lappend wraplines1 {} } } } if {$pdfprint} { PdfPrint $top $wraplength $wraplines1 $wraplines2 } else { # Write all lines to a file, taking one page at a time from each # side. set ch [open $tmpFile "w"] fconfigure $ch -encoding binary |
︙ | ︙ | |||
310 311 312 313 314 315 316 | } } } # Finished normalCursor $top | | | | | > > > > > > > > > > > > | > | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | } } } # Finished normalCursor $top if {!$pdfprint && !$quiet} { destroy .dp toplevel .dp wm title .dp "Eskil Print" button .dp.b -text "Close" -command {destroy .dp} label .dp.l -anchor w -justify left -text "The following files have\ been created:\n\n$tmpFile\nInput file to enscript.\ \n\n$tmpFile2\nCreated with\ '[lrange $enscriptCmd 0 end-3] \\\n \ [lrange $enscriptCmd end-2 end]'" \ -font "Courier 8" pack .dp.b -side bottom pack .dp.l -side "top" } } proc PdfPrint {top cpl wraplines1 wraplines2} { if {$::diff($top,printFile) != ""} { set pdfFile $::diff($top,printFile) } else { set pdfFile ~/eskil.pdf } if {![regexp {^(.*)( \(.*?\))$} $::diff($top,leftLabel) -> lfile lrest]} { set lfile $::diff($top,leftLabel) set lrest "" } set lfile [file tail $lfile]$lrest if {![regexp {^(.*)( \(.*?\))$} $::diff($top,rightLabel) -> rfile rrest]} { set rfile $::diff($top,rightLabel) set rrest "" } set rfile [file tail $rfile]$rrest set pdf [eskilprint %AUTO% -file $pdfFile -cpl $cpl \ -headleft $lfile -headright $rfile -headsize 10] set linesPerPage [$pdf getNLines] $pdf setTag change "0.8 0.4 0.4" $pdf setTag new1 "0.4 0.8 0.4" $pdf setTag new2 "0.4 0.4 0.8" set len1 [llength $wraplines1] set len2 [llength $wraplines2] |
︙ | ︙ | |||
362 363 364 365 366 367 368 | } $pdf setHalf right for {set i 0} {$i < $linesPerPage && $i2 < $len2} {incr i ; incr i2} { $pdf drawTextLine [lindex $wraplines2 $i2] $pdf newLine } } | | < | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | } $pdf setHalf right for {set i 0} {$i < $linesPerPage && $i2 < $len2} {incr i ; incr i2} { $pdf drawTextLine [lindex $wraplines2 $i2] $pdf newLine } } $pdf endPrint } # Create a print dialog. proc doPrint {top {quiet 0}} { if {![info exists ::diff(prettyPrint)]} { set ::diff(prettyPrint) "" } |
︙ | ︙ | |||
437 438 439 440 441 442 443 | set ::diff(currentCharsPerLine) $len } } # Count the longest line length in the current display proc CountCharsPerLine {top} { set ::diff(currentCharsPerLine) 0 | | | > > > > > > > > > > > > | | > > > > | | > > > > | | > > > > | | | | | | | | 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | set ::diff(currentCharsPerLine) $len } } # Count the longest line length in the current display proc CountCharsPerLine {top} { set ::diff(currentCharsPerLine) 0 $::widgets($top,wDiff1) dump -text -command AccumulateMax 1.0 end $::widgets($top,wDiff2) dump -text -command AccumulateMax 1.0 end return $::diff(currentCharsPerLine) } proc BrowsePrintFileName {top entry} { set prev $::diff($top,printFile) set dir [file dirname $prev] set apa [tk_getSaveFile -initialdir $dir -initialfile [file tail $prev] \ -parent [winfo toplevel $entry] -title "PDF file"] if {$apa ne ""} { set ::diff($top,printFile) $apa $entry xview end } } # Create a print dialog. proc doPrint2 {top {quiet 0}} { if {$quiet} { PrintDiffs $top 1 1 return } destroy .pr toplevel .pr -padx 3 -pady 3 wm title .pr "Print diffs to PDF" label .pr.hsl -anchor w -text "Header Size" spinbox .pr.hss -textvariable ::Pref(printHeaderSize) \ -from 5 -to 16 -width 3 label .pr.cll -anchor w -text "Chars per line" entry .pr.cle -textvariable ::Pref(printCharsPerLine) -width 4 frame .pr.clf set values [list 80 [CountCharsPerLine $top]] if {[string is digit -strict $::Pref(printCharsPerLine)]} { lappend values $::Pref(printCharsPerLine) } set values [lsort -unique -integer $values] foreach value $values { radiobutton .pr.clf.$value -variable ::Pref(printCharsPerLine) \ -value $value -text $value pack .pr.clf.$value -side left -padx 3 -pady 3 } # FIXA: Select paper size #set paperlist [lsort -dictionary [pdf4tcl::getPaperSizeList]] #set Pref(printPaper) a4 label .pr.fnl -anchor w -text "File name" entry .pr.fne -textvariable ::diff($top,printFile) -width 30 button .pr.fnb -text Browse \ -command [list BrowsePrintFileName $top .pr.fne] if {$::diff($top,printFile) eq ""} { set ::diff($top,printFile) "~/eskil.pdf" } frame .pr.fb button .pr.b1 -text "Print to File" -padx 5\ -command "destroy .pr; update; PrintDiffs $top 0 1" button .pr.b2 -text "Cancel" -padx 5 \ -command {destroy .pr} pack .pr.b1 -in .pr.fb -side left -padx 3 -pady 3 pack .pr.b2 -in .pr.fb -side right -padx 3 -pady 3 grid .pr.hsl .pr.hss -sticky we -padx 3 -pady 3 grid .pr.cll .pr.cle .pr.clf -sticky we -padx 3 -pady 3 grid .pr.fnl .pr.fne - .pr.fnb -sticky we -padx 3 -pady 3 grid .pr.fb - - - -sticky we -padx 3 -pady 3 grid columnconfigure .pr 2 -weight 1 } |