[PD-cvs] SF.net SVN: pure-data:[10466] branches/pd-devel/0.41.4/src

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Fri Dec 26 10:13:30 CET 2008


Revision: 10466
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10466&view=rev
Author:   eighthave
Date:     2008-12-26 09:13:30 +0000 (Fri, 26 Dec 2008)

Log Message:
-----------
- created new package for key and event bindings

- added new packages to pkgIndex

Modified Paths:
--------------
    branches/pd-devel/0.41.4/src/pd.tk
    branches/pd-devel/0.41.4/src/pd_menus.tcl
    branches/pd-devel/0.41.4/src/pkgIndex.tcl

Added Paths:
-----------
    branches/pd-devel/0.41.4/src/pd_bindings.tcl

Modified: branches/pd-devel/0.41.4/src/pd.tk
===================================================================
--- branches/pd-devel/0.41.4/src/pd.tk	2008-12-26 08:04:34 UTC (rev 10465)
+++ branches/pd-devel/0.41.4/src/pd.tk	2008-12-26 09:13:30 UTC (rev 10466)
@@ -10,29 +10,31 @@
 #namespace import -force ttk::*
 
 # set . as first dir in auto_path
-set auto_path [linsert $auto_path 0 .]
+set auto_path [linsert $auto_path 0 "/Users/hans/code/pure-data/branches/pd-devel/0.41.4/src"]
+set auto_path [linsert $auto_path 0 "."]
 
 package require pd_menus
+package require pd_bindings
 
 # ------------------------------------------------------------------------------
 # global variables
 
-# for displaying on menus
-set accelerator "Ctrl"
-# for key bindings
-set modifier "Control"
 
-
 # ------------------------------------------------------------------------------
 # init functions
 
 proc init {} {
 	switch -- [tk windowingsystem] {
 		"x11" {
+			# load the dialog once, otherwise setting the vars will not work
+			catch {tk_getOpenFile -with-invalid-argument} 
+			# add control to show/hide hidden files
+			namespace eval ::tk::dialog::file {
+				variable showHiddenBtn 1
+				variable showHiddenVar 0
+			}
 		}
 		"aqua" {
-			global modifier
-			set modifier "Mod1"
 		}
 		"win32" {
 			font create menufont -family Tahoma -size -11
@@ -48,6 +50,7 @@
 	toplevel $canvas_name -width $width -height $height
 	::pd_menus::create_menubar $canvas_name.menubar
 	$canvas_name configure -menu $canvas_name.menubar
+	::pd_bindings::canvas_bindings $canvas_name
 }
 
 # ------------------------------------------------------------------------------
@@ -56,11 +59,11 @@
 	init
 
 	wm title . "Pd-devel"
-	wm protocol . WM_DELETE_WINDOW menu_quit
 
 	::pd_menus::create_menubar .menubar
 	. configure -menu .menubar -width 400 -height 250
 	::pd_menus::configure_pdwindow .menubar
+	::pd_bindings::window_bindings .
 }
 
 main

Added: branches/pd-devel/0.41.4/src/pd_bindings.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pd_bindings.tcl	                        (rev 0)
+++ branches/pd-devel/0.41.4/src/pd_bindings.tcl	2008-12-26 09:13:30 UTC (rev 10466)
@@ -0,0 +1,107 @@
+package provide pd_bindings 0.1
+
+package require pd_menucommands
+
+namespace eval ::pd_bindings:: {
+	# for key bindings
+	if {[tk windowingsystem] eq "aqua"} {
+		variable modifier "Mod1"
+	} else {
+		variable modifier "Control"
+	}
+
+	namespace export window_bindings
+	namespace export panel_bindings
+	namespace export canvas_bindings
+}
+
+proc ::pd_bindings::window_bindings {name} {
+	variable modifier
+
+	# File menu
+	bind $name <$modifier-Key-b> {menu_helpbrowser}
+	bind $name <$modifier-Key-n> {menu_new}
+	bind $name <$modifier-Key-o> {menu_open}
+	bind $name <$modifier-Key-p> {menu_print $name}
+	bind $name <$modifier-Key-q> {menu_quit}
+	bind $name <$modifier-Key-r> {menu_raiseconsole}
+	bind $name <$modifier-Key-w> {menu_close $name}
+	bind $name <$modifier-Shift-Key-L> {menu_clear_console}
+	bind $name <$modifier-Shift-Key-R> {menu_toggle_console}	
+
+	# DSP control
+	bind $name <$modifier-Key-slash> {menu_audio 1}
+	bind $name <$modifier-Key-period> {menu_audio 0}
+}
+
+proc ::pd_bindings::pdwindow_bindings {name} {
+	variable modifier
+
+	window_bindings $name
+
+	bind . <$modifier-Key-a> {.printout.text tag add sel 1.0 end}
+	bind . <$modifier-Key-x> {tk_textCut .printout.text}
+	bind . <$modifier-Key-c> {tk_textCopy .printout.text}
+	bind . <$modifier-Key-v> {tk_textPaste .printout.text}
+	bind . <$modifier-Key-w> {pdtk_post "Can't close Pd window, ignored.\n"}
+
+	# event bindings
+	wm protocol . WM_DELETE_WINDOW menu_quit
+}
+
+proc ::pd_bindings::panel_bindings {name} {
+	variable modifier
+
+	window_bindings $name
+
+#    bind $name <KeyPress-Escape> [format "%s_cancel %s" $panelname $name]
+#    bind $name <KeyPress-Return> [format "%s_ok %s" $panelname $name]
+#    bind $name <$modifier_key-Key-w> [format "%s_cancel %s" $panelname $name]
+}
+
+proc ::pd_bindings::canvas_bindings {name} {
+	variable modifier
+
+	window_bindings $name
+
+	bind $name <$modifier-Key-1> {menu_object $name 1}
+	bind $name <$modifier-Key-2> {menu_message $name 1}
+	bind $name <$modifier-Key-3> {menu_floatatom $name 1}
+	bind $name <$modifier-Key-4> {menu_symbolatom $name 1}
+	bind $name <$modifier-Key-5> {menu_comment $name 1}
+	bind $name <$modifier-Key-a> {menu_selectall $name}
+	bind $name <$modifier-Key-c> {menu_copy $name}
+	bind $name <$modifier-Key-d> {menu_duplicate $name}
+	bind $name <$modifier-Key-e> {menu_editmode $name}
+	bind $name <$modifier-Key-f> {menu_findobject $name}
+	bind $name <$modifier-Key-g> {menu_findagain $name}
+	bind $name <$modifier-Key-s> {menu_save $name}
+	bind $name <$modifier-Key-v> {menu_paste $name}
+	bind $name <$modifier-Key-x> {menu_cut $name}
+	bind $name <$modifier-Key-z> {menu_undo $name}
+
+	# annoying, but Tk's bind needs uppercase letter to get the Shift
+	bind $name <$modifier-Shift-Key-B> {menu_bang}
+	bind $name <$modifier-Shift-Key-C> {menu_canvas}
+	bind $name <$modifier-Shift-Key-D> {menu_vradio}
+	bind $name <$modifier-Shift-Key-H> {menu_hslider}
+	bind $name <$modifier-Shift-Key-I> {menu_hradio}
+	bind $name <$modifier-Shift-Key-N> {menu_number2}
+	bind $name <$modifier-Shift-Key-S> {menu_saveas $name}
+	bind $name <$modifier-Shift-Key-T> {menu_toggle}
+	bind $name <$modifier-Shift-Key-U> {menu_vumeter}
+	bind $name <$modifier-Shift-Key-V> {menu_vslider}
+	bind $name <$modifier-Shift-Key-Z> {menu_redo $name}
+
+	if {[tk windowingsystem] eq "aqua"} {
+		bind $name <Mod1-Key-m>      {menu_minimize $name}
+		bind $name <Mod1-Key-t>      {menu_font $name}
+	} else {
+		bind $name <Control-Key-m>   {menu_send $name}
+		bind $name <Control-Key-t>   {menu_texteditor $name}
+	}
+
+	# event bindings
+	wm protocol $name WM_DELETE_WINDOW {menu_close $name}
+}
+

Modified: branches/pd-devel/0.41.4/src/pd_menus.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pd_menus.tcl	2008-12-26 08:04:34 UTC (rev 10465)
+++ branches/pd-devel/0.41.4/src/pd_menus.tcl	2008-12-26 09:13:30 UTC (rev 10466)
@@ -21,7 +21,7 @@
 
 namespace eval ::pd_menus:: {
 	if {[tk windowingsystem] eq "aqua"} {
-		variable accelerator "Mod1"
+		variable accelerator "Meta"
 	} else {
 		variable accelerator "Ctrl"
 	}
@@ -153,10 +153,17 @@
 	$rootmenu add command -label "Select All" -accelerator "$accelerator+A" \
 		-command {menu_selectall $name}
 	$rootmenu add  separator
-	$rootmenu add command -label "Text Editor" -accelerator "$accelerator+T" \
-		-command {menu_texteditor $name}
-	$rootmenu add command -label "Font" \
-		-command {menu_font $name}
+	if {[tk windowingsystem] eq "aqua"} {
+		$rootmenu add command -label "Text Editor" \
+			-command {menu_texteditor $name}
+		$rootmenu add command -label "Font"  -accelerator "$accelerator+T" \
+			-command {menu_font $name}
+	} else {
+		$rootmenu add command -label "Text Editor" -accelerator "$accelerator+T"\
+			-command {menu_texteditor $name}
+		$rootmenu add command -label "Font" \
+			-command {menu_font $name}
+	}
 	$rootmenu add command -label "Tidy Up" \
 		-command {menu_tidyup $name}
 	$rootmenu add command -label "Toggle Console" -accelerator "Shift+$accelerator+R" \
@@ -200,7 +207,7 @@
 		-command {menu_vradio $name 0}
 	$rootmenu add command -label "Hradio"  -accelerator "Shift+$accelerator+I" \
 		-command {menu_hradio $name 0}
-	$rootmenu add command -label "VU"      -accelerator "Shift+$accelerator+U" \
+	$rootmenu add command -label "VU Meter" -accelerator "Shift+$accelerator+U"\
 		-command {menu_vumeter $name 0}
 	$rootmenu add command -label "Canvas"  -accelerator "Shift+$accelerator+C" \
 		-command {menu_mycnv $name 0}

Modified: branches/pd-devel/0.41.4/src/pkgIndex.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pkgIndex.tcl	2008-12-26 08:04:34 UTC (rev 10465)
+++ branches/pd-devel/0.41.4/src/pkgIndex.tcl	2008-12-26 09:13:30 UTC (rev 10466)
@@ -8,6 +8,7 @@
 # script is sourced, the variable $dir must contain the
 # full path name of this file's directory.
 
+package ifneeded pd_bindings 0.1 [list source [file join $dir pd_bindings.tcl]]
 package ifneeded pd_iemgui 0.1 [list source [file join $dir pd_iemgui.tcl]]
 package ifneeded pd_menucommands 0.1 [list source [file join $dir pd_menucommands.tcl]]
 package ifneeded pd_menus 0.1 [list source [file join $dir pd_menus.tcl]]


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