diff options
author | Miller Puckette <millerpuckette@users.sourceforge.net> | 2008-09-20 00:30:48 +0000 |
---|---|---|
committer | Miller Puckette <millerpuckette@users.sourceforge.net> | 2008-09-20 00:30:48 +0000 |
commit | 4f51fe6574a7d46ddb95bb85e1053e86c2fb805a (patch) | |
tree | 79dbdbd418f6755bd22ee5437e56f897bcab4ffc /pd/src | |
parent | 59c8e59dce8fc86ba4d07e91984c6a3dd43bc73e (diff) |
pd 0.42-0 test 05
svn path=/trunk/; revision=10301
Diffstat (limited to 'pd/src')
-rw-r--r-- | pd/src/g_canvas.c | 4 | ||||
-rw-r--r-- | pd/src/g_canvas.h | 2 | ||||
-rw-r--r-- | pd/src/g_editor.c | 42 | ||||
-rw-r--r-- | pd/src/g_scalar.c | 9 | ||||
-rw-r--r-- | pd/src/g_template.c | 2 | ||||
-rw-r--r-- | pd/src/m_binbuf.c | 28 | ||||
-rw-r--r-- | pd/src/m_pd.h | 2 | ||||
-rw-r--r-- | pd/src/makefile.nt | 3 | ||||
-rw-r--r-- | pd/src/notes.txt | 20 | ||||
-rw-r--r-- | pd/src/s_audio_alsamm.c | 15 | ||||
-rw-r--r-- | pd/src/s_audio_pa.c | 5 | ||||
-rw-r--r-- | pd/src/s_path.c | 13 | ||||
-rw-r--r-- | pd/src/s_stuff.h | 2 | ||||
-rw-r--r-- | pd/src/t_tkcmd.c | 16 | ||||
-rw-r--r-- | pd/src/u_main.tk | 109 | ||||
-rw-r--r-- | pd/src/x_interface.c | 27 |
16 files changed, 199 insertions, 100 deletions
diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 3220360f..6838832e 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -63,6 +63,8 @@ static t_atom *canvas_newargv; static void glist_doupdatewindowlist(t_glist *gl, char *sbuf) { t_gobj *g; + if (glist_amreloadingabstractions) /* not if we're in a reload */ + return; if (!gl->gl_owner) { /* this is a canvas; if we have a window, put on "windows" list */ @@ -606,6 +608,8 @@ void canvas_reflecttitle(t_canvas *x) void canvas_dirty(t_canvas *x, t_int n) { t_canvas *x2 = canvas_getrootfor(x); + if (glist_amreloadingabstractions) + return; if ((unsigned)n != x2->gl_dirty) { x2->gl_dirty = n; diff --git a/pd/src/g_canvas.h b/pd/src/g_canvas.h index c074ad5c..784a590b 100644 --- a/pd/src/g_canvas.h +++ b/pd/src/g_canvas.h @@ -404,7 +404,7 @@ EXTERN void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag); EXTERN void canvas_create_editor(t_glist *x, int createit); void canvas_deletelinesforio(t_canvas *x, t_text *text, t_inlet *inp, t_outlet *outp); - +extern int glist_amreloadingabstractions; /* stop GUI changes while reloading */ /* -------------------- functions on texts ------------------------- */ EXTERN void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize); diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index ee2a76ac..c4bfd456 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -697,6 +697,7 @@ static void glist_doreload(t_glist *gl, t_symbol *name, t_symbol *dir, { t_gobj *g; int i, nobj = glist_getindex(gl, 0); /* number of objects */ + int hadwindow = gl->gl_havewindow; for (g = gl->gl_list, i = 0; g && i < nobj; i++) { if (g != except && pd_class(&g->g_pd) == canvas_class && @@ -709,8 +710,7 @@ static void glist_doreload(t_glist *gl, t_symbol *name, t_symbol *dir, replacement will be at the end of the list, so we don't do g = g->g_next in this case. */ int j = glist_getindex(gl, g); - int hadwindow = gl->gl_havewindow; - if (!hadwindow) + if (!gl->gl_havewindow) canvas_vis(glist_getcanvas(gl), 1); glist_noselect(gl); glist_select(gl, g); @@ -720,8 +720,6 @@ static void glist_doreload(t_glist *gl, t_symbol *name, t_symbol *dir, canvas_undo(gl); glist_noselect(gl); g = glist_nth(gl, j); - if (!hadwindow) - canvas_vis(glist_getcanvas(gl), 0); } else { @@ -730,15 +728,23 @@ static void glist_doreload(t_glist *gl, t_symbol *name, t_symbol *dir, g = g->g_next; } } + if (!hadwindow && gl->gl_havewindow) + canvas_vis(glist_getcanvas(gl), 0); } + /* this flag stops canvases from being marked "dirty" if we have to touch + them to reload an abstraction; also suppress window list update */ +int glist_amreloadingabstractions = 0; + /* call canvas_doreload on everyone */ void canvas_reload(t_symbol *name, t_symbol *dir, t_gobj *except) { t_canvas *x; + glist_amreloadingabstractions = 1; /* find all root canvases */ for (x = canvas_list; x; x = x->gl_next) glist_doreload(x, name, dir, except); + glist_amreloadingabstractions = 0; } /* ------------------------ event handling ------------------------ */ @@ -1896,9 +1902,9 @@ static void canvas_menufont(t_canvas *x) gfxstub_new(&x2->gl_pd, &x2->gl_pd, buf); } -static int canvas_find_index1, canvas_find_index2; +static int canvas_find_index1, canvas_find_index2, canvas_find_wholeword; static t_binbuf *canvas_findbuf; -int binbuf_match(t_binbuf *inbuf, t_binbuf *searchbuf); +int binbuf_match(t_binbuf *inbuf, t_binbuf *searchbuf, int wholeword); /* find an atom or string of atoms */ static int canvas_dofind(t_canvas *x, int *myindex1p) @@ -1913,7 +1919,8 @@ static int canvas_dofind(t_canvas *x, int *myindex1p) t_object *ob = 0; if (ob = pd_checkobject(&y->g_pd)) { - if (binbuf_match(ob->ob_binbuf, canvas_findbuf)) + if (binbuf_match(ob->ob_binbuf, canvas_findbuf, + canvas_find_wholeword)) { if (myindex1 > canvas_find_index1 || myindex1 == canvas_find_index1 && @@ -1943,25 +1950,16 @@ static int canvas_dofind(t_canvas *x, int *myindex1p) return (0); } -static void canvas_find(t_canvas *x, t_symbol *s, int ac, t_atom *av) +static void canvas_find(t_canvas *x, t_symbol *s, t_floatarg wholeword) { - int myindex1 = 0, i; - for (i = 0; i < ac; i++) - { - if (av[i].a_type == A_SYMBOL) - { - if (!strcmp(av[i].a_w.w_symbol->s_name, "_semi_")) - SETSEMI(&av[i]); - else if (!strcmp(av[i].a_w.w_symbol->s_name, "_comma_")) - SETCOMMA(&av[i]); - } - } + int myindex1 = 0; + t_symbol *decodedsym = sys_decodedialog(s); if (!canvas_findbuf) canvas_findbuf = binbuf_new(); - binbuf_clear(canvas_findbuf); - binbuf_add(canvas_findbuf, ac, av); + binbuf_text(canvas_findbuf, decodedsym->s_name, strlen(decodedsym->s_name)); canvas_find_index1 = 0; canvas_find_index2 = -1; + canvas_find_wholeword = wholeword; canvas_whichfind = x; if (!canvas_dofind(x, &myindex1)) { @@ -2635,7 +2633,7 @@ void g_editor_setup(void) class_addmethod(canvas_class, (t_method)canvas_font, gensym("font"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL); class_addmethod(canvas_class, (t_method)canvas_find, - gensym("find"), A_GIMME, A_NULL); + gensym("find"), A_SYMBOL, A_FLOAT, A_NULL); class_addmethod(canvas_class, (t_method)canvas_find_again, gensym("findagain"), A_NULL); class_addmethod(canvas_class, (t_method)canvas_find_parent, diff --git a/pd/src/g_scalar.c b/pd/src/g_scalar.c index 675df500..fe80de44 100644 --- a/pd/src/g_scalar.c +++ b/pd/src/g_scalar.c @@ -325,6 +325,9 @@ void scalar_redraw(t_scalar *x, t_glist *glist) sys_queuegui(x, glist, scalar_doredraw); } +extern void template_notifyforscalar(t_template *template, t_glist *owner, + t_scalar *sc, t_symbol *s, int argc, t_atom *argv); + int scalar_doclick(t_word *data, t_template *template, t_scalar *sc, t_array *ap, struct _glist *owner, t_float xloc, t_float yloc, int xpix, int ypix, @@ -333,8 +336,14 @@ int scalar_doclick(t_word *data, t_template *template, t_scalar *sc, int hit = 0; t_canvas *templatecanvas = template_findcanvas(template); t_gobj *y; + t_atom at[2]; t_float basex = template_getfloat(template, gensym("x"), data, 0); t_float basey = template_getfloat(template, gensym("y"), data, 0); + SETFLOAT(at, basex + xloc); + SETFLOAT(at+1, basey + yloc); + if (doit) + template_notifyforscalar(template, owner, + sc, gensym("click"), 2, at); for (y = templatecanvas->gl_list; y; y = y->g_next) { t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd); diff --git a/pd/src/g_template.c b/pd/src/g_template.c index aff6f7cb..34541c06 100644 --- a/pd/src/g_template.c +++ b/pd/src/g_template.c @@ -484,7 +484,7 @@ void template_notify(t_template *template, t_symbol *s, int argc, t_atom *argv) /* bash the first of (argv) with a pointer to a scalar, and send on to template as a notification message */ -static void template_notifyforscalar(t_template *template, t_glist *owner, +void template_notifyforscalar(t_template *template, t_glist *owner, t_scalar *sc, t_symbol *s, int argc, t_atom *argv) { t_gpointer gp; diff --git a/pd/src/m_binbuf.c b/pd/src/m_binbuf.c index c2ebd2ca..a895bc67 100644 --- a/pd/src/m_binbuf.c +++ b/pd/src/m_binbuf.c @@ -1308,7 +1308,7 @@ static t_binbuf *binbuf_convert(t_binbuf *oldb, int maxtopd) } /* function to support searching */ -int binbuf_match(t_binbuf *inbuf, t_binbuf *searchbuf) +int binbuf_match(t_binbuf *inbuf, t_binbuf *searchbuf, int wholeword) { int indexin, nmatched; for (indexin = 0; indexin <= inbuf->b_n - searchbuf->b_n; indexin++) @@ -1317,15 +1317,25 @@ int binbuf_match(t_binbuf *inbuf, t_binbuf *searchbuf) { t_atom *a1 = &inbuf->b_vec[indexin + nmatched], *a2 = &searchbuf->b_vec[nmatched]; - if (a1->a_type != a2->a_type || - a1->a_type == A_SYMBOL && a1->a_w.w_symbol != a2->a_w.w_symbol - || - a1->a_type == A_FLOAT && a1->a_w.w_float != a2->a_w.w_float - || - a1->a_type == A_DOLLAR && a1->a_w.w_index != a2->a_w.w_index - || - a1->a_type == A_DOLLSYM && a1->a_w.w_symbol != a2->a_w.w_symbol) + if (a1->a_type == A_SEMI || a1->a_type == A_COMMA) + { + if (a2->a_type != a1->a_type) goto nomatch; + } + else if (a1->a_type == A_FLOAT || a1->a_type == A_DOLLAR) + { + if (a2->a_type != a1->a_type || + a1->a_w.w_float != a2->a_w.w_float) + goto nomatch; + } + else if (a1->a_type == A_SYMBOL || a1->a_type == A_DOLLSYM) + { + if ((a2->a_type != A_SYMBOL && a2->a_type == A_DOLLSYM) + || (wholeword && a1->a_w.w_symbol != a2->a_w.w_symbol) + || (!wholeword && !strstr(a1->a_w.w_symbol->s_name, + a2->a_w.w_symbol->s_name))) + goto nomatch; + } } return (1); nomatch: ; diff --git a/pd/src/m_pd.h b/pd/src/m_pd.h index da6a7c66..438b9f61 100644 --- a/pd/src/m_pd.h +++ b/pd/src/m_pd.h @@ -11,7 +11,7 @@ extern "C" { #define PD_MAJOR_VERSION 0 #define PD_MINOR_VERSION 42 #define PD_BUGFIX_VERSION 0 -#define PD_TEST_VERSION "test3" +#define PD_TEST_VERSION "test5" /* old name for "MSW" flag -- we have to take it for the sake of many old "nmakefiles" for externs, which will define NT and not MSW */ diff --git a/pd/src/makefile.nt b/pd/src/makefile.nt index 1f2822ba..cda842f2 100644 --- a/pd/src/makefile.nt +++ b/pd/src/makefile.nt @@ -20,7 +20,8 @@ LIB = /NODEFAULTLIB:libcmt /NODEFAULTLIB:oldnames /NODEFAULTLIB:libc \ GLIB = $(LIB) ..\bin\tcl84.lib ..\bin\tk84.lib CFLAGS = /nologo /W3 /DMSW /DNT /DPD /DPD_INTERNAL /DWIN32 /DWINDOWS /Ox \ - -DPA_LITTLE_ENDIAN -DUSEAPI_MMIO -DUSEAPI_PORTAUDIO -D__i386__ -DPA19 + -DPA_LITTLE_ENDIAN -DUSEAPI_MMIO -DUSEAPI_PORTAUDIO -D__i386__ -DPA19 \ + -D_CRT_SECURE_NO_WARNINGS LFLAGS = /nologo SYSSRC = s_audio_pa.c s_audio_pablio.c s_audio_paring.c \ diff --git a/pd/src/notes.txt b/pd/src/notes.txt index e5c85dca..70209b65 100644 --- a/pd/src/notes.txt +++ b/pd/src/notes.txt @@ -53,27 +53,24 @@ real-time spectrum grapher document ||, |, etc, better features: -pasting should look at current mouse location optionally suppress leading "." directories and files on "open" change config.h to #ifdef _MSC_VER (include MSW fake) else include a real one stick snprintf alias in the MSW fake. +"installation mode" - turn off Pd window, accelerators, menu bars, scrollbars flag to prevent unlocking patches -clickless connection (hit 'c' key? see Bouchard paper) messages to suppress menus&accelerators, and invisibilize Pd window machine-independent fonts -callback scheduling on Mac sigmund~: sort by pitch; one-shot -add -x flag to drawnumbers.... +expr to parse exponential notation +pipe to handle symbols&pointers (just takes floats now???) grab new ALSA midi code from devel -externs able to usurp built-ins (+mem alignment for SSE) +mem alignment for SSE replace gatom_escapit with a quoting mechanism (handle '[', spaces, etc.) unicode in filenames??? How does this work? (bug report about windows) sprout inlet for "route", "sel" if one arg more list functions (see x_list.c) poly inlet to turn stealing on/off, plus mode to handle note-with-duration integrate video into tilde objects -graph "hide name" flag controllable from dialog -"installation mode" - turn off Pd window, accelerators, menu bars, scrollbars fix copyright notices pixel font sizes pd to find running ones (pd -new to defeat) @@ -81,6 +78,7 @@ tables: if there's just one array, don't do stringent hit check. array click protection (Krzysztof's suggestion) make graph labels persistent and add to dialog + graph "hide name" flag controllable from dialog object to get/set table size; random; quantile flag to hide array names think of a way to embed abstractions in a patch @@ -89,10 +87,9 @@ delete-in-rectangle message to Pds put serial object in main dist (see rat@telecoma, Apr. 25; winfried May 22) open/save panel to take messages to init directory, and to set extent list flags to defeat pre-loading specified classes -expr to parse exponential notation -pipe to handle symbols&pointers (just takes floats now???) -fix "system" (google CLOEXEC alsa) editing: + pasting should look at current mouse location + clickless connection (hit 'c' key? see Bouchard paper) "enter" into object box to create new one (also, change border? forking?) tab to jump to a connected object (first one?) (shift-tab to back up?) arrow keys to shift connections left and right @@ -103,6 +100,8 @@ editing: (also, a way to make multiple connections?) data: +add -x [-n?] flag to drawnumbers +flag to disable edits for arrays make a 2-pass proecss for finding hot spot closes to any given click replace list element with binbuf?? hooks for table mousing, other changes (scalars?) @@ -117,7 +116,6 @@ sublists should display on parent if desired? (new drawing instruction) test and debug list elements of templates sublists seem not to handle canvas allocation right (get.pd->pointer.pd bug) append doesn't do symbols yet. --n flag for drawnumbers non-clickable arrays (plus arrays that respond more easily than default) more features: diff --git a/pd/src/s_audio_alsamm.c b/pd/src/s_audio_alsamm.c index 66255932..3bc4b369 100644 --- a/pd/src/s_audio_alsamm.c +++ b/pd/src/s_audio_alsamm.c @@ -748,21 +748,6 @@ static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams, int pl if(sys_verbose) post("sw_params: set avail_min= %d (was %d)", (int) ps, (int) ops); #endif - - /* ALIGN: align all transfers to 1 sample */ - - snd_pcm_sw_params_get_xfer_align(swparams, &ops); - err = snd_pcm_sw_params_set_xfer_align(handle, swparams, 1); - if (err < 0) { - check_error(err,"Unable to set transfer align for playback"); - return err; - } - snd_pcm_sw_params_get_xfer_align(swparams, &ps); - -#ifdef ALSAMM_DEBUG - if(sys_verbose) - post("sw_params: set xfer_align = %d (was %d)", (int) ps, (int) ops); -#endif /* write the parameters to the playback device */ diff --git a/pd/src/s_audio_pa.c b/pd/src/s_audio_pa.c index 85816ee7..e02cbc9e 100644 --- a/pd/src/s_audio_pa.c +++ b/pd/src/s_audio_pa.c @@ -14,6 +14,8 @@ #include <portaudio.h> #include "s_audio_pablio.h" +#define MAX_PA_CHANS 32 +#define MAX_SAMPLES_PER_FRAME (MAX_PA_CHANS * DEFDACBLKSIZE) /* LATER try to figure out how to handle default devices in portaudio; the way s_audio.c handles them isn't going to work here. */ @@ -25,9 +27,6 @@ static int pa_inchans, pa_outchans; static float *pa_soundin, *pa_soundout; static t_audiocallback pa_callback; -#define MAX_PA_CHANS 32 -#define MAX_SAMPLES_PER_FRAME MAX_PA_CHANS * DEFDACBLKSIZE - int pa_foo; static int pa_lowlevel_callback(const void *inputBuffer, diff --git a/pd/src/s_path.c b/pd/src/s_path.c index ef441184..d74aa0f6 100644 --- a/pd/src/s_path.c +++ b/pd/src/s_path.c @@ -270,8 +270,11 @@ int sys_open_absolute(const char *name, const char* ext, { if (sys_isabsolutepath(name)) { - char dirbuf[MAXPDSTRING]; - int dirlen = (strrchr(name, '/') - name); + char dirbuf[MAXPDSTRING], *z = strrchr(name, '/'); + int dirlen; + if (!z) + return (0); + dirlen = z - name; if (dirlen > MAXPDSTRING-1) dirlen = MAXPDSTRING-1; strncpy(dirbuf, name, dirlen); @@ -419,9 +422,9 @@ int sys_rcfile(void) for (i = 1; i < NUMARGS-1; i++) { - if (fscanf(file, "%999s", buf) < 0) + if (fscanf(file, "%998s", buf) < 0) break; - buf[1000] = 0; + buf[999] = 0; if (!(rcargv[i] = malloc(strlen(buf) + 1))) goto cleanup; strcpy(rcargv[i], buf); @@ -437,7 +440,7 @@ int sys_rcfile(void) fclose(file); if (sys_verbose) { - if (rcargv) + if (rcargc) { post("startup args from RC file:"); for (i = 1; i < rcargc; i++) diff --git a/pd/src/s_stuff.h b/pd/src/s_stuff.h index 3276b00b..4af5c754 100644 --- a/pd/src/s_stuff.h +++ b/pd/src/s_stuff.h @@ -28,7 +28,7 @@ int sys_open_absolute(const char *name, const char* ext, char *dirresult, char **nameresult, unsigned int size, int bin, int *fdp); int sys_trytoopenone(const char *dir, const char *name, const char* ext, char *dirresult, char **nameresult, unsigned int size, int bin); - +t_symbol *sys_decodedialog(t_symbol *s); /* s_file.c */ diff --git a/pd/src/t_tkcmd.c b/pd/src/t_tkcmd.c index bd6ff5a5..6d863c15 100644 --- a/pd/src/t_tkcmd.c +++ b/pd/src/t_tkcmd.c @@ -333,7 +333,7 @@ gotit: ; #ifdef STARTGUI -/* #define DEBUGCONNECT */ +#define DEBUGCONNECT #ifdef DEBUGCONNECT static FILE *debugfd; @@ -618,11 +618,19 @@ void pdgui_setname(char *s) int Pdtcl_Init(Tcl_Interp *interp) { const char *argv = Tcl_GetVar(interp, "argv", 0); - int portno, argno = 0; - if (argv && (portno = atoi(argv)) > 1) + int portno = 0, i; + if (argv) + { + for (i = 0; i < (int)strlen(argv) - 1; i++) + if (argv[i] >= '0' && argv[i] <= '9') + { + portno = atoi(argv+i); + break; + } + } + if (portno) pdgui_setsock(portno); #ifdef DEBUGCONNECT - pd_portno = portno; debugfd = fopen("/tmp/bratwurst", "w"); fprintf(debugfd, "turning stderr back on\n"); fflush(debugfd); diff --git a/pd/src/u_main.tk b/pd/src/u_main.tk index 1ad84f08..9d68b58e 100644 --- a/pd/src/u_main.tk +++ b/pd/src/u_main.tk @@ -194,12 +194,14 @@ pack .controls.inout.out.label .controls.inout.out.level \ button .controls.dio -text "DIO\nerrors" \ -command {pd [concat pd audiostatus \;]} +button .controls.clear -text "clear\nprinout" \ + -command {.printout.text delete 0.0 end} pack .controls.inout.in .controls.inout.out -side left -padx 6 pack .controls.inout -side left -padx 14 -pack .controls.switches -side right -pack .controls.dio -side right -padx 20 - +pack .controls.switches -side left +pack .controls.dio -side left -padx 20 +pack .controls.clear -side right -padx 6 frame .printout text .printout.text -relief raised -bd 2 -font console_font \ @@ -835,16 +837,12 @@ proc menu_fixwindowmenu {name} { set find_canvas nobody set find_string "" set find_count 1 +set find_wholeword 1 proc find_apply {name} { - global find_string - global find_canvas - regsub -all \; $find_string " _semi_ " find_string2 - regsub -all \, $find_string2 " _comma_ " find_string3 -# puts stderr [concat $find_canvas find $find_string3 \ -# \;] - pd [concat $find_canvas find $find_string3 \ - \;] + global find_string find_canvas find_wholeword + pd [concat $find_canvas find [pdtk_encodedialog $find_string] \ + $find_wholeword \;] after 50 destroy $name } @@ -853,9 +851,7 @@ proc find_cancel {name} { } proc menu_findobject {canvas} { - global find_string - global find_canvas - global find_count + global find_string find_canvas find_count find_wholeword set name [format ".find%d" $find_count] set find_count [expr $find_count + 1] @@ -869,6 +865,9 @@ proc menu_findobject {canvas} { entry $name.entry -textvariable find_string pack $name.entry -side top + checkbutton $name.wholeword -variable find_wholeword \ + -text {whole word} -anchor e + pack $name.wholeword -side bottom frame $name.buttonframe pack $name.buttonframe -side bottom -fill x -pady 2m @@ -4233,7 +4232,9 @@ proc path_apply {id} { for {set x 0} {$x < $pd_path_count} {incr x} { global pd_path$x set this_path [set pd_path$x] - if {0==[string match "" $this_path]} {lappend pd_path [pdtk_encodedialog $this_path]} + if {0==[string match "" $this_path]} { + lappend pd_path [pdtk_encodedialog $this_path] + } } pd [concat pd path-dialog $pd_extrapath $pd_verbose $pd_path \;] @@ -4395,3 +4396,81 @@ proc pdtk_startup_dialog {id nort flags} { focus $id.f0 } +########## data-driven dialog -- convert others to this someday? ########## + +proc ddd_apply {id} { + set vid [string trimleft $id .] + set var_count [concat ddd_count_$vid] + global $var_count + set count [eval concat $$var_count] + set values {} + + for {set x 0} {$x < $count} {incr x} { + set varname [concat ddd_var_$vid$x] + global $varname + lappend values [eval concat $$varname] + } + set cmd [concat $id done $values \;] + +# puts stderr $cmd + pd $cmd +} + +proc ddd_cancel {id} { + set cmd [concat $id cancel \;] +# puts stderr $cmd + pd $cmd +} + +proc ddd_ok {id} { + ddd_apply $id + ddd_cancel $id +} + +proc ddd_dialog {id dialogname} { + global ddd_fields + set vid [string trimleft $id .] + set count [llength $ddd_fields] + + set var_count [concat ddd_count_$vid] + global $var_count + set $var_count $count + + toplevel $id + label $id.label -text $dialogname + pack $id.label -side top + wm title $id "Pd dialog" + wm resizable $id 0 0 + wm protocol $id WM_DELETE_WINDOW [concat ddd_cancel $id] + + for {set x 0} {$x < $count} {incr x} { + set varname [concat ddd_var_$vid$x] + global $varname + set fieldname [lindex $ddd_fields $x 0] + set $varname [lindex $ddd_fields $x 1] + frame $id.frame$x + pack $id.frame$x -side top + label $id.frame$x.label -text $fieldname + entry $id.frame$x.entry -textvariable $varname -width 20 + bind $id.frame$x.entry <KeyPress-Return> [concat ddd_ok $id] + pdtk_standardkeybindings $id.frame$x.entry + pack $id.frame$x.entry $id.frame$x.label -side right + } + + frame $id.buttonframe -pady 5 + pack $id.buttonframe -side top -fill x -pady 2 + button $id.buttonframe.cancel -text {Cancel}\ + -command "ddd_cancel $id" + button $id.buttonframe.apply -text {Apply}\ + -command "ddd_apply $id" + button $id.buttonframe.ok -text {OK}\ + -command "ddd_ok $id" + pack $id.buttonframe.cancel $id.buttonframe.apply \ + $id.buttonframe.ok -side left -expand 1 + +# $id.params.entry select from 0 +# $id.params.entry select adjust end +# focus $id.params.entry +} + + diff --git a/pd/src/x_interface.c b/pd/src/x_interface.c index 4effa0d9..044961b1 100644 --- a/pd/src/x_interface.c +++ b/pd/src/x_interface.c @@ -5,6 +5,7 @@ /* interface objects */ #include "m_pd.h" +#include <string.h> /* -------------------------- print ------------------------------ */ static t_class *print_class; @@ -15,34 +16,39 @@ typedef struct _print t_symbol *x_sym; } t_print; -static void *print_new(t_symbol *s) +static void *print_new(t_symbol *sel, int argc, t_atom *argv) { t_print *x = (t_print *)pd_new(print_class); - if (*s->s_name) x->x_sym = s; - else x->x_sym = gensym("print"); + t_symbol *s = atom_getsymbolarg(0, argc, argv); + if (!*s->s_name) + x->x_sym = gensym("print"); + else if (!strcmp(s->s_name, "-n")) + x->x_sym = &s_; + else x->x_sym = s; return (x); } static void print_bang(t_print *x) { - post("%s: bang", x->x_sym->s_name); + post("%s%sbang", x->x_sym->s_name, (*x->x_sym->s_name ? ": " : "")); } static void print_pointer(t_print *x, t_gpointer *gp) { - post("%s: (gpointer)", x->x_sym->s_name); + post("%s%s(gpointer)", x->x_sym->s_name, (*x->x_sym->s_name ? ": " : "")); } static void print_float(t_print *x, t_float f) { - post("%s: %g", x->x_sym->s_name, f); + post("%s%s%g", x->x_sym->s_name, (*x->x_sym->s_name ? ": " : ""), f); } static void print_list(t_print *x, t_symbol *s, int argc, t_atom *argv) { int i; if (argc && argv->a_type != A_SYMBOL) startpost("%s:", x->x_sym->s_name); - else startpost("%s: %s", x->x_sym->s_name, + else startpost("%s%s%s", x->x_sym->s_name, + (*x->x_sym->s_name ? ": " : ""), (argc > 1 ? s_list.s_name : (argc == 1 ? s_symbol.s_name : s_bang.s_name))); postatom(argc, argv); @@ -52,7 +58,8 @@ static void print_list(t_print *x, t_symbol *s, int argc, t_atom *argv) static void print_anything(t_print *x, t_symbol *s, int argc, t_atom *argv) { int i; - startpost("%s: %s", x->x_sym->s_name, s->s_name); + startpost("%s%s%s", x->x_sym->s_name, (*x->x_sym->s_name ? ": " : ""), + s->s_name); postatom(argc, argv); endpost(); } @@ -60,7 +67,7 @@ static void print_anything(t_print *x, t_symbol *s, int argc, t_atom *argv) static void print_setup(void) { print_class = class_new(gensym("print"), (t_newmethod)print_new, 0, - sizeof(t_print), 0, A_DEFSYM, 0); + sizeof(t_print), 0, A_GIMME, 0); class_addbang(print_class, print_bang); class_addfloat(print_class, print_float); class_addpointer(print_class, print_pointer); @@ -68,8 +75,6 @@ static void print_setup(void) class_addanything(print_class, print_anything); } - - void x_interface_setup(void) { print_setup(); |