[PD-cvs] SF.net SVN: pure-data: [9942] branches/pd-extended/v0-40/pd/src/u_main.tk

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Thu May 29 17:11:16 CEST 2008


Revision: 9942
          http://pure-data.svn.sourceforge.net/pure-data/?rev=9942&view=rev
Author:   eighthave
Date:     2008-05-29 08:11:15 -0700 (Thu, 29 May 2008)

Log Message:
-----------
- added Ctrl-[axcv] key bindings and menu items to the Pd window, so you can
  manipulate the text normally

- added $ctrl_key variable as an idea to replace proc accel_munge

Modified Paths:
--------------
    branches/pd-extended/v0-40/pd/src/u_main.tk

Modified: branches/pd-extended/v0-40/pd/src/u_main.tk
===================================================================
--- branches/pd-extended/v0-40/pd/src/u_main.tk	2008-05-29 12:14:02 UTC (rev 9941)
+++ branches/pd-extended/v0-40/pd/src/u_main.tk	2008-05-29 15:11:15 UTC (rev 9942)
@@ -14,6 +14,7 @@
 # set pd_nt (bad name) 0 for unix, 1 for microsoft, and 2 for Mac OSX.
 if { $tcl_platform(platform) == "windows" }  {
     set pd_nt 1
+    set ctrl_key "Control"
     # fonts
     set defaultFontFamily {Bitstream Vera Sans Mono}
     font create menuFont -family Tahoma -size 11
@@ -32,6 +33,7 @@
 	}
 } elseif { $tcl_platform(os) == "Darwin" } {  
     set pd_nt 2
+	set ctrl_key "Mod1"
     # fonts
     set defaultFontFamily Monaco
     # mouse cursors
@@ -49,6 +51,7 @@
 	}
 } else { 
     set pd_nt 0
+    set ctrl_key "Control"
     # fonts
     set defaultFontFamily {Bitstream Vera Sans Mono}
     # mouse cursors
@@ -325,29 +328,24 @@
 }
 
 proc pdtk_standardkeybindings {id} {
-    global pd_nt
-    if {$pd_nt == 2} {
-        bind $id <Mod1-Key> {pdtk_canvas_ctrlkey %W %K 0}
-        bind $id <Mod1-Shift-Key> {pdtk_canvas_ctrlkey %W %K 1}
-    } else {
-        bind $id <Control-Key> {pdtk_pd_ctrlkey %W %K 0}
-        bind $id <Control-Shift-Key> {pdtk_pd_ctrlkey %W %K 1}
-    }
+    global pd_nt ctrl_key
+    bind $id <$ctrl_key-Key> {pdtk_canvas_ctrlkey %W %K 0}
+    bind $id <$ctrl_key-Shift-Key> {pdtk_canvas_ctrlkey %W %K 1}
 }
 
 proc pdtk_panelkeybindings {id panelname} {
-    global pd_nt
+    global pd_nt ctrl_key
     pdtk_standardkeybindings $id
     bind $id <KeyPress-Escape> [format "%s_cancel %s" $panelname $id]
     bind $id <KeyPress-Return> [format "%s_ok %s" $panelname $id]
-    if {$pd_nt == 2} {
-        bind $id <Mod1-Key-w> [format "%s_cancel %s" $panelname $id]
-    } else {
-        bind $id <Control-Key-w> [format "%s_cancel %s" $panelname $id]
-    }
+    bind $id <$ctrl_key-Key-w> [format "%s_cancel %s" $panelname $id]
 }
 
 pdtk_standardkeybindings .
+bind . <$ctrl_key-Key-a> {.printout.text tag add sel 1.0 end}
+bind . <$ctrl_key-Key-x> {tk_textCut .printout.text}
+bind . <$ctrl_key-Key-c> {tk_textCopy .printout.text}
+bind . <$ctrl_key-Key-v> {tk_textPaste .printout.text}
 
 wm title . "Pd"
 # initial location of Pd window (+x+y)
@@ -494,7 +492,7 @@
 
 ################## the "Message" menu command #########################
 proc menu_send {} {
-    global pd_nt
+    global pd_nt ctrl_key
     destroy .sendpanel
     toplevel .sendpanel
     pdtk_standardkeybindings .sendpanel
@@ -502,11 +500,7 @@
     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 <Mod1-Key-w> {destroy .sendpanel}
-    } else {
-        bind .sendpanel <Control-Key-w> {destroy .sendpanel}
-    }
+    bind .sendpanel <$ctrl_key-Key-w> {destroy .sendpanel}
     bind .sendpanel <KeyPress-Escape> {destroy .sendpanel}
     bind .sendpanel.entry <KeyPress-Return> {
         pd [concat $send_textvariable \;]
@@ -639,7 +633,7 @@
 
 ################## help browser and support functions #########################
 proc menu_doc_browser {} {
-    global .mbar pd_nt help_top_directory
+    global .mbar pd_nt ctrl_key help_top_directory
     if {![file isdirectory $help_top_directory]} {
         puts stderr "menu_doc_browser non-directory $help_top_directory\n"
     }
@@ -651,11 +645,7 @@
         frame .help_browser.frame
         pack .help_browser.frame -side top -fill both
         pdtk_standardkeybindings .help_browser
-        if {$pd_nt == 2} {
-            bind .help_browser <Mod1-Key-w> {destroy .help_browser}
-        } else {
-            bind .help_browser <Control-Key-w> {destroy .help_browser}
-        }
+        bind .help_browser <$ctrl_key-Key-w> {destroy .help_browser}
         doc_make_listbox .help_browser.frame $help_top_directory 0
     }
 }
@@ -841,17 +831,17 @@
 .mbar.edit add separator
 # this should apply to .printout.text
 .mbar.edit add command -label Cut  -accelerator [accel_munge "Ctrl+x"] \
-    -state disabled
+    -command {tk_textCut .printout.text}
 # this should apply to .printout.text
 .mbar.edit add command -label Copy -accelerator [accel_munge "Ctrl+c"] \
-    -state disabled
+    -command {tk_textCopy .printout.text}
 .mbar.edit add command -label Paste -accelerator [accel_munge "Ctrl+v"] \
-    -state disabled
+    -command {tk_textPaste .printout.text}
 .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 command -label {Select all} -accelerator [accel_munge "Ctrl+a"]\
+    -command {.printout.text tag add sel 1.0 end}
 .mbar.edit add separator
 if {$pd_nt == 2} { # no key command for Mac OS X
 	.mbar.edit add command -label {Text Editor} -state disabled


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list