Index: u_main.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/u_main.tk,v retrieving revision 1.28 diff -u -w -r1.28 u_main.tk --- u_main.tk 18 Aug 2007 23:32:44 -0000 1.28 +++ u_main.tk 4 Nov 2007 20:13:46 -0000 @@ -93,28 +93,19 @@ set help_top_directory $pd_guidir/doc -# it's unfortunate but we seem to have to turn off global bindings -# for Text objects to get control-s and control-t to do what we want for -# "text" dialogs below. Also we have to get rid of tab's changing the focus. - -bind all "" -bind all <> "" -bind Text {} -bind Text {} -# puts stderr [bind all] - ################## set up main window ######################### # the menus are instantiated here for the main window # for the patch windows, they are created by pdtk_canvas_new menu .mbar -canvas .dummy -height 2p -width 6c -frame .controls -pack .controls .dummy -side top -fill x menu .mbar.file -tearoff $pd_tearoff -.mbar add cascade -label "File" -menu .mbar.file +.mbar add cascade -label File -menu .mbar.file +menu .mbar.edit -tearoff $pd_tearoff +.mbar add cascade -label Edit -menu .mbar.edit +menu .mbar.put -tearoff $pd_tearoff +.mbar add cascade -label Put -menu .mbar.put menu .mbar.find -tearoff $pd_tearoff -.mbar add cascade -label "Find" -menu .mbar.find +.mbar add cascade -label Find -menu .mbar.find menu .mbar.windows -postcommand [concat pdtk_fixwindowmenu] -tearoff $pd_tearoff menu .mbar.audio -tearoff $pd_tearoff if {$pd_nt != 2} { @@ -132,11 +123,22 @@ .mbar add cascade -label "Help" -menu .mbar.help } +proc showhide_printouttext {state} { + if {$state} { + pack .printout -side bottom -fill both -expand 1 + } else { + pack forget .printout + } +} + set ctrls_audio_on 0 set ctrls_meter_on 0 set ctrls_inlevel 0 set ctrls_outlevel 0 +set show_text_window 0 +frame .controls +pack .controls -fill x -expand 1 frame .controls.switches checkbutton .controls.switches.audiobutton -text {compute audio} \ -variable ctrls_audio_on \ @@ -148,7 +150,12 @@ -anchor w \ -command {pd [concat pd meters $ctrls_meter_on \;]} -pack .controls.switches.audiobutton .controls.switches.meterbutton -side top +checkbutton .controls.switches.textwindow -text {text window} \ + -variable show_text_window \ + -command {showhide_printouttext $show_text_window} + +pack .controls.switches.audiobutton .controls.switches.meterbutton \ + .controls.switches.textwindow -side top frame .controls.inout frame .controls.inout.in @@ -190,16 +197,35 @@ proc pdtk_standardkeybindings {id} { global pd_nt - bind $id {pdtk_pd_ctrlkey %W %K 0} - bind $id {pdtk_pd_ctrlkey %W %K 1} if {$pd_nt == 2} { bind $id {pdtk_canvas_ctrlkey %W %K 0} bind $id {pdtk_canvas_ctrlkey %W %K 1} + } else { + bind $id {pdtk_pd_ctrlkey %W %K 0} + bind $id {pdtk_pd_ctrlkey %W %K 1} + } +} + +proc pdtk_panelkeybindings {id panelname} { + global pd_nt + pdtk_standardkeybindings $id + bind $id [format "%s_cancel %s" $panelname $id] + bind $id [format "%s_ok %s" $panelname $id] + if {$pd_nt == 2} { + bind $id [format "%s_cancel %s" $panelname $id] + } else { + bind $id [format "%s_cancel %s" $panelname $id] } } pdtk_standardkeybindings . +if {$pd_nt == 2} { + bind .printout.text {puts stderr ARG.printout.text} +} else { + bind .printout.text {puts stderr ARG.printout.text} +} + wm title . "Pd" . configure -menu .mbar -width 200 -height 150 @@ -331,18 +357,29 @@ ################## the "Message" menu command ######################### proc menu_send {} { + global pd_nt + destroy .sendpanel toplevel .sendpanel + pdtk_standardkeybindings .sendpanel entry .sendpanel.entry -textvariable send_textvariable pack .sendpanel.entry -side bottom -fill both -ipadx 100 .sendpanel.entry select from 0 .sendpanel.entry select adjust end + if {$pd_nt == 2} { + bind .sendpanel {destroy .sendpanel} + } else { + bind .sendpanel {destroy .sendpanel} + } + bind .sendpanel {destroy .sendpanel} bind .sendpanel.entry { pd [concat $send_textvariable \;] } - pdtk_standardkeybindings .sendpanel.entry focus .sendpanel.entry } +################## the "Clear Pd window" menu command ######################### +proc menu_clear_pd_window {} {.printout.text delete 0.0 end} + ################## the "Quit" menu command ######################### proc menu_really_quit {} {pd {pd quit;}} @@ -416,10 +453,10 @@ ################## help browser and support functions ######################### -proc menu_doc_browser {dir} { - global .mbar - if {![file isdirectory $dir]} { - puts stderr "menu_doc_browser non-directory $dir\n" +proc menu_doc_browser {} { + global .mbar pd_nt help_top_directory + if {![file isdirectory $help_top_directory]} { + puts stderr "menu_doc_browser non-directory $help_top_directory\n" } if { [winfo exists .help_browser.frame] } { raise .help_browser @@ -428,7 +465,13 @@ wm title .help_browser "Pd Documentation Browser" frame .help_browser.frame pack .help_browser.frame -side top -fill both - doc_make_listbox .help_browser.frame $dir 0 + pdtk_standardkeybindings .help_browser + if {$pd_nt == 2} { + bind .help_browser {destroy .help_browser} + } else { + bind .help_browser {destroy .help_browser} + } + doc_make_listbox .help_browser.frame $help_top_directory 0 } } @@ -549,7 +592,8 @@ $mbar.help add command -label {Html ...} \ -command {menu_doc_open doc/1.manual index.htm} $mbar.help add command -label {Browser ...} \ - -command {menu_doc_browser $help_top_directory} + -accelerator [accel_munge "Ctrl+b"] \ + -command {menu_doc_browser} } #################### the "File" menu for the Pd window ############## @@ -573,7 +617,52 @@ .mbar.file add command -label Quit -command {menu_quit} \ -accelerator [accel_munge "Ctrl+q"] + +#################### the "Edit" menu for the Pd window ############## +# this is mostly a placeholder +.mbar.edit add command -label Undo -accelerator [accel_munge "Ctrl+z"] \ + -state disabled +.mbar.edit add command -label Redo -accelerator [accel_munge "Ctrl+Z"] \ + -state disabled +.mbar.edit add separator +# this should apply to .printout.text +.mbar.edit add command -label Cut -accelerator [accel_munge "Ctrl+x"] \ + -state disabled +# this should apply to .printout.text +.mbar.edit add command -label Copy -accelerator [accel_munge "Ctrl+c"] \ + -state disabled +.mbar.edit add command -label Paste -accelerator [accel_munge "Ctrl+v"] \ + -state disabled +.mbar.edit add command -label Duplicate -accelerator [accel_munge "Ctrl+d"] \ + -state disabled +# this should apply to .printout.text +.mbar.edit add command -label {Select all} -accelerator [accel_munge "Ctrl+a"] \ + -state disabled +.mbar.edit add separator +.mbar.edit add command -label {Text Editor} \ + -accelerator "Ctrl-T" -state disabled +.mbar.edit add command -label Font -state disabled +.mbar.edit add command -label {Tidy Up} -state disabled +.mbar.edit add command -label {Clear Pd window} \ + -accelerator [accel_munge "Ctrl+r"] -command menu_clear_pd_window +.mbar.edit add separator +# this should apply to .printout.text +.mbar.edit add command -label {Find...} -accelerator [accel_munge "Ctrl+f"] \ + -state disabled +# this should apply to .printout.text +.mbar.edit add command -label {Find Again} -accelerator [accel_munge "Ctrl+g"] \ + -state disabled +.mbar.edit add command -label {Find last error} +.mbar.edit add separator +.mbar.edit add command -label {Edit mode} -accelerator [accel_munge "Ctrl+e"] \ + -state disabled + #################### the "Find" menu for the Pd window ############## + +.mbar.find add command -label Find -accelerator [accel_munge "Ctrl+f"] \ + -state disabled +.mbar.find add command -label {Find Again} -accelerator [accel_munge "Ctrl+g"] \ + -state disabled .mbar.find add command -label {Find last error} -command {menu_finderror} ########### functions for menu functions on document windows ######## @@ -802,7 +891,7 @@ set find_string "" set find_count 1 -proc find_apply {name} { +proc find_ok {name} { global find_string global find_canvas regsub -all \; $find_string " _semi_ " find_string2 @@ -830,6 +919,9 @@ toplevel $name + #bind $name "puts stderr \"bind focus $name.entry\"" + pdtk_panelkeybindings $name "find" + label $name.label -text {find...} pack $name.label -side top @@ -841,15 +933,15 @@ button $name.buttonframe.cancel -text {Cancel}\ -command "find_cancel $name" button $name.buttonframe.ok -text {OK}\ - -command "find_apply $name" + -command "find_ok $name" pack $name.buttonframe.cancel -side left -expand 1 pack $name.buttonframe.ok -side left -expand 1 $name.entry select from 0 $name.entry select adjust end - bind $name.entry [ concat find_apply $name] - pdtk_standardkeybindings $name.entry + #puts stderr "before focus $name.entry" focus $name.entry + #puts stderr "after focus $name.entry" } @@ -974,7 +1066,7 @@ $name.m.edit add command -label {Text Editor} \ -command [concat menu_texteditor $name] \ - -accelerator [accel_munge "Ctrl+t"] + -accelerator "Ctrl-T" $name.m.edit add command -label Font \ -command [concat menu_font $name] @@ -982,6 +1074,10 @@ $name.m.edit add command -label {Tidy Up} \ -command [concat menu_tidyup $name] + $name.m.edit add command -label {Clear Pd window} \ + -accelerator [accel_munge "Ctrl+r"] \ + -command [concat menu_clear_pd_window] + $name.m.edit add separator # Apple, Microsoft, and others put find functions in the Edit menu. @@ -1006,7 +1102,8 @@ -accelerator [accel_munge "Ctrl+e"] if { $editable == 0 } { - $name.m.edit entryconfigure "Edit mode" -indicatoron false } + $name.m.edit entryconfigure "Edit mode" -indicatoron false + } ############iemlib################## @@ -1616,11 +1713,13 @@ if {$key == "q" || $key == "Q"} {menu_quit} if {$key == "s" || $key == "S"} {menu_save $topname} if {$key == "z" || $key == "Z"} {menu_undo $topname} + if {$key == "b" || $key == "B"} {menu_doc_browser} if {$key == "n" || $key == "N"} {menu_new} if {$key == "o" || $key == "O"} {menu_open} if {$key == "m" || $key == "M"} {menu_send} if {$key == "w" || $key == "W"} {menu_close $topname} if {$key == "p" || $key == "P"} {menu_print $topname} + if {$key == "r" || $key == "R"} {menu_clear_pd_window} if {$key == "x" || $key == "X"} {menu_cut $topname} if {$key == "c" || $key == "C"} {menu_copy $topname} if {$key == "v" || $key == "V"} {menu_paste $topname} @@ -1704,28 +1803,42 @@ ############ pdtk_canvas_dofont -- run a font and resize dialog ######### set fontsize 0 +set dofont_fontsize 0 set stretchval 0 set whichstretch 0 -proc dofont_apply {name} { - global fontsize +proc dofont_apply {name myfontsize} { global stretchval global whichstretch - set cmd [concat $name font $fontsize $stretchval $whichstretch \;] + set cmd [concat $name font $myfontsize $stretchval $whichstretch \;] +# puts stderr $cmd + pd $cmd +} + +proc dofont_close {name} { + set cmd [concat $name cancel \;] # puts stderr $cmd pd $cmd } proc dofont_cancel {name} { + global fontsize + dofont_apply $name $fontsize set cmd [concat $name cancel \;] # puts stderr $cmd pd $cmd } +proc dofont_ok {name} { + global fontsize dofont_fontsize + set fontsize $dofont_fontsize + dofont_apply $name $fontsize + dofont_close $name +} + proc pdtk_canvas_dofont {name initsize} { - global fontsize - set fontsize $initsize + global dofont_fontsize global stretchval set stretchval 100 @@ -1737,12 +1850,14 @@ wm title $name {FONT BOMB} wm protocol $name WM_DELETE_WINDOW [concat dofont_cancel $name] + pdtk_panelkeybindings $name dofont + frame $name.buttonframe pack $name.buttonframe -side bottom -fill x -pady 2m button $name.buttonframe.cancel -text {Cancel}\ -command "dofont_cancel $name" - button $name.buttonframe.ok -text {Do it}\ - -command "dofont_apply $name" + button $name.buttonframe.ok -text {OK}\ + -command "dofont_ok $name" pack $name.buttonframe.cancel -side left -expand 1 pack $name.buttonframe.ok -side left -expand 1 @@ -1752,12 +1867,18 @@ label $name.radiof.label -text {Font Size:} pack $name.radiof.label -side top - radiobutton $name.radiof.radio8 -value 8 -variable fontsize -text "8" - radiobutton $name.radiof.radio10 -value 10 -variable fontsize -text "10" - radiobutton $name.radiof.radio12 -value 12 -variable fontsize -text "12" - radiobutton $name.radiof.radio16 -value 16 -variable fontsize -text "16" - radiobutton $name.radiof.radio24 -value 24 -variable fontsize -text "24" - radiobutton $name.radiof.radio36 -value 36 -variable fontsize -text "36" + radiobutton $name.radiof.radio8 -value 8 -variable dofont_fontsize -text "8" \ + -command [concat dofont_apply $name 8] + radiobutton $name.radiof.radio10 -value 10 -variable dofont_fontsize -text "10" \ + -command [concat dofont_apply $name 10] + radiobutton $name.radiof.radio12 -value 12 -variable dofont_fontsize -text "12" \ + -command [concat dofont_apply $name 12] + radiobutton $name.radiof.radio16 -value 16 -variable dofont_fontsize -text "16" \ + -command [concat dofont_apply $name 16] + radiobutton $name.radiof.radio24 -value 24 -variable dofont_fontsize -text "24" \ + -command [concat dofont_apply $name 24] + radiobutton $name.radiof.radio36 -value 36 -variable dofont_fontsize -text "36" \ + -command [concat dofont_apply $name 36] pack $name.radiof.radio8 -side top -anchor w pack $name.radiof.radio10 -side top -anchor w pack $name.radiof.radio12 -side top -anchor w @@ -1902,6 +2023,8 @@ wm title $id {Atom} wm protocol $id WM_DELETE_WINDOW [concat dogatom_cancel $id] + pdtk_panelkeybindings $id "dogatom" + frame $id.buttonframe pack $id.buttonframe -side bottom -fill x -pady 2m button $id.buttonframe.cancel -text {Cancel}\ @@ -1973,14 +2096,6 @@ entry $id.params.entry -textvariable $var_gatomwidth -width 4 pack $id.params.entryname $id.params.entry -side left - - - bind $id.paramhi.entry [concat dogatom_ok $id] - bind $id.paramlo.entry [concat dogatom_ok $id] - bind $id.params.entry [concat dogatom_ok $id] - pdtk_standardkeybindings $id.paramhi.entry - pdtk_standardkeybindings $id.paramlo.entry - pdtk_standardkeybindings $id.params.entry $id.params.entry select from 0 $id.params.entry select adjust end focus $id.params.entry @@ -2489,6 +2604,8 @@ wm title $id [format "%s-PROPERTIES" $mainheader] wm protocol $id WM_DELETE_WINDOW [concat iemgui_cancel $id] + pdtk_panelkeybindings $id "iemgui" + frame $id.dim pack $id.dim -side top label $id.dim.head -text $dim_header @@ -2708,31 +2825,6 @@ bind $id <> {tk::TabToWindow [tk_focusPrev %W]} } - bind $id.dim.w_ent [concat iemgui_ok $id] - bind $id.dim.h_ent [concat iemgui_ok $id] - bind $id.rng.min_ent [concat iemgui_ok $id] - bind $id.rng.max_ent [concat iemgui_ok $id] - bind $id.para.num_ent [concat iemgui_ok $id] - bind $id.snd.ent [concat iemgui_ok $id] - bind $id.rcv.ent [concat iemgui_ok $id] - bind $id.gnam.ent [concat iemgui_ok $id] - bind $id.gnxy.x_ent [concat iemgui_ok $id] - bind $id.gnxy.y_ent [concat iemgui_ok $id] - bind $id.gnfs.fs_ent [concat iemgui_ok $id] - bind $id.cao.ok [concat iemgui_ok $id] - pdtk_standardkeybindings $id.dim.w_ent - pdtk_standardkeybindings $id.dim.h_ent - pdtk_standardkeybindings $id.rng.min_ent - pdtk_standardkeybindings $id.rng.max_ent - pdtk_standardkeybindings $id.para.num_ent - pdtk_standardkeybindings $id.snd.ent - pdtk_standardkeybindings $id.rcv.ent - pdtk_standardkeybindings $id.gnam.ent - pdtk_standardkeybindings $id.gnxy.x_ent - pdtk_standardkeybindings $id.gnxy.y_ent - pdtk_standardkeybindings $id.gnfs.fs_ent - pdtk_standardkeybindings $id.cao.ok - $id.dim.w_ent select from 0 $id.dim.w_ent select adjust end focus $id.dim.w_ent @@ -2810,6 +2902,8 @@ wm title $id {array} wm protocol $id WM_DELETE_WINDOW [concat array_cancel $id] + pdtk_panelkeybindings $id "array" + frame $id.name pack $id.name -side top label $id.name.label -text "name" @@ -2876,10 +2970,6 @@ if {$newone == 0} {pack $id.buttonframe.apply -side left -expand 1} pack $id.buttonframe.ok -side left -expand 1 - bind $id.name.entry [concat array_ok $id] - bind $id.n.entry [concat array_ok $id] - pdtk_standardkeybindings $id.name.entry - pdtk_standardkeybindings $id.n.entry $id.name.entry select from 0 $id.name.entry select adjust end focus $id.name.entry @@ -3070,6 +3160,8 @@ wm title $id {canvas} wm protocol $id WM_DELETE_WINDOW [concat canvas_cancel $id] + pdtk_panelkeybindings $id "canvas" + label $id.toplabel -text "Canvas Properties" pack $id.toplabel -side top @@ -3139,10 +3231,6 @@ pack $id.buttonframe.apply -side left -expand 1 pack $id.buttonframe.ok -side left -expand 1 - bind $id.xscale.entry [concat canvas_ok $id] - bind $id.yscale.entry [concat canvas_ok $id] - pdtk_standardkeybindings $id.xscale.entry - pdtk_standardkeybindings $id.yscale.entry $id.xscale.entry select from 0 $id.xscale.entry select adjust end focus $id.xscale.entry @@ -3182,6 +3270,10 @@ wm title $name {Atom} wm protocol $name WM_DELETE_WINDOW [concat dodata_cancel $name] + pdtk_panelkeybindings $name "dodata" + bind $name [concat dodata_ok $name] + bind $name [concat dodata_send $name] + frame $name.buttonframe pack $name.buttonframe -side bottom -fill x -pady 2m button $name.buttonframe.send -text {Send (Ctrl s)}\ @@ -3198,8 +3290,6 @@ pack $name.text -side left -fill both -expand 1 $name.text insert end $stuff focus $name.text - bind $name.text [concat dodata_ok $name] - bind $name.text [concat dodata_send $name] } ############ check or uncheck the "edit" menu item ############## @@ -3375,6 +3465,10 @@ toplevel $name wm title $name {TEXT} + pdtk_standardkeybindings $name + bind $name {texteditor_ok %W} + bind $name {texteditor_send %W} + frame $name.buttons pack $name.buttons -side bottom -fill x -pady 2m button $name.buttons.send -text {Send (Ctrl s)}\ @@ -3391,8 +3485,6 @@ pack $name.text -side left -fill both -expand 1 $name.text insert end $stuff focus $name.text - bind $name.text {texteditor_ok %W} - bind $name.text {texteditor_send %W} } # paste text into a text box @@ -3591,6 +3683,8 @@ wm title $id {audio} wm protocol $id WM_DELETE_WINDOW [concat audio_cancel $id] + pdtk_panelkeybindings $id "audio" + frame $id.buttonframe pack $id.buttonframe -side bottom -fill x -pady 2m button $id.buttonframe.cancel -text {Cancel}\ @@ -3752,17 +3846,9 @@ -command {pd pd audio-properties 1 \;} pack $id.longbutton.b } - bind $id.srf.x1 [concat audio_ok $id] - bind $id.srf.x2 [concat audio_ok $id] - bind $id.in1f.x2 [concat audio_ok $id] - bind $id.out1f.x2 [concat audio_ok $id] $id.srf.x1 select from 0 $id.srf.x1 select adjust end focus $id.srf.x1 - pdtk_standardkeybindings $id.srf.x1 - pdtk_standardkeybindings $id.srf.x2 - pdtk_standardkeybindings $id.in1f.x2 - pdtk_standardkeybindings $id.out1f.x2 } ####################### midi dialog ################## @@ -3841,6 +3927,8 @@ wm title $id {midi} wm protocol $id WM_DELETE_WINDOW [concat midi_cancel $id] + pdtk_panelkeybindings $id "midi" + frame $id.buttonframe pack $id.buttonframe -side bottom -fill x -pady 2m button $id.buttonframe.cancel -text {Cancel}\ @@ -3975,6 +4063,8 @@ wm title $id {midi} wm protocol $id WM_DELETE_WINDOW [concat midi_cancel $id] + pdtk_panelkeybindings $id "midi" + frame $id.buttonframe pack $id.buttonframe -side bottom -fill x -pady 2m button $id.buttonframe.cancel -text {Cancel}\ @@ -4132,6 +4222,8 @@ wm title $id {PD search path for patches and other files} wm protocol $id WM_DELETE_WINDOW [concat path_cancel $id] + pdtk_panelkeybindings $id "path" + frame $id.buttonframe pack $id.buttonframe -side bottom -fill x -pady 2m button $id.buttonframe.cancel -text {Cancel}\ @@ -4157,8 +4249,6 @@ for {set x 0} {$x < 10} {incr x} { entry $id.f$x -textvariable pd_path$x -width 80 - bind $id.f$x [concat path_ok $id] - pdtk_standardkeybindings $id.f$x pack $id.f$x -side top } @@ -4206,6 +4296,8 @@ wm title $id {Pd binaries to load (on next startup)} wm protocol $id WM_DELETE_WINDOW [concat startup_cancel $id] + pdtk_panelkeybindings $id "startup" + frame $id.buttonframe pack $id.buttonframe -side bottom -fill x -pady 2m button $id.buttonframe.cancel -text {Cancel}\ @@ -4222,8 +4314,6 @@ pack $id.flags -side bottom label $id.flags.entryname -text {startup flags} entry $id.flags.entry -textvariable pd_flags -width 80 - bind $id.flags.entry [concat startup_ok $id] - pdtk_standardkeybindings $id.flags.entry pack $id.flags.entryname $id.flags.entry -side left frame $id.nortframe @@ -4242,8 +4332,6 @@ for {set x 0} {$x < 10} {incr x} { entry $id.f$x -textvariable pd_startup$x -width 80 - bind $id.f$x [concat startup_ok $id] - pdtk_standardkeybindings $id.f$x pack $id.f$x -side top }