From 5c2f8f45fc6369c89b62ff0d2f38d3007cd8eecb Mon Sep 17 00:00:00 2001 From: Miller Puckette <msp@ucsd.edu> Date: Tue, 18 Sep 2007 10:33:49 -0700 Subject: [PATCH] expand detabbing to *.tk --- linux/detab-src.sh | 2 +- src/g_all_guis.c | 2 +- src/g_bang.c | 2 +- src/g_graph.c | 2 +- src/g_hslider.c | 2 +- src/g_mycanvas.c | 4 +- src/g_numbox.c | 2 +- src/g_template.c | 2 +- src/g_toggle.c | 2 +- src/g_vslider.c | 2 +- src/g_vumeter.c | 14 ++--- src/s_inter.c | 2 +- src/s_main.c | 16 +++--- src/u_main.tk | 126 ++++++++++++++++++++++----------------------- 14 files changed, 91 insertions(+), 89 deletions(-) diff --git a/linux/detab-src.sh b/linux/detab-src.sh index b943abc8c..771781471 100755 --- a/linux/detab-src.sh +++ b/linux/detab-src.sh @@ -1,5 +1,5 @@ #! /bin/sh -for i in `find . -name "*.[ch]"` ; do +for i in `find . -name "*.[ch]" -o -name "*.tk"` ; do expand $i > /tmp/foo if ( ! cmp -s $i /tmp/foo ) ; then echo detabbing: $i diff --git a/src/g_all_guis.c b/src/g_all_guis.c index 0547b0de7..d520603e8 100644 --- a/src/g_all_guis.c +++ b/src/g_all_guis.c @@ -448,7 +448,7 @@ void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *a if(glist_isvisible(iemgui->x_glist)) sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} %d %s}\n", glist_getcanvas(iemgui->x_glist), x, iemgui->x_font, - iemgui->x_fontsize, sys_fontweight); + iemgui->x_fontsize, sys_fontweight); } void iemgui_size(void *x, t_iemgui *iemgui) diff --git a/src/g_bang.c b/src/g_bang.c index cd4b71291..d02c20f55 100644 --- a/src/g_bang.c +++ b/src/g_bang.c @@ -60,7 +60,7 @@ void bng_draw_new(t_bng *x, t_glist *glist) ypos+x->x_gui.x_ldy, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x); + x->x_gui.x_lcol, x); if(!x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n", canvas, xpos, diff --git a/src/g_graph.c b/src/g_graph.c index 7db14b5e6..88a98d625 100644 --- a/src/g_graph.c +++ b/src/g_graph.c @@ -828,7 +828,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis) (int)glist_xtopixels(x, atof(x->gl_xlabel[i]->s_name)), (int)glist_ytopixels(x, x->gl_xlabely), x->gl_xlabel[i]->s_name, sys_font, - glist_getfont(x), sys_fontweight, tag); + glist_getfont(x), sys_fontweight, tag); /* draw y labels */ for (i = 0; i < x->gl_nylabels; i++) diff --git a/src/g_hslider.c b/src/g_hslider.c index cc776be41..b5b446987 100644 --- a/src/g_hslider.c +++ b/src/g_hslider.c @@ -81,7 +81,7 @@ static void hslider_draw_new(t_hslider *x, t_glist *glist) ypos+x->x_gui.x_ldy, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x); + x->x_gui.x_lcol, x); if(!x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n", canvas, xpos-3, ypos + x->x_gui.x_h-1, diff --git a/src/g_mycanvas.c b/src/g_mycanvas.c index 50abdcabf..2dbf91f36 100644 --- a/src/g_mycanvas.c +++ b/src/g_mycanvas.c @@ -48,7 +48,7 @@ void my_canvas_draw_new(t_my_canvas *x, t_glist *glist) canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x); + x->x_gui.x_lcol, x); } void my_canvas_draw_move(t_my_canvas *x, t_glist *glist) @@ -87,7 +87,7 @@ void my_canvas_draw_config(t_my_canvas* x, t_glist* glist) x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_bcol); sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} %d %s} -fill #%6.6x -text {%s} \n", canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, + x->x_gui.x_lcol, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); } diff --git a/src/g_numbox.c b/src/g_numbox.c index 099acc301..03671e570 100644 --- a/src/g_numbox.c +++ b/src/g_numbox.c @@ -199,7 +199,7 @@ static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist) canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x); + x->x_gui.x_lcol, x); my_numbox_ftoa(x); sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ -font {{%s} %d %s} -fill #%6.6x -tags %lxNUMBER\n", diff --git a/src/g_template.c b/src/g_template.c index fecb805f1..4613d4153 100644 --- a/src/g_template.c +++ b/src/g_template.c @@ -2137,7 +2137,7 @@ static void drawnumber_vis(t_gobj *z, t_glist *glist, sys_vgui(".x%lx.c create text %d %d -anchor nw -fill %s -text {%s}", glist_getcanvas(glist), xloc, yloc, colorstring, buf); sys_vgui(" -font {{%s} %d %s}", sys_font, - sys_hostfontsize(glist_getfont(glist)), sys_fontweight); + sys_hostfontsize(glist_getfont(glist)), sys_fontweight); sys_vgui(" -tags drawnumber%lx\n", data); } else sys_vgui(".x%lx.c delete drawnumber%lx\n", glist_getcanvas(glist), data); diff --git a/src/g_toggle.c b/src/g_toggle.c index c0c36f1ac..4473adcc6 100644 --- a/src/g_toggle.c +++ b/src/g_toggle.c @@ -66,7 +66,7 @@ void toggle_draw_new(t_toggle *x, t_glist *glist) yy+x->x_gui.x_ldy, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x); + x->x_gui.x_lcol, x); if(!x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n", canvas, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h, x, 0); diff --git a/src/g_vslider.c b/src/g_vslider.c index a5b9cc860..e7f1a8e12 100644 --- a/src/g_vslider.c +++ b/src/g_vslider.c @@ -63,7 +63,7 @@ static void vslider_draw_new(t_vslider *x, t_glist *glist) canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x); + x->x_gui.x_lcol, x); if(!x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n", canvas, diff --git a/src/g_vumeter.c b/src/g_vumeter.c index 813e63c97..f0fb5ea50 100644 --- a/src/g_vumeter.c +++ b/src/g_vumeter.c @@ -118,7 +118,7 @@ static void vu_draw_new(t_vu *x, t_glist *glist) sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ -font {{%s} %d %s} -fill #%6.6x -tags %lxSCALE%d\n", canvas, end, yyy+k3, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, + x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, i); } if(x->x_scale) @@ -128,7 +128,7 @@ static void vu_draw_new(t_vu *x, t_glist *glist) sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ -font {{%s} %d %s} -fill #%6.6x -tags %lxSCALE%d\n", canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, - x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, i); } sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %lxRCOVER\n", @@ -142,7 +142,7 @@ static void vu_draw_new(t_vu *x, t_glist *glist) canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x); + x->x_gui.x_lcol, x); if(!x->x_gui.x_fsf.x_snd_able) { sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n", @@ -279,7 +279,7 @@ static void vu_draw_config(t_vu* x, t_glist* glist) if(((i+2)&3) && (x->x_scale)) sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} -font {{%s} %d %s} -fill #%6.6x\n", canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, - x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol); } if(x->x_scale) @@ -287,7 +287,7 @@ static void vu_draw_config(t_vu* x, t_glist* glist) i=IEM_VU_STEPS+1; sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} -font {{%s} %d %s} -fill #%6.6x\n", canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, - x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol); } sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} %d %s} -fill #%6.6x -text {%s} \n", @@ -483,7 +483,7 @@ static void vu_scale(t_vu *x, t_floatarg fscale) sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ -font {{%s} %d %s} -fill #%6.6x -tags %lxSCALE%d\n", canvas, end, yyy+k3, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, + x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, i); } i=IEM_VU_STEPS+1; @@ -491,7 +491,7 @@ static void vu_scale(t_vu *x, t_floatarg fscale) sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ -font {{%s} %d %s} -fill #%6.6x -tags %lxSCALE%d\n", canvas, end, yyy+k3, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, sys_fontweight, x->x_gui.x_lcol, x, i); } } diff --git a/src/s_inter.c b/src/s_inter.c index bbfaf23f3..0cfa860b2 100644 --- a/src/s_inter.c +++ b/src/s_inter.c @@ -1258,7 +1258,7 @@ int sys_startgui(const char *guidir) sys_get_audio_apis(buf); sys_get_midi_apis(buf2); sys_vgui("pdtk_pd_startup {%s} %s %s {%s} %s\n", pd_version, buf, buf2, - sys_font, sys_fontweight); + sys_font, sys_fontweight); } return (0); diff --git a/src/s_main.c b/src/s_main.c index de282d043..2cdb8acfc 100644 --- a/src/s_main.c +++ b/src/s_main.c @@ -58,10 +58,11 @@ int sys_nmidiin = -1; int sys_midiindevlist[MAXMIDIINDEV] = {1}; int sys_midioutdevlist[MAXMIDIOUTDEV] = {1}; -#ifdef __APPLE__ -char sys_font[] = "Monaco"; /* tb: font name */ +char sys_font[100] = +#ifdef MSW + "courier"; #else -char sys_font[] = "Bitstream Vera Sans Mono"; /* tb: font name */ + "Bitstream Vera Sans Mono"; #endif char sys_fontweight[] = "normal"; /* currently only used for iemguis */ static int sys_main_srate; @@ -765,10 +766,11 @@ int sys_argparse(int argc, char **argv) } else if (!strcmp(*argv, "-font-weight") && argc > 1) { - strcpy(sys_fontweight,*(argv+1)); - argc -= 2; - argv += 2; - } + strncpy(sys_fontweight,*(argv+1),sizeof(sys_fontweight)-1); + sys_font[sizeof(sys_fontweight)-1] = 0; + argc -= 2; + argv += 2; + } else if (!strcmp(*argv, "-verbose")) { sys_verbose++; diff --git a/src/u_main.tk b/src/u_main.tk index 8da3b4503..73be5db4c 100644 --- a/src/u_main.tk +++ b/src/u_main.tk @@ -64,7 +64,7 @@ if {$pd_nt == 2} { # turn on James Tittle II's fast drawing set tk::mac::useCGDrawing 1 # anti-alias all lines that need it - set tk::mac::CGAntialiasLimit 0 + set tk::mac::CGAntialiasLimit 2 global pd_guidir global pd_tearoff set pd_gui2 [string range $argv0 0 [expr [string last / $argv0 ] - 1]] @@ -441,72 +441,72 @@ proc menu_doc_open {subdir basename} { ################## 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" - } - if { [winfo exists .help_browser.frame] } { - raise .help_browser - } else { - toplevel .help_browser -menu .mbar - 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 + global .mbar + if {![file isdirectory $dir]} { + puts stderr "menu_doc_browser non-directory $dir\n" + } + if { [winfo exists .help_browser.frame] } { + raise .help_browser + } else { + toplevel .help_browser -menu .mbar + 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 } } proc doc_make_listbox {base dir count} { - # check for [file readable]? - #if { [info tclversion] >= 8.5 } { - # requires Tcl 8.5 but probably deals with special chars better -# destroy {expand}[lrange [winfo children $base] [expr {2 * $count}] end] - #} else { - if { [catch { eval destroy [lrange [winfo children $base] \ - [expr { 2 * $count }] end] } \ - errorMessage] } { - puts stderr "doc_make_listbox: error listing $dir\n" - } - #} - # exportselection 0 looks good, but selection gets easily out-of-sync - set current_listbox [listbox "[set b "$base.listbox$count"]-list" -yscrollcommand \ - [list "$b-scroll" set] -height 20 -exportselection 0] - pack $current_listbox [scrollbar "$b-scroll" -command [list $current_listbox yview]] \ - -side left -expand 1 -fill y -anchor w - foreach item [concat [lsort -dictionary [glob -directory $dir -nocomplain -types {d} -- *]] \ - [lsort -dictionary [glob -directory $dir -nocomplain -types {f} -- *]]] { - $current_listbox insert end "[file tail $item][expr {[file isdirectory $item] ? {/} : {}}]" - } - bind $current_listbox <Button-1> [list doc_navigate $dir $count %W %x %y] - bind $current_listbox <Double-Button-1> [list doc_double_button $dir $count %W %x %y] + # check for [file readable]? + #if { [info tclversion] >= 8.5 } { + # requires Tcl 8.5 but probably deals with special chars better +# destroy {expand}[lrange [winfo children $base] [expr {2 * $count}] end] + #} else { + if { [catch { eval destroy [lrange [winfo children $base] \ + [expr { 2 * $count }] end] } \ + errorMessage] } { + puts stderr "doc_make_listbox: error listing $dir\n" + } + #} + # exportselection 0 looks good, but selection gets easily out-of-sync + set current_listbox [listbox "[set b "$base.listbox$count"]-list" -yscrollcommand \ + [list "$b-scroll" set] -height 20 -exportselection 0] + pack $current_listbox [scrollbar "$b-scroll" -command [list $current_listbox yview]] \ + -side left -expand 1 -fill y -anchor w + foreach item [concat [lsort -dictionary [glob -directory $dir -nocomplain -types {d} -- *]] \ + [lsort -dictionary [glob -directory $dir -nocomplain -types {f} -- *]]] { + $current_listbox insert end "[file tail $item][expr {[file isdirectory $item] ? {/} : {}}]" + } + bind $current_listbox <Button-1> [list doc_navigate $dir $count %W %x %y] + bind $current_listbox <Double-Button-1> [list doc_double_button $dir $count %W %x %y] } proc doc_navigate {dir count width x y} { - if {[set newdir [$width get [$width index "@$x,$y"]]] eq {}} { - return - } - set dir_to_open [file join $dir $newdir] - if {[file isdirectory $dir_to_open]} { - doc_make_listbox [winfo parent $width] $dir_to_open [incr count] - } + if {[set newdir [$width get [$width index "@$x,$y"]]] eq {}} { + return + } + set dir_to_open [file join $dir $newdir] + if {[file isdirectory $dir_to_open]} { + doc_make_listbox [winfo parent $width] $dir_to_open [incr count] + } } proc doc_double_button {dir count width x y} { - global pd_guidir - if {[set newdir [$width get [$width index "@$x,$y"]]] eq {}} { - return - } - set dir_to_open [file join $dir $newdir] - if {[file isdirectory $dir_to_open]} { - doc_navigate $dir $count $width $x $y - } else { - regsub -- $pd_guidir [file dirname $dir_to_open] "" subdir - set file [file tail $dir_to_open] - if { [catch {menu_doc_open $subdir $file} fid] } { - puts stderr "Could not open $pd_guidir/$subdir/$file\n" - } - return; - } + global pd_guidir + if {[set newdir [$width get [$width index "@$x,$y"]]] eq {}} { + return + } + set dir_to_open [file join $dir $newdir] + if {[file isdirectory $dir_to_open]} { + doc_navigate $dir $count $width $x $y + } else { + regsub -- $pd_guidir [file dirname $dir_to_open] "" subdir + set file [file tail $dir_to_open] + if { [catch {menu_doc_open $subdir $file} fid] } { + puts stderr "Could not open $pd_guidir/$subdir/$file\n" + } + return; + } } ############# routine to add media, help, and apple menu items ############### @@ -3376,17 +3376,17 @@ proc pdtk_pd_startup {version apilist midiapilist fontname_from_pd fontweight_fr set width0 [font measure $font x] set height0 [lindex [font metrics $font] 5] set fontlist [concat $fontlist $i [font measure $font x] \ - [lindex [font metrics $font] 5]] + [lindex [font metrics $font] 5]] } set tclpatch [info patchlevel] if {$tclpatch == "8.3.0" || \ - $tclpatch == "8.3.1" || \ - $tclpatch == "8.3.2" || \ - $tclpatch == "8.3.3" } { - set oldtclversion 1 + $tclpatch == "8.3.1" || \ + $tclpatch == "8.3.2" || \ + $tclpatch == "8.3.3" } { + set oldtclversion 1 } else { - set oldtclversion 0 + set oldtclversion 0 } pd [concat pd init [pdtk_enquote [pwd]] $oldtclversion $fontlist \;]; -- GitLab