aboutsummaryrefslogtreecommitdiff
path: root/pd/src
diff options
context:
space:
mode:
authorMiller Puckette <millerpuckette@users.sourceforge.net>2008-12-30 01:51:31 +0000
committerMiller Puckette <millerpuckette@users.sourceforge.net>2008-12-30 01:51:31 +0000
commit0648504ff46cde69a7392a647d718f621c402b08 (patch)
tree142fa7cc238f6c22922ab8f91230ecdc344a34b3 /pd/src
parentb56403eec4b767e04880c418a467b88f7cfeb2ca (diff)
0.42-0test08
svn path=/trunk/; revision=10469
Diffstat (limited to 'pd/src')
-rw-r--r--pd/src/CHANGELOG.txt2
-rw-r--r--pd/src/g_canvas.c27
-rw-r--r--pd/src/g_canvas.h5
-rw-r--r--pd/src/g_editor.c171
-rw-r--r--pd/src/g_rtext.c7
-rw-r--r--pd/src/g_text.c89
-rw-r--r--pd/src/m_glob.c22
-rw-r--r--pd/src/m_pd.h5
-rw-r--r--pd/src/makefile.in25
-rw-r--r--pd/src/notes.txt4
-rw-r--r--pd/src/s_audio.c2
-rw-r--r--pd/src/s_audio_oss.c58
-rw-r--r--pd/src/s_audio_pa.c8
-rw-r--r--pd/src/s_loader.c2
-rw-r--r--pd/src/s_main.c7
-rw-r--r--pd/src/s_stuff.h7
16 files changed, 252 insertions, 189 deletions
diff --git a/pd/src/CHANGELOG.txt b/pd/src/CHANGELOG.txt
index 6d789171..c376ff43 100644
--- a/pd/src/CHANGELOG.txt
+++ b/pd/src/CHANGELOG.txt
@@ -1,6 +1,6 @@
This file describes implementation and API changes; stuff more visible to the
user appears in the "release notes" instead. See the bottom of this file
-for original notes on source stype and organization.
+for original notes on source style and organization.
0.42.0
diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c
index 6838832e..fd2df161 100644
--- a/pd/src/g_canvas.c
+++ b/pd/src/g_canvas.c
@@ -51,7 +51,6 @@ void canvas_reflecttitle(t_canvas *x);
static void canvas_addtolist(t_canvas *x);
static void canvas_takeofflist(t_canvas *x);
static void canvas_pop(t_canvas *x, t_floatarg fvis);
-void canvas_create_editor(t_glist *x, int createit);
/* --------- functions to handle the canvas environment ----------- */
@@ -513,8 +512,6 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym,
if (!menu)
pd_pushsym(&x->gl_pd);
glist_add(g, &x->gl_gobj);
- if (glist_isvisible(g))
- canvas_create_editor(x, 1);
return (x);
}
@@ -605,7 +602,8 @@ void canvas_reflecttitle(t_canvas *x)
canvas_getdir(x)->s_name);
}
-void canvas_dirty(t_canvas *x, t_int n)
+ /* mark a glist dirty or clean */
+void canvas_dirty(t_canvas *x, t_floatarg n)
{
t_canvas *x2 = canvas_getrootfor(x);
if (glist_amreloadingabstractions)
@@ -613,7 +611,8 @@ void canvas_dirty(t_canvas *x, t_int n)
if ((unsigned)n != x2->gl_dirty)
{
x2->gl_dirty = n;
- canvas_reflecttitle(x2);
+ if (glist_isvisible(x2))
+ canvas_reflecttitle(x2);
}
}
@@ -663,15 +662,8 @@ void canvas_map(t_canvas *x, t_floatarg f)
{
if (glist_isvisible(x))
{
- /* just clear out the whole canvas... */
+ /* just clear out the whole canvas */
sys_vgui(".x%lx.c delete all\n", x);
-#if 0
- /* alternatively, we could have erased them one by one...
- for (y = x->gl_list; y; y = y->g_next)
- gobj_vis(y, x, 0);
- ... but we should go through and erase the lines as well
- if we do it that way. */
-#endif
x->gl_mapped = 0;
}
}
@@ -695,14 +687,14 @@ void glist_menu_open(t_glist *x)
{
t_glist *gl2 = x->gl_owner;
if (!gl2)
- bug("canvas_vis"); /* shouldn't happen but don't get too upset. */
+ bug("glist_menu_open"); /* shouldn't happen but not dangerous */
else
{
/* erase ourself in parent window */
gobj_vis(&x->gl_gobj, gl2, 0);
/* get rid of our editor (and subeditors) */
if (x->gl_editor)
- canvas_create_editor(x, 0);
+ canvas_destroy_editor(x);
x->gl_havewindow = 1;
/* redraw ourself in parent window (blanked out this time) */
gobj_vis(&x->gl_gobj, gl2, 1);
@@ -744,7 +736,8 @@ void canvas_free(t_canvas *x)
glist_noselect(x);
while (y = x->gl_list)
glist_delete(x, y);
- canvas_vis(x, 0);
+ if (x == glist_getcanvas(x))
+ canvas_vis(x, 0);
if (strcmp(x->gl_name->s_name, "Pd"))
pd_unbind(&x->gl_pd, canvas_makebindsym(x->gl_name));
@@ -1558,6 +1551,8 @@ void g_canvas_setup(void)
gensym("menu-open"), A_NULL);
class_addmethod(canvas_class, (t_method)canvas_map,
gensym("map"), A_FLOAT, A_NULL);
+ class_addmethod(canvas_class, (t_method)canvas_dirty,
+ gensym("dirty"), A_FLOAT, A_NULL);
class_setpropertiesfn(canvas_class, (t_propertiesfn)canvas_properties);
/* ---------------------- list handling ------------------------ */
diff --git a/pd/src/g_canvas.h b/pd/src/g_canvas.h
index 784a590b..e36fb48b 100644
--- a/pd/src/g_canvas.h
+++ b/pd/src/g_canvas.h
@@ -401,7 +401,8 @@ EXTERN void glist_redraw(t_glist *x);
EXTERN void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
char *tag, int x1, int y1, int x2, int y2);
EXTERN void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag);
-EXTERN void canvas_create_editor(t_glist *x, int createit);
+EXTERN void canvas_create_editor(t_glist *x);
+EXTERN void canvas_destroy_editor(t_glist *x);
void canvas_deletelinesforio(t_canvas *x, t_text *text,
t_inlet *inp, t_outlet *outp);
extern int glist_amreloadingabstractions; /* stop GUI changes while reloading */
@@ -466,7 +467,7 @@ EXTERN void canvas_setcurrent(t_canvas *x);
EXTERN void canvas_unsetcurrent(t_canvas *x);
EXTERN t_symbol *canvas_realizedollar(t_canvas *x, t_symbol *s);
EXTERN t_canvas *canvas_getrootfor(t_canvas *x);
-EXTERN void canvas_dirty(t_canvas *x, t_int n);
+EXTERN void canvas_dirty(t_canvas *x, t_floatarg n);
EXTERN int canvas_getfont(t_canvas *x);
typedef int (*t_canvasapply)(t_canvas *x, t_int x1, t_int x2, t_int x3);
diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index c4bfd456..ef096a4c 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -27,6 +27,7 @@ static void canvas_clearline(t_canvas *x);
static t_binbuf *copy_binbuf;
static char *canvas_textcopybuf;
static int canvas_textcopybufsize;
+static t_glist *glist_finddirty(t_glist *x);
/* ---------------- generic widget behavior ------------------------- */
@@ -166,12 +167,26 @@ void glist_select(t_glist *x, t_gobj *y)
}
}
+ /* recursively deselect everything in a gobj "g", if it happens to be
+ a glist, in preparation for deselecting g itself in glist_dselect() */
+static void glist_checkanddeselectall(t_glist *gl, t_gobj *g)
+{
+ t_glist *gl2;
+ t_gobj *g2;
+ if (pd_class(&g->g_pd) != canvas_class)
+ return;
+ gl2 = (t_glist *)g;
+ for (g2 = gl2->gl_list; g2; g2 = g2->g_next)
+ glist_checkanddeselectall(gl2, g2);
+ glist_noselect(gl2);
+}
+
/* call this for selected objects only */
void glist_deselect(t_glist *x, t_gobj *y)
{
int fixdsp = 0;
static int reenter = 0;
- if (reenter) return;
+ /* if (reenter) return; */
reenter = 1;
if (x->gl_editor)
{
@@ -187,6 +202,7 @@ void glist_deselect(t_glist *x, t_gobj *y)
{
z = fuddy;
canvas_stowconnections(glist_getcanvas(x));
+ glist_checkanddeselectall(x, y);
}
gobj_activate(y, x, 0);
}
@@ -862,39 +878,31 @@ static void editor_free(t_editor *x, t_glist *y)
/* recursively create or destroy all editors of a glist and its
sub-glists, as long as they aren't toplevels. */
-void canvas_create_editor(t_glist *x, int createit)
+void canvas_create_editor(t_glist *x)
{
t_gobj *y;
t_object *ob;
- if (createit)
+ if (!x->gl_editor)
{
- if (x->gl_editor)
- bug("canvas_create_editor");
- else
- {
- x->gl_editor = editor_new(x);
- for (y = x->gl_list; y; y = y->g_next)
- if (ob = pd_checkobject(&y->g_pd))
- rtext_new(x, ob);
- }
+ x->gl_editor = editor_new(x);
+ for (y = x->gl_list; y; y = y->g_next)
+ if (ob = pd_checkobject(&y->g_pd))
+ rtext_new(x, ob);
}
- else
+}
+
+void canvas_destroy_editor(t_glist *x)
+{
+ t_gobj *y;
+ t_object *ob;
+ if (x->gl_editor)
{
- if (!x->gl_editor)
- bug("canvas_create_editor");
- else
- {
- for (y = x->gl_list; y; y = y->g_next)
- if (ob = pd_checkobject(&y->g_pd))
- rtext_free(glist_findrtext(x, ob));
- editor_free(x->gl_editor, x);
- x->gl_editor = 0;
- }
+ for (y = x->gl_list; y; y = y->g_next)
+ if (ob = pd_checkobject(&y->g_pd))
+ rtext_free(glist_findrtext(x, ob));
+ editor_free(x->gl_editor, x);
+ x->gl_editor = 0;
}
- for (y = x->gl_list; y; y = y->g_next)
- if (pd_class(&y->g_pd) == canvas_class &&
- ((t_canvas *)y)->gl_isgraph && !((t_canvas *)y)->gl_havewindow)
- canvas_create_editor((t_canvas *)y, createit);
}
void canvas_reflecttitle(t_canvas *x);
@@ -907,6 +915,8 @@ void canvas_vis(t_canvas *x, t_floatarg f)
{
char buf[30];
int flag = (f != 0);
+ if (x != glist_getcanvas(x))
+ bug("canvas_vis");
if (flag)
{
/* post("havewindow %d, isgraph %d, isvisible %d editor %d",
@@ -926,7 +936,7 @@ void canvas_vis(t_canvas *x, t_floatarg f)
}
else
{
- canvas_create_editor(x, 1);
+ canvas_create_editor(x);
sys_vgui("pdtk_canvas_new .x%lx %d %d +%d+%d %d\n", x,
(int)(x->gl_screenx2 - x->gl_screenx1),
(int)(x->gl_screeny2 - x->gl_screeny1),
@@ -949,14 +959,14 @@ void canvas_vis(t_canvas *x, t_floatarg f)
subpatches fall here too but don'd need the editor freed, so
we check if it exists. */
if (x->gl_editor)
- canvas_create_editor(x, 0);
+ canvas_destroy_editor(x);
return;
}
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x);
glist_noselect(x);
if (glist_isvisible(x))
canvas_map(x, 0);
- canvas_create_editor(x, 0);
+ canvas_destroy_editor(x);
sys_vgui("destroy .x%lx\n", x);
for (i = 1, x2 = x; x2; x2 = x2->gl_next, i++)
;
@@ -966,8 +976,6 @@ void canvas_vis(t_canvas *x, t_floatarg f)
if (glist_isgraph(x) && x->gl_owner)
{
t_glist *gl2 = x->gl_owner;
- if (!x->gl_owner->gl_isdeleting)
- canvas_create_editor(x, 1);
if (glist_isvisible(gl2))
gobj_vis(&x->gl_gobj, gl2, 0);
x->gl_havewindow = 0;
@@ -987,7 +995,7 @@ void canvas_setgraph(t_glist *x, int flag, int nogoprect)
{
int hadeditor = (x->gl_editor != 0);
if (hadeditor)
- canvas_create_editor(x, 0);
+ canvas_destroy_editor(x);
if (x->gl_owner && !x->gl_loading && glist_isvisible(x->gl_owner))
gobj_vis(&x->gl_gobj, x->gl_owner, 0);
x->gl_isgraph = 0;
@@ -996,8 +1004,6 @@ void canvas_setgraph(t_glist *x, int flag, int nogoprect)
gobj_vis(&x->gl_gobj, x->gl_owner, 1);
canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
}
- if (hadeditor)
- canvas_create_editor(x, 1);
}
else if (flag)
{
@@ -1023,8 +1029,6 @@ void canvas_setgraph(t_glist *x, int flag, int nogoprect)
}
if (glist_isvisible(x) && x->gl_goprect)
glist_redraw(x);
- if (x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner))
- canvas_create_editor(x, 1);
if (x->gl_owner && !x->gl_loading && glist_isvisible(x->gl_owner))
{
gobj_vis(&x->gl_gobj, x->gl_owner, 1);
@@ -1549,7 +1553,7 @@ static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
else hiy = x->gl_editor->e_ywas, loy = ypos;
canvas_selectinrect(x, lox, loy, hix, hiy);
sys_vgui(".x%lx.c delete x\n", x);
- x->gl_editor->e_onmotion = 0;
+ x->gl_editor->e_onmotion = MA_NONE;
}
else sys_vgui(".x%lx.c coords x %d %d %d %d\n",
x, x->gl_editor->e_xwas,
@@ -1580,8 +1584,25 @@ void canvas_mouseup(t_canvas *x,
/* after motion, if there's only one item selected, activate it */
if (x->gl_editor->e_selection &&
!(x->gl_editor->e_selection->sel_next))
- gobj_activate(x->gl_editor->e_selection->sel_what,
- x, 1);
+ {
+ t_gobj *g = x->gl_editor->e_selection->sel_what;
+ t_glist *gl2;
+ /* first though, check we aren't an abstraction with a
+ dirty sub-patch that would be discarded if we edit this. */
+ if (pd_class(&g->g_pd) == canvas_class &&
+ canvas_isabstraction((t_glist *)g) &&
+ (gl2 = glist_finddirty((t_glist *)g)))
+ {
+ vmess(&gl2->gl_pd, gensym("menu-open"), "");
+ x->gl_editor->e_onmotion = MA_NONE;
+ sys_vgui(
+"pdtk_check {Discard changes to '%s'?} {.x%lx dirty 0;\n} no\n",
+ canvas_getrootfor(gl2)->gl_name->s_name, gl2);
+ return;
+ }
+ /* OK, activate it */
+ gobj_activate(x->gl_editor->e_selection->sel_what, x, 1);
+ }
}
if (x->gl_editor->e_onmotion != MA_NONE)
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x);
@@ -1609,7 +1630,8 @@ static void canvas_displaceselection(t_canvas *x, int dx, int dy)
}
if (resortin) canvas_resortinlets(x);
if (resortout) canvas_resortoutlets(x);
- canvas_dirty(x, 1);
+ if (x->gl_editor->e_selection)
+ canvas_dirty(x, 1);
}
/* this routine is called whenever a key is pressed or released. "x"
@@ -1686,6 +1708,10 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
return;
if (x && down)
{
+ t_object *ob;
+ /* cancel any dragging action */
+ if (x->gl_editor->e_onmotion == MA_MOVE)
+ x->gl_editor->e_onmotion = MA_NONE;
/* if an object has "grabbed" keys just send them on */
if (x->gl_editor->e_grab
&& x->gl_editor->e_keyfn && keynum)
@@ -1699,15 +1725,34 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
|| !strcmp(gotkeysym->s_name, "Left")
|| !strcmp(gotkeysym->s_name, "Right")))
{
- if (!x->gl_editor->e_textdirty)
+ /* special case - carriage return to object "makes" it */
+ if (keynum == '\n' && (ob =
+ pd_checkobject(&x->gl_editor->e_selection->sel_what->g_pd)) &&
+ ob->te_type == T_OBJECT)
{
- canvas_setundo(x, canvas_undo_cut,
- canvas_undo_set_cut(x, UCUT_TEXT), "typing");
+ t_gobj *g;
+ int nobj, indx =
+ canvas_getindex(x, x->gl_editor->e_selection->sel_what);
+ glist_noselect(x);
+ /* "ob" may have disappeared; just search to the last
+ object and select it */
+ for (g = x->gl_list, nobj = 0; g; g = g->g_next, nobj++)
+ if (nobj == indx)
+ glist_select(x, g);
+ }
+ else
+ {
+ /* otherwise send the key to the box's editor */
+ if (!x->gl_editor->e_textdirty)
+ {
+ canvas_setundo(x, canvas_undo_cut,
+ canvas_undo_set_cut(x, UCUT_TEXT), "typing");
+ }
+ rtext_key(x->gl_editor->e_textedfor,
+ (int)keynum, gotkeysym);
+ if (x->gl_editor->e_textdirty)
+ canvas_dirty(x, 1);
}
- rtext_key(x->gl_editor->e_textedfor,
- (int)keynum, gotkeysym);
- if (x->gl_editor->e_textdirty)
- canvas_dirty(x, 1);
}
/* check for backspace or clear */
else if (keynum == 8 || keynum == 127)
@@ -1795,6 +1840,7 @@ void canvas_startmotion(t_canvas *x)
}
/* ----------------------------- window stuff ----------------------- */
+extern int sys_perf;
void canvas_print(t_canvas *x, t_symbol *s)
{
@@ -1827,11 +1873,11 @@ void glob_verifyquit(void *dummy, t_floatarg f)
{
canvas_vis(g2, 1);
sys_vgui(
-"pdtk_check {Discard changes to this window??} {.x%lx menuclose 3;\n} no\n",
- g2);
+"pdtk_check {Discard changes to '%s'?} {.x%lx menuclose 3;\n} no\n",
+ canvas_getrootfor(g2)->gl_name->s_name, g2);
return;
}
- if (f == 0)
+ if (f == 0 && sys_perf)
sys_vgui("pdtk_check {really quit?} {pd quit;\n} yes\n");
else glob_quit(0);
}
@@ -1854,18 +1900,19 @@ void canvas_menuclose(t_canvas *x, t_floatarg fforce)
g = glist_finddirty(x);
if (g)
{
- canvas_vis(g, 1);
+ vmess(&g->gl_pd, gensym("menu-open"), "");
sys_vgui(
-"pdtk_check {Discard changes to this window??} {.x%lx menuclose 2;\n} no\n",
- g);
+"pdtk_check {Discard changes to '%s'?} {.x%lx menuclose 2;\n} no\n",
+ canvas_getrootfor(g)->gl_name->s_name, g);
return;
}
- else
+ else if (sys_perf)
{
sys_vgui(
-"pdtk_check {Close this window??} {.x%lx menuclose 1;\n} yes\n",
- x);
+"pdtk_check {Close '%s'?} {.x%lx menuclose 1;\n} yes\n",
+ canvas_getrootfor(x)->gl_name->s_name, x);
}
+ else pd_free(&x->gl_pd);
}
else if (force == 1)
pd_free(&x->gl_pd);
@@ -1877,10 +1924,10 @@ void canvas_menuclose(t_canvas *x, t_floatarg fforce)
g = glist_finddirty(x);
if (g)
{
- canvas_vis(g, 1);
+ vmess(&g->gl_pd, gensym("menu-open"), "");
sys_vgui(
-"pdtk_check {Discard changes to this window??} {.x%lx menuclose 2;\n} no\n",
- g);
+"pdtk_check {Discard changes to '%s'?} {.x%lx menuclose 2;\n} no\n",
+ canvas_getrootfor(x)->gl_name->s_name, g);
return;
}
else pd_free(&x->gl_pd);
@@ -2361,10 +2408,10 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
as needed */
if (pd_class(&src->g_pd) == text_class && objsrc->te_type == T_OBJECT)
while (outno >= obj_noutlets(objsrc))
- outlet_new(objsrc, &s_);
+ outlet_new(objsrc, 0);
if (pd_class(&sink->g_pd) == text_class && objsink->te_type == T_OBJECT)
while (inno >= obj_ninlets(objsink))
- inlet_new(objsink, &objsink->ob_pd, &s_, &s_);
+ inlet_new(objsink, &objsink->ob_pd, 0, 0);
if (!(oc = obj_connect(objsrc, outno, objsink, inno))) goto bad;
if (glist_isvisible(x))
diff --git a/pd/src/g_rtext.c b/pd/src/g_rtext.c
index 948ebcb4..63a7485b 100644
--- a/pd/src/g_rtext.c
+++ b/pd/src/g_rtext.c
@@ -342,8 +342,11 @@ void rtext_retext(t_rtext *x)
/* find the rtext that goes with a text item */
t_rtext *glist_findrtext(t_glist *gl, t_text *who)
{
- t_rtext *x = gl->gl_editor->e_rtext;
- while (x && x->x_text != who) x = x->x_next;
+ t_rtext *x;
+ if (!gl->gl_editor)
+ canvas_create_editor(gl);
+ for (x = gl->gl_editor->e_rtext; x && x->x_text != who; x = x->x_next)
+ ;
if (!x) bug("glist_findrtext");
return (x);
}
diff --git a/pd/src/g_text.c b/pd/src/g_text.c
index 1d4559ec..30184fcf 100644
--- a/pd/src/g_text.c
+++ b/pd/src/g_text.c
@@ -131,9 +131,36 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix, int selected,
canvas_unsetcurrent((t_canvas *)gl);
}
+ /* utility routine to figure out where to put a new text box from menu
+ and whether to connect to it automatically */
+static void canvas_howputnew(t_canvas *x, int *connectp, int *xpixp, int *ypixp,
+ int *indexp, int *totalp)
+{
+ int xpix, ypix, indx = 0, nobj = 0, x1, x2, y1, y2;
+ int connectme = (x->gl_editor->e_selection &&
+ !x->gl_editor->e_selection->sel_next);
+ if (connectme)
+ {
+ t_gobj *g;
+ for (g = x->gl_list, nobj = 0; g; g = g->g_next, nobj++)
+ if (g == x->gl_editor->e_selection->sel_what)
+ {
+ gobj_getrect(g, x, &x1, &y1, &x2, &y2);
+ indx = nobj;
+ *xpixp = x1;
+ *ypixp = y2 + 5;
+ }
+ }
+ else glist_getnextxy(x, xpixp, ypixp);
+ glist_noselect(x);
+ *connectp = connectme;
+ *indexp = indx;
+ *totalp = nobj;
+}
+
/* object creation routine. These are called without any arguments if
- they're invoked from the
- gui; when pasting or restoring from a file, we get at least x and y. */
+ they're invoked from the gui; when pasting or restoring from a file, we
+ get at least x and y. */
void canvas_obj(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
{
@@ -145,18 +172,20 @@ void canvas_obj(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
canvas_objtext(gl, atom_getintarg(0, argc, argv),
atom_getintarg(1, argc, argv), 0, b);
}
- else if(!glist_isvisible(gl)){
- /* JMZ: not a good idea to go into interactive mode in a closed canvas... */
- post("unable to create stub object in closed canvas!");
- return;
- } else {
+ /* JMZ: don't go into interactive mode in a closed canvas */
+ else if (!glist_isvisible(gl))
+ post("unable to create stub object in closed canvas!");
+ else
+ {
+ /* interactively create new obect */
t_binbuf *b = binbuf_new();
- int xpix, ypix;
+ int connectme, xpix, ypix, indx, nobj;
+ canvas_howputnew(gl, &connectme, &xpix, &ypix, &indx, &nobj);
pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
- glist_noselect(gl);
- glist_getnextxy(gl, &xpix, &ypix);
canvas_objtext(gl, xpix, ypix, 1, b);
- canvas_startmotion(glist_getcanvas(gl));
+ if (connectme)
+ canvas_connect(gl, indx, 0, nobj, 0);
+ else canvas_startmotion(glist_getcanvas(gl));
}
}
@@ -417,24 +446,23 @@ void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
if (argc > 2) binbuf_restore(x->m_text.te_binbuf, argc-2, argv+2);
glist_add(gl, &x->m_text.te_g);
}
+ else if (!glist_isvisible(gl))
+ post("unable to create stub message in closed canvas!");
else
{
- int xpix, ypix;
- /* JMZ: not a good idea to go into interactive mode in a closed canvas... */
- if(!glist_isvisible(gl)){
- post("unable to create stub message in closed canvas!");
- return;
- }
+ int connectme, xpix, ypix, indx, nobj;
+ canvas_howputnew(gl, &connectme, &xpix, &ypix, &indx, &nobj);
+
pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
- glist_noselect(gl);
- glist_getnextxy(gl, &xpix, &ypix);
- x->m_text.te_xpix = xpix-3;
- x->m_text.te_ypix = ypix-3;
+ x->m_text.te_xpix = xpix;
+ x->m_text.te_ypix = ypix;
glist_add(gl, &x->m_text.te_g);
glist_noselect(gl);
glist_select(gl, &x->m_text.te_g);
gobj_activate(&x->m_text.te_g, gl, 1);
- canvas_startmotion(glist_getcanvas(gl));
+ if (connectme)
+ canvas_connect(gl, indx, 0, nobj, 0);
+ else canvas_startmotion(glist_getcanvas(gl));
}
}
@@ -876,19 +904,20 @@ void canvas_atom(t_glist *gl, t_atomtype type,
}
else
{
- int xpix, ypix;
+ int connectme, xpix, ypix, indx, nobj;
+ canvas_howputnew(gl, &connectme, &xpix, &ypix, &indx, &nobj);
outlet_new(&x->a_text,
x->a_atom.a_type == A_FLOAT ? &s_float: &s_symbol);
inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0);
pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
- glist_noselect(gl);
- glist_getnextxy(gl, &xpix, &ypix);
x->a_text.te_xpix = xpix;
x->a_text.te_ypix = ypix;
glist_add(gl, &x->a_text.te_g);
glist_noselect(gl);
glist_select(gl, &x->a_text.te_g);
- canvas_startmotion(glist_getcanvas(gl));
+ if (connectme)
+ canvas_connect(gl, indx, 0, nobj, 0);
+ else canvas_startmotion(glist_getcanvas(gl));
}
}
@@ -1321,10 +1350,18 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize)
else binbuf_text(x->te_binbuf, buf, bufsize);
}
+ /* this gets called when amessage gets sent to an object whose creation
+ failed, presumably because of loading a patch with a missing extern or
+ abstraction */
+static void text_anything(t_text *x, t_symbol *s, int argc, t_atom *argv)
+{
+}
+
void g_text_setup(void)
{
text_class = class_new(gensym("text"), 0, 0, sizeof(t_text),
CLASS_NOINLET | CLASS_PATCHABLE, 0);
+ class_addanything(text_class, text_anything);
message_class = class_new(gensym("message"), 0, (t_method)message_free,
sizeof(t_message), CLASS_PATCHABLE, 0);
diff --git a/pd/src/m_glob.c b/pd/src/m_glob.c
index c3a70e53..ca3b5d1a 100644
--- a/pd/src/m_glob.c
+++ b/pd/src/m_glob.c
@@ -8,6 +8,8 @@
t_class *glob_pdobject;
static t_class *maxclass;
+int sys_perf; /* true if we should query user on close and quit */
+
/* These "glob" routines, which implement messages to Pd, are from all
over. Some others are prototyped in m_imp.h as well. */
@@ -55,6 +57,11 @@ static void glob_version(t_pd *dummy, float f)
error("file format newer than this version of Pd (trying anyway...)");
}
+static void glob_perf(t_pd *dummy, float f)
+{
+ sys_perf = (f != 0);
+}
+
void max_default(t_pd *x, t_symbol *s, int argc, t_atom *argv)
{
int i;
@@ -121,6 +128,8 @@ void glob_init(void)
gensym("save-preferences"), 0);
class_addmethod(glob_pdobject, (t_method)glob_version,
gensym("version"), A_FLOAT, 0);
+ class_addmethod(glob_pdobject, (t_method)glob_perf,
+ gensym("perf"), A_FLOAT, 0);
#ifdef UNIX
class_addmethod(glob_pdobject, (t_method)glob_watchdog,
gensym("watchdog"), 0);
@@ -128,3 +137,16 @@ void glob_init(void)
class_addanything(glob_pdobject, max_default);
pd_bind(&glob_pdobject, gensym("pd"));
}
+
+ /* function to return version number at run time. Any of the
+ calling pointers may be zero in case you don't need all of them. */
+void sys_getversion(int *major, int *minor, int *bugfix)
+{
+ if (major)
+ *major = PD_MAJOR_VERSION;
+ if (minor)
+ *minor = PD_MINOR_VERSION;
+ if (bugfix)
+ *bugfix = PD_BUGFIX_VERSION;
+}
+
diff --git a/pd/src/m_pd.h b/pd/src/m_pd.h
index 3e686aa1..888ed936 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 "test6"
+#define PD_TEST_VERSION "test8"
/* 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 */
@@ -642,6 +642,9 @@ defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */
#define PD_BIGORSMALL(f) 0
#endif
+ /* get version number at run time */
+EXTERN void sys_getversion(int *major, int *minor, int *bugfix);
+
#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
}
#endif
diff --git a/pd/src/makefile.in b/pd/src/makefile.in
index ab6209ff..cba0f7a8 100644
--- a/pd/src/makefile.in
+++ b/pd/src/makefile.in
@@ -163,32 +163,33 @@ externs:
BINARYMODE=@binarymode@
-ABOUT_FILE=$(pddocdir)/1.manual/1.introduction.txt
+ABOUT_FILE=$(DESTDIR)$(pddocdir)/1.manual/1.introduction.txt
install: all
- install -d $(libpdbindir)
- install $(BIN_DIR)/$(GUINAME) $(libpdbindir)/$(GUINAME)
- install $(BIN_DIR)/pd-watchdog $(libpdbindir)/pd-watchdog
- install -m644 $(BIN_DIR)/pd.tk $(libpdbindir)/pd.tk
+ install -d $(DESTDIR)$(libpdbindir)
+ install $(BIN_DIR)/$(GUINAME) $(DESTDIR)$(libpdbindir)/$(GUINAME)
+ install $(BIN_DIR)/pd-watchdog $(DESTDIR)$(libpdbindir)/pd-watchdog
+ install -m644 $(BIN_DIR)/pd.tk $(DESTDIR)$(libpdbindir)/pd.tk
install -d $(DESTDIR)$(bindir)
install $(BINARYMODE) $(PDEXEC) $(DESTDIR)$(bindir)/pd
install -m755 $(BIN_DIR)/pdsend $(DESTDIR)$(bindir)/pdsend
install -m755 $(BIN_DIR)/pdreceive $(DESTDIR)$(bindir)/pdreceive
for dir in $(shell ls -1 ../doc | grep -v CVS); do \
echo "installing $$dir"; \
- install -d $(pddocdir)/$$dir ; \
- install -m644 -p ../doc/$$dir/*.* $(pddocdir)/$$dir ; \
+ install -d $(DESTDIR)$(pddocdir)/$$dir ; \
+ install -m644 -p ../doc/$$dir/*.* $(DESTDIR)$(pddocdir)/$$dir ; \
done
for dir in $(shell ls -1 ../doc/7.stuff | grep -v CVS); do \
echo "installing 7.stuff/$$dir"; \
- install -d $(pddocdir)/7.stuff/$$dir ; \
- install -m644 -p ../doc/7.stuff/$$dir/*.* $(pddocdir)/7.stuff/$$dir ; \
+ install -d $(DESTDIR)$(pddocdir)/7.stuff/$$dir ; \
+ install -m644 -p ../doc/7.stuff/$$dir/*.* \
+ $(DESTDIR)$(pddocdir)/7.stuff/$$dir ; \
done
mv $(ABOUT_FILE) $(ABOUT_FILE).tmp
cat $(ABOUT_FILE).tmp | sed 's|PD_VERSION|Pd version $(PD_VERSION)|' \
> $(ABOUT_FILE)
rm $(ABOUT_FILE).tmp
- cp -pr ../extra $(libpddir)/
- rm -f $(libpddir)/extra/*/*.o
+ cp -pr ../extra $(DESTDIR)$(libpddir)/
+ rm -f $(DESTDIR)$(libpddir)/extra/*/*.o
install -d $(DESTDIR)$(includedir)
install -m644 m_pd.h $(DESTDIR)$(includedir)/m_pd.h
install -d $(DESTDIR)$(mandir)/man1
@@ -230,7 +231,7 @@ makefile.dependencies: makefile
$(CC) $(CPPFLAGS) -M $(SRC) > makefile.dependencies
uninstall:
- rm -f -r $(libpddir)
+ rm -f -r $(DESTDIR)$(libpddir)
rm -f $(DESTDIR)$(bindir)/pd
rm -f $(DESTDIR)$(bindir)/pdsend
rm -f $(DESTDIR)$(bindir)/pdreceive
diff --git a/pd/src/notes.txt b/pd/src/notes.txt
index a64e02dc..fabdc332 100644
--- a/pd/src/notes.txt
+++ b/pd/src/notes.txt
@@ -1,5 +1,5 @@
---------------- dolist --------------------
-done:
+close patch with dirty GOP abstraction can't vis the abstraction to query
test:
compile on various versions of linux
@@ -15,6 +15,7 @@ mac:
Gnome: why don't windows pop up when clicked on?
problems:
+saving as "x.pd" on mac writes to "x.pd.pd"
if .pdsettings asks for an alsa device out of range, dialog
comes up with empty list
find asdf$1 (e.g.) doesn't work
@@ -29,7 +30,6 @@ look again at array vis/invis conundrum, g_template.c
TK commands to nonexistent windows? (occasionally still happens)
still can't detect when a window is moved or resized
open_via_path call in d_soundfile.c isn't threadsafe
-crashed Pd putting vec and template in wrong order in array element of struct
floor, ciel functions in expr misdeclared
graph names don't appear until graph moved? (invis/vis on new array/rename)
don't filter locked click() through getrect
diff --git a/pd/src/s_audio.c b/pd/src/s_audio.c
index 9f4e2051..81438bbe 100644
--- a/pd/src/s_audio.c
+++ b/pd/src/s_audio.c
@@ -175,7 +175,7 @@ void sys_setchsr(int chin, int chout, int sr)
/* set audio device settings (after cleaning up the specified device and
channel vectors). The audio devices are "zero based" (i.e. "0" means the
- first one.) We can later re-open audio and/or show the settings on a\
+ first one.) We can later re-open audio and/or show the settings on a
dialog window. */
void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev,
diff --git a/pd/src/s_audio_oss.c b/pd/src/s_audio_oss.c
index 2649d4e1..73f916ce 100644
--- a/pd/src/s_audio_oss.c
+++ b/pd/src/s_audio_oss.c
@@ -70,7 +70,6 @@ t_sample *sys_soundin;
/* OSS-specific private variables */
static int oss_blockmode = 1; /* flag to use "blockmode" */
-static int oss_32bit = 0; /* allow 23 bit transfers in OSS */
static char ossdsp[] = "/dev/dsp%d";
/* don't assume we can turn all 31 bits when doing float-to-fix;
@@ -109,12 +108,6 @@ void oss_init(void)
countedthem = 1;
}
-void oss_set32bit( void)
-{
- oss_32bit = 1;
-}
-
-
typedef struct _multidev {
int fd;
int channels;
@@ -128,15 +121,6 @@ int oss_reset(int fd) {
return err;
}
- /* The AFMT_S32_BLOCKED format is not defined in standard linux kernels
- but is proposed by Guenter Geiger to support extending OSS to handle
- 32 bit sample. This is user in Geiger's OSS driver for RME Hammerfall.
- I'm not clear why this isn't called AFMT_S32_[SLN]E... */
-
-#ifndef AFMT_S32_BLOCKED
-#define AFMT_S32_BLOCKED 0x0000400
-#endif
-
void oss_configure(t_oss_dev *dev, int srate, int dac, int skipblocksize)
{
int orig, param, nblk, fd = dev->d_fd, wantformat;
@@ -145,22 +129,12 @@ void oss_configure(t_oss_dev *dev, int srate, int dac, int skipblocksize)
audio_buf_info ainfo;
- /* set resolution - first try 4 byte samples */
- if (oss_32bit && (ioctl(fd,SNDCTL_DSP_GETFMTS,&param) >= 0) &&
- (param & AFMT_S32_BLOCKED))
- {
- wantformat = AFMT_S32_BLOCKED;
- dev->d_bytespersamp = 4;
- }
- else
- {
- wantformat = AFMT_S16_NE;
- dev->d_bytespersamp = 2;
- }
+ /* we only know how to do 2 byte samples */
+ wantformat = AFMT_S16_NE;
+ dev->d_bytespersamp = 2;
+
param = wantformat;
- if (sys_verbose)
- post("bytes per sample = %d", dev->d_bytespersamp);
if (ioctl(fd, SNDCTL_DSP_SETFMT, &param) == -1)
fprintf(stderr,"OSS: Could not set DSP format\n");
else if (wantformat != param)
@@ -740,18 +714,7 @@ int oss_send_dacs(void)
linux_dacs[dev].d_dropcount--;
else
{
- if (linux_dacs[dev].d_bytespersamp == 4)
- {
- for (i = DEFDACBLKSIZE * nchannels, fp1 = sys_soundout +
- DEFDACBLKSIZE*thischan,
- lp = (t_oss_int32 *)buf; i--; fp1++, lp++)
- {
- float f = *fp1 * 2147483648.;
- *lp = (f >= 2147483647. ? 2147483647. :
- (f < -2147483648. ? -2147483648. : f));
- }
- }
- else
+ if (linux_dacs[dev].d_bytespersamp == 2)
{
for (i = DEFDACBLKSIZE, fp1 = sys_soundout +
DEFDACBLKSIZE*thischan,
@@ -798,16 +761,7 @@ int oss_send_dacs(void)
}
timeref = timenow;
- if (linux_adcs[dev].d_bytespersamp == 4)
- {
- for (i = DEFDACBLKSIZE*nchannels,
- fp1 = sys_soundin + thischan*DEFDACBLKSIZE,
- lp = (t_oss_int32 *)buf; i--; fp1++, lp++)
- {
- *fp1 = ((float)(*lp))*(float)(1./2147483648.);
- }
- }
- else
+ if (linux_adcs[dev].d_bytespersamp == 2)
{
for (i = DEFDACBLKSIZE,fp1 = sys_soundin + thischan*DEFDACBLKSIZE,
sp = (t_oss_int16 *)buf; i--; fp1++, sp += nchannels)
diff --git a/pd/src/s_audio_pa.c b/pd/src/s_audio_pa.c
index 4ceeb6c6..66618d46 100644
--- a/pd/src/s_audio_pa.c
+++ b/pd/src/s_audio_pa.c
@@ -11,7 +11,6 @@
#include "s_stuff.h"
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <portaudio.h>
#include "s_audio_pablio.h"
@@ -30,11 +29,15 @@ static t_audiocallback pa_callback;
int pa_foo;
+#ifndef MSW
+#include <unistd.h>
+#endif
static void pa_init(void)
{
static int initialized;
if (!initialized)
{
+#ifndef MSW
/* Initialize PortAudio */
/* for some reason Pa_Initialize(0 closes file descriptor 1.
As a workaround, dup it to another number and dup2 it back
@@ -46,6 +49,9 @@ static void pa_init(void)
dup2(newfd, 1);
close(newfd);
}
+#else
+ int err = Pa_Initialize();
+#endif
if ( err != paNoError )
{
fprintf( stderr,
diff --git a/pd/src/s_loader.c b/pd/src/s_loader.c
index bc637dce..6cc497c4 100644
--- a/pd/src/s_loader.c
+++ b/pd/src/s_loader.c
@@ -203,8 +203,6 @@ gotone:
return (1);
}
-/* callback type definition */
-typedef int (*loader_t)(t_canvas *canvas, char *classname);
/* linked list of loaders */
typedef struct loader_queue {
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index cb4bf7af..8e9cb08d 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -333,7 +333,6 @@ static char *(usagemessage[]) = {
#ifdef USEAPI_OSS
"-oss -- use OSS audio API\n",
-"-32bit ----- allow 32 bit OSS audio (for RME Hammerfall)\n",
#endif
#ifdef USEAPI_ALSA
@@ -619,12 +618,6 @@ int sys_argparse(int argc, char **argv)
sys_set_audio_api(API_OSS);
argc--; argv++;
}
- else if (!strcmp(*argv, "-32bit"))
- {
- sys_set_audio_api(API_OSS);
- oss_set32bit();
- argc--; argv++;
- }
#endif
#ifdef USEAPI_ALSA
else if (!strcmp(*argv, "-alsa"))
diff --git a/pd/src/s_stuff.h b/pd/src/s_stuff.h
index 4af5c754..0fb2497e 100644
--- a/pd/src/s_stuff.h
+++ b/pd/src/s_stuff.h
@@ -49,10 +49,13 @@ EXTERN int sys_hostfontsize(int fontsize);
extern int sys_defaultfont;
extern t_symbol *sys_libdir; /* library directory for auxilliary files */
-extern t_symbol *sys_guidir; /* directory holding pd_gui (also pd, u_pdsend, etc) */
+extern t_symbol *sys_guidir; /* directory holding pd_gui, u_pdsend, etc */
/* s_loader.c */
-int sys_load_lib(t_canvas *canvas, char *filename);
+
+typedef int (*loader_t)(t_canvas *canvas, char *classname); /* callback type */
+EXTERN int sys_load_lib(t_canvas *canvas, char *filename);
+EXTERN void sys_register_loader(loader_t loader);
/* s_audio.c */