Changeset 837 for trunk/lstview


Ignore:
Timestamp:
Dec 4, 2009 5:12:53 PM (11 years ago)
Author:
toby
Message:

# on 2005/03/24 21:43:24, toby did:
fix bug in save options
Add unix capability to print selected text
(should work on OS X if lpr points to desired printer -- I think)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lstview

    • Property rcs:date changed from 2004/09/20 15:26:54 to 2005/03/24 21:43:24
    • Property rcs:lines changed from +3 -2 to +49 -8
    • Property rcs:rev changed from 1.17 to 1.18
    r799 r837  
    2121set txtvw(sum) 0
    2222set txtvw(hideplot) 0
     23set txtvw(printcommand) lpr
    2324# maximum characters to read initially from a .LST file
    2425set txtvw(maxchars) 1000000
     
    360361        set fp [open [file join ~ .gsas_config] a]
    361362    }
    362     puts $fp "# LSTVIEW saved options from [clock format [clock ticks]]"
    363     puts $fp "set txtvw(followcycle) [list $txtvw(followcycle)]"
    364     puts $fp "set txtvw(font) [list $txtvw(font)]"
     363    puts $fp "# LSTVIEW saved options from [clock format [clock seconds]]"
     364    foreach var {followcycle font printcommand} {
     365        puts $fp "set txtvw($var) [list $txtvw($var)]"
     366    }
    365367    close $fp
    366368}
     
    448450
    449451# windows copy command. Should not be needed in X windows
     452pack [menubutton .a.edit -text Edit -underline 0 -menu .a.edit.menu] \
     453    -side left
     454menu .a.edit.menu
    450455if {$tcl_platform(platform) == "windows"} {
    451     pack [menubutton .a.edit -text Edit -underline 0 -menu .a.edit.menu] \
    452             -side left
    453     menu .a.edit.menu
    454456    .a.edit.menu add command -label copy \
    455457            -command {catch {clipboard append [selection get]}}
     458} else {
     459    .a.edit.menu add command -label "Print Selection" \
     460            -command {catch PrintSelection}
    456461}
    457462
     
    490495}
    491496
     497if {$tcl_platform(platform) != "windows"} {
     498    .a.options.menu add command -label "Set print command" -underline 1 \
     499        -command SetPrintCommand
     500}
    492501.a.options.menu add command -label "Save Options" -underline 1 \
    493502        -command "SaveOptions"
     
    695704    .txt see $loc
    696705}
     706
     707proc PrintSelection {} {
     708    global txtvw
     709    if {[catch {
     710        set fp [open "| $txtvw(printcommand)" w]
     711        puts $fp [selection get]
     712        close $fp
     713    } errmsg]} {
     714        MyMessageBox -parent . -title "Print error" \
     715            -message "Error trying to print: $errmsg" \
     716            -icon warning -type Ignore -default ignore
     717        # -helplink "expguierr.html Customizewarning"
     718    }
     719    catch {close $fp}
     720}
     721
     722proc SetPrintCommand {} {
     723    set bx .opt
     724    catch {destroy $bx}
     725    toplevel $bx
     726    wm iconname $bx "Print options"
     727    wm title $bx "Print options"
     728
     729    pack [label $bx.0 -text "Set Print Command" ] -side top
     730    pack [frame $bx.c] -side top
     731    pack [frame $bx.b] -side top
     732    pack [label $bx.c.a -text "Command:"] -side left
     733    pack [entry $bx.c.b -textvariable txtvw(printcommand) -width 40] \
     734            -side left
     735    pack [button $bx.b.c -command "destroy $bx" -text Close ] -side right
     736}
     737
    697738
    698739pack [menubutton .a.help -text Help -underline 0 -menu .a.help.menu] -side right
Note: See TracChangeset for help on using the changeset viewer.