From 1eef182b31a4cb2f55e26e7527469fc2902368a3 Mon Sep 17 00:00:00 2001
From: "N.N." <krzyszcz@users.sourceforge.net>
Date: Mon, 28 Feb 2005 13:10:41 +0000
Subject: cyclone alpha53 (see notes.txt for cyclone, bin and shared)

svn path=/trunk/externals/miXed/; revision=2590
---
 cyclone/hammer/Table.c   |  57 +++++++++++++++++++-----
 cyclone/hammer/capture.c |   8 ++--
 cyclone/hammer/coll.c    | 111 ++++++++++++++++++++++++++++-------------------
 cyclone/hammer/prob.c    |   3 +-
 cyclone/hammer/seq.c     |  72 +++++++++++++++++-------------
 5 files changed, 159 insertions(+), 92 deletions(-)

(limited to 'cyclone/hammer')

diff --git a/cyclone/hammer/Table.c b/cyclone/hammer/Table.c
index a120f13..00043f0 100644
--- a/cyclone/hammer/Table.c
+++ b/cyclone/hammer/Table.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004 krzYszcz and others.
+/* Copyright (c) 2004-2005 krzYszcz and others.
  * For information on usage and redistribution, and for a DISCLAIMER OF ALL
  * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
 
@@ -225,10 +225,48 @@ static int tablecommon_quantile(t_tablecommon *cc, float f)
     return (ndx);
 }
 
+static void tablecommon_fromatoms(t_tablecommon *cc, int ac, t_atom *av)
+{
+    int i, size = 0, nsyms = 0;
+    t_atom *ap;
+    int *ptr;
+    cc->c_increation = 1;
+    for (i = 0, ap = av; i < ac; i++, ap++)
+    {
+	if (ap->a_type == A_FLOAT)
+	    size++;
+	else if (ap->a_type == A_SYMBOL)
+	    nsyms++, size++;
+    }
+    if (size < ac)
+	loud_warning(0, "Table", "%d invalid atom%s ignored",
+		     ac - size, (ac - size > 1 ? "s" : ""));
+    if (nsyms)
+	loud_warning(0, "Table", "%d symbol%s bashed to zero",
+		     nsyms, (nsyms > 1 ? "s" : ""));
+    tablecommon_setlength(cc, size);
+    size = cc->c_length;
+    ptr = cc->c_table;
+    for (i = 0; i < ac; i++, av++)
+    {
+	if (av->a_type == A_FLOAT)
+	    *ptr++ = (int)av->a_w.w_float;
+	else if (av->a_type == A_SYMBOL)
+	    *ptr++ = 0;
+	else
+	    continue;
+	if (size-- == 1)
+	    break;
+    }
+    while (size--)
+	*ptr++ = 0;
+    cc->c_increation = 0;
+}
+
+/* FIXME keep int precision: save/load directly, not through a bb */
 /* LATER binary files */
 static void tablecommon_doread(t_tablecommon *cc, t_symbol *fn, t_canvas *cv)
 {
-    /* FIXME */
     t_binbuf *bb = binbuf_new();
     int ac;
     t_atom *av;
@@ -249,8 +287,8 @@ static void tablecommon_doread(t_tablecommon *cc, t_symbol *fn, t_canvas *cv)
 	av->a_type == A_SYMBOL &&
 	av->a_w.w_symbol == gensym("table"))
     {
+	tablecommon_fromatoms(cc, ac - 1, av + 1);
 	post("Table: %s read successful", fn->s_name);  /* CHECKME */
-	/* FIXME */
     }
 #if 0  /* FIXME */
     else  /* CHECKME complaint */
@@ -325,7 +363,7 @@ static void table_embedhook(t_pd *z, t_binbuf *bb, t_symbol *bindsym)
 
 static void tablecommon_editorhook(t_pd *z, t_symbol *s, int ac, t_atom *av)
 {
-    /* FIXME */
+    tablecommon_fromatoms((t_tablecommon *)z, ac, av);
 }
 
 static void tablecommon_free(t_tablecommon *cc)
@@ -754,7 +792,7 @@ static int tablecommon_editorappend(t_tablecommon *cc,
 	*bp++ = ' ', cnt++;
     cnt += sprintf(bp, "%d", v);
     if (col + cnt > 80)
-	buf[0] = '\n', col = cnt;
+	buf[0] = '\n', col = cnt - 1;  /* assuming col > 0 */
     else
 	col += cnt;
     hammereditor_append(cc->c_filehandle, buf);
@@ -763,22 +801,19 @@ static int tablecommon_editorappend(t_tablecommon *cc,
 
 static void table_open(t_table *x)
 {
-    /* FIXME */
     t_tablecommon *cc = x->x_common;
     char buf[MAXPDSTRING];
     int *bp = cc->c_table;
     int count = cc->c_length, col = 0;
-    /* LATER prepend "table: " */
-    hammereditor_open(cc->c_filehandle,
-		      /* CHECKED default name is plain `Untitled' */
-		      x->x_name ? x->x_name->s_name : "Untitled");
+    hammereditor_open(cc->c_filehandle, (x->x_name ? x->x_name->s_name : 0), 0);
     while (count--)
 	col = tablecommon_editorappend(cc, *bp++, buf, col);
+    hammereditor_setdirty(cc->c_filehandle, 0);
 }
 
 static void table_wclose(t_table *x)
 {
-    /* FIXME */
+    hammereditor_close(x->x_common->c_filehandle, 1);
 }
 
 static void table_click(t_table *x, t_floatarg xpos, t_floatarg ypos,
diff --git a/cyclone/hammer/capture.c b/cyclone/hammer/capture.c
index b36c421..7598a59 100644
--- a/cyclone/hammer/capture.c
+++ b/cyclone/hammer/capture.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002-2003 krzYszcz and others.
+/* Copyright (c) 2002-2005 krzYszcz and others.
  * For information on usage and redistribution, and for a DISCLAIMER OF ALL
  * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
 
@@ -87,7 +87,7 @@ static int capture_formatint(int i, char *buf, int col,
 	*bp++ = ' ', cnt++;
     cnt += sprintf(bp, fmt, i);
     if (col + cnt > maxcol)
-	buf[0] = '\n', col = cnt;
+	buf[0] = '\n', col = cnt - 1;  /* assuming col > 0 */
     else
 	col += cnt;
     return (col);
@@ -102,7 +102,7 @@ static int capture_formatfloat(float f, char *buf, int col,
 	*bp++ = ' ', cnt++;
     cnt += sprintf(bp, fmt, f);
     if (col + cnt > maxcol)
-	buf[0] = '\n', col = cnt;
+	buf[0] = '\n', col = cnt - 1;  /* assuming col > 0 */
     else
 	col += cnt;
     return (col);
@@ -194,7 +194,7 @@ static void capture_open(t_capture *x)
 {
     int count = x->x_count;
     char buf[MAXPDSTRING];
-    hammereditor_open(x->x_filehandle, "t_capture");  /* CHECKED */
+    hammereditor_open(x->x_filehandle, "Capture", "");  /* CHECKED */
     if (count < x->x_bufsize)
     {
 	float *bp = x->x_buffer;
diff --git a/cyclone/hammer/coll.c b/cyclone/hammer/coll.c
index a0644c8..fc81b30 100644
--- a/cyclone/hammer/coll.c
+++ b/cyclone/hammer/coll.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002-2004 krzYszcz and others.
+/* Copyright (c) 2002-2005 krzYszcz and others.
  * For information on usage and redistribution, and for a DISCLAIMER OF ALL
  * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
 
@@ -9,10 +9,8 @@
 #include "common/loud.h"
 #include "hammer/file.h"
 
-/* FIXME sort -1 -1, sort 1 crashes in pd large */
-/* FIXME sort crashes after (corrupt?) transfers from the editor */
+/* LATER profile for the bottlenecks of insertion and sorting */
 /* LATER make sure that ``reentrancy protection hack'' is really working... */
-/* CHECKME default fname for 'write' -- c_filename, x_name, nothing? */
 
 #ifdef KRZYSZCZ
 //#define COLL_DEBUG
@@ -42,7 +40,7 @@ typedef struct _collcommon
     int            c_selfmodified;
     int            c_entered;    /* a counter, LATER rethink */
     int            c_embedflag;  /* common field (CHECKED in 'TEXT' files) */
-    t_symbol      *c_filename;
+    t_symbol      *c_filename;   /* CHECKED common for all, read and write */
     t_canvas      *c_lastcanvas;
     t_hammerfile  *c_filehandle;
     t_collelem    *c_first;
@@ -98,20 +96,27 @@ static void collelem_free(t_collelem *ep)
 }
 
 /* CHECKME again... apparently c74 is not able to fix this for good */
-/* result: 1 for ep1 < ep2, otherwise 0 (symbols are less then floats) */
-static int collelem_less(t_collelem *ep1, t_collelem *ep2, int ndx)
+/* result: 1 for ep1 < ep2, 0 for ep1 >= ep2, all symbols are < any float */
+static int collelem_less(t_collelem *ep1, t_collelem *ep2, int ndx, int swap)
 {
+    int isless;
+    if (swap)
+    {
+	t_collelem *ep = ep1;
+	ep1 = ep2;
+	ep2 = ep;
+    }
     if (ndx < 0)
     {
 	if (ep1->e_symkey)
-	    return (ep2->e_symkey ?
-		    strcmp(ep1->e_symkey->s_name,
-			   ep2->e_symkey->s_name) < 0
-		    : 1);  /* CHECKED incompatible with 4.07, but consistent */
+	    isless =
+		(ep2->e_symkey ? strcmp(ep1->e_symkey->s_name,
+					ep2->e_symkey->s_name) < 0
+		 : 1);  /* CHECKED incompatible with 4.07, but consistent */
 	else if (ep2->e_symkey)
-	    return (0);  /* CHECKED incompatible with 4.07, but consistent */
+	    isless = 0;  /* CHECKED incompatible with 4.07, but consistent */
 	else
-	    return (ep1->e_numkey < ep2->e_numkey);  /* CHECKED in 4.07 */
+	    isless = (ep1->e_numkey < ep2->e_numkey);  /* CHECKED in 4.07 */
     }
     else
     {
@@ -122,25 +127,25 @@ static int collelem_less(t_collelem *ep1, t_collelem *ep2, int ndx)
 	if (ap1->a_type == A_FLOAT)
 	{
  	    if (ap2->a_type == A_FLOAT)
-		return (ap1->a_w.w_float < ap2->a_w.w_float);
+		isless = (ap1->a_w.w_float < ap2->a_w.w_float);
  	    else if (ap2->a_type == A_SYMBOL)
-		return (0);
+		isless = 0;
 	    else
-		return (1);
+		isless = 1;
 	}
 	else if (ap1->a_type == A_SYMBOL)
 	{
 	    if (ap2->a_type == A_FLOAT)
-		return (1);
+		isless = 1;
 	    else if (ap2->a_type == A_SYMBOL)
-		return (strcmp(ap1->a_w.w_symbol->s_name,
-			       ap2->a_w.w_symbol->s_name) < 0);
+		isless = (strcmp(ap1->a_w.w_symbol->s_name,
+				 ap2->a_w.w_symbol->s_name) < 0);
 	    else
-		return (1);
+		isless = 1;
 	}
-	else
-	    return (0);
+	else isless = 0;
     }
+    return (isless);
 }
 
 static t_collelem *collcommon_numkey(t_collcommon *cc, int numkey)
@@ -379,10 +384,10 @@ static void collcommon_renumber(t_collcommon *cc, int startkey)
 }
 
 /* LATER choose a better algo, after coll's storage structures stabilize.
-   Note, that even the simple insertion sort below (n-square) might prove
-   better for dlls, than theoretically efficient algo (nlogn) which requires
+   Note, that even the simple insertion sort below (n-square) might prove better
+   for bi-directional lists, than theoretically efficient algo (nlogn) requiring
    random access emulation.  Avoiding recursion is not a bad idea, too. */
-static void collcommon_sort(t_collcommon *cc, int asc, int ndx)
+static void collcommon_sort(t_collcommon *cc, int descending, int ndx)
 {
     t_collelem *min = cc->c_first;
     t_collelem *ep;
@@ -391,7 +396,8 @@ static void collcommon_sort(t_collcommon *cc, int asc, int ndx)
 	cc->c_increation = 1;
 	/* search for a sentinel element */
  	do
-	    if (collelem_less(ep, min, ndx) == asc) min = ep;
+	    if (collelem_less(ep, min, ndx, descending))
+		min = ep;
 	while (ep = ep->e_next);
 	/* prepend it */
 	collcommon_swaplinks(cc, cc->c_first, min);
@@ -401,9 +407,12 @@ static void collcommon_sort(t_collcommon *cc, int asc, int ndx)
 	{
 	    t_collelem *next = ep->e_next;
 	    for (min = ep->e_prev;
-		 collelem_less(ep, min, ndx) == asc;
+		 min &&  /* LATER remove */
+		     collelem_less(ep, min, ndx, descending);
 		 min = min->e_prev);
-	    if (ep != min->e_next)
+	    if (!min)  /* LATER remove */
+		loudbug_bug("collcommon_sort");
+	    else if (ep != min->e_next)
 	    {
 		collcommon_takeout(cc, ep);
 		collcommon_putafter(cc, ep, min);
@@ -457,12 +466,17 @@ static t_collelem *collcommon_tonumkey(t_collcommon *cc, int numkey,
 	{
 	    collcommon_putbefore(cc, new, old);
 	    do
-		if (old->e_hasnumkey) old->e_numkey++;  /* LATER rethink */
+		if (old->e_hasnumkey)
+		    /* CHECKED incremented up to the last one; incompatible:
+		       elements with numkey == 0 not incremented (a bug?) */
+		    old->e_numkey++;
 	    while (old = old->e_next);
 	}
 	else
 	{
-	    int closestkey = 0;  /* LATER rethink */
+	    /* CHECKED negative numkey always put before the last element,
+	       zero numkey always becomes the new head */
+	    int closestkey = 0;
 	    t_collelem *closest = 0, *ep;
 	    for (ep = cc->c_first; ep; ep = ep->e_next)
 	    {
@@ -501,7 +515,7 @@ static t_collelem *collcommon_tosymkey(t_collcommon *cc, t_symbol *symkey,
     return (new);
 }
 
-static int collcommon_fromlist(t_collcommon *cc, int ac, t_atom *av)
+static int collcommon_fromatoms(t_collcommon *cc, int ac, t_atom *av)
 {
     int hasnumkey = 0, numkey;
     t_symbol *symkey = 0;
@@ -565,7 +579,7 @@ static int collcommon_fromlist(t_collcommon *cc, int ac, t_atom *av)
 
 static int collcommon_frombinbuf(t_collcommon *cc, t_binbuf *bb)
 {
-    return (collcommon_fromlist(cc, binbuf_getnatom(bb), binbuf_getvec(bb)));
+    return (collcommon_fromatoms(cc, binbuf_getnatom(bb), binbuf_getvec(bb)));
 }
 
 static void collcommon_doread(t_collcommon *cc, t_symbol *fn, t_canvas *cv)
@@ -730,7 +744,7 @@ static void coll_embedhook(t_pd *z, t_binbuf *bb, t_symbol *bindsym)
 
 static void collcommon_editorhook(t_pd *z, t_symbol *s, int ac, t_atom *av)
 {
-    int nlines = collcommon_fromlist((t_collcommon *)z, ac, av);
+    int nlines = collcommon_fromatoms((t_collcommon *)z, ac, av);
     if (nlines < 0)
 	loud_error(0, "coll: editing error in line %d", 1 - nlines);
 }
@@ -1169,7 +1183,7 @@ static void coll_sort(t_coll *x, t_floatarg f1, t_floatarg f2)
     int dir, ndx;
     if (loud_checkint((t_pd *)x, f1, &dir, gensym("sort")) &&
 	loud_checkint((t_pd *)x, f2, &ndx, gensym("sort")))
-	collcommon_sort(x->x_common, (dir < 0 ? 1 : 0),
+	collcommon_sort(x->x_common, (dir < 0 ? 0 : 1),
 			(ndx < 0 ? -1 : (ndx ? ndx - 1 : 0)));
 }
 
@@ -1298,9 +1312,12 @@ static void coll_min(t_coll *x, t_floatarg f)
     if (loud_checkint((t_pd *)x, f, &ndx, gensym("min")))
     {
 	t_collelem *found;
-	if (ndx <= 0)
-	    ndx = 0;  /* LATER consider complaining, CHECKME */
-	else ndx--;
+	if (ndx > 0)
+	    ndx--;
+	/* LATER consider complaining: */
+	else if (ndx < 0)
+	    return;  /* CHECKED silently rejected */
+	/* else CHECKED silently defaults to 1 */
 	if (found = coll_firsttyped(x, ndx, A_FLOAT))
 	{
 	    t_float result = found->e_data[ndx].a_w.w_float;
@@ -1327,9 +1344,12 @@ static void coll_max(t_coll *x, t_floatarg f)
     if (loud_checkint((t_pd *)x, f, &ndx, gensym("max")))
     {
 	t_collelem *found;
-	if (ndx <= 0)
-	    ndx = 0;  /* LATER consider complaining, CHECKME */
-	else ndx--;
+	if (ndx > 0)
+	    ndx--;
+	/* LATER consider complaining: */
+	else if (ndx < 0)
+	    return;  /* CHECKED silently rejected */
+	/* else CHECKED silently defaults to 1 */
 	if (found = coll_firsttyped(x, ndx, A_FLOAT))
 	{
 	    t_float result = found->e_data[ndx].a_w.w_float;
@@ -1383,7 +1403,7 @@ static void coll_write(t_coll *x, t_symbol *s)
     if (s && s != &s_)
 	collcommon_dowrite(cc, s, x->x_canvas);
     else
-	hammerpanel_save(cc->c_filehandle, 0, 0);  /* CHECKME default name */
+	hammerpanel_save(cc->c_filehandle, 0, 0);  /* CHECKED no default name */
 }
 
 static void coll_readagain(t_coll *x)
@@ -1401,7 +1421,7 @@ static void coll_writeagain(t_coll *x)
     if (cc->c_filename)
 	collcommon_dowrite(cc, 0, 0);
     else
-	hammerpanel_save(cc->c_filehandle, 0, 0);  /* CHECKME default name */
+	hammerpanel_save(cc->c_filehandle, 0, 0);  /* CHECKED no default name */
 }
 
 static void coll_filetype(t_coll *x, t_symbol *s)
@@ -1431,9 +1451,8 @@ static void coll_open(t_coll *x)
     int i, natoms, newline;
     t_atom *ap;
     char buf[MAXPDSTRING];
-    /* LATER prepend "coll: " */
     hammereditor_open(cc->c_filehandle,
-		      x->x_name ? x->x_name->s_name : "Untitled");
+		      (x->x_name ? x->x_name->s_name : "Untitled"), "coll");
     collcommon_tobinbuf(cc, bb);
     natoms = binbuf_getnatom(bb);
     ap = binbuf_getvec(bb);
@@ -1453,10 +1472,12 @@ static void coll_open(t_coll *x)
 	hammereditor_append(cc->c_filehandle, buf);
 	ap++;
     }
+    hammereditor_setdirty(cc->c_filehandle, 0);
     binbuf_free(bb);
 }
 
-/* asking and storing the changes -- CHECKME close window, and 'wclose' */
+/* CHECKED if there was any editing, both close window and 'wclose'
+   ask and replace the contents.  LATER debug. */
 static void coll_wclose(t_coll *x)
 {
     hammereditor_close(x->x_common->c_filehandle, 1);
diff --git a/cyclone/hammer/prob.c b/cyclone/hammer/prob.c
index 2794858..83960eb 100644
--- a/cyclone/hammer/prob.c
+++ b/cyclone/hammer/prob.c
@@ -244,12 +244,13 @@ static void prob__silent(t_prob *x)
     }
 }
 
+/* CHECKED not available, LATER full editing */
 static void prob_click(t_prob *x, t_floatarg xpos, t_floatarg ypos,
 		       t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
 {
     t_probtrans *state;
     char buf[64];
-    hammereditor_open(x->x_filehandle, "prob");
+    hammereditor_open(x->x_filehandle, 0, 0);
     for (state = x->x_translist; state; state = state->tr_nextstate)
     {
 	t_probtrans *trans;
diff --git a/cyclone/hammer/seq.c b/cyclone/hammer/seq.c
index 030a7ab..26027c0 100644
--- a/cyclone/hammer/seq.c
+++ b/cyclone/hammer/seq.c
@@ -860,26 +860,22 @@ mfwritefailed:
     return (result);
 }
 
-/* FIXME */
-/* CHECKED absolute timestamps, semi-terminated, verified */
-static int seq_frombinbuf(t_seq *x, t_binbuf *bb)
+/* CHECKED text file input: absolute timestamps, semi-terminated, verified */
+static int seq_fromatoms(t_seq *x, int ac, t_atom *av, int abstime)
 {
-    int nevents = 0;
-    int ac = binbuf_getnatom(bb);
-    t_atom *av = binbuf_getvec(bb);
-    while (ac--)
-	if (av++->a_type == A_SEMI)  /* FIXME parsing */
+    int i, nevents = 0;
+    t_atom *ap;
+    for (i = 0, ap = av; i < ac; i++, ap++)
+	if (ap->a_type == A_SEMI)  /* FIXME parsing */
 	    nevents++;
     if (nevents)
     {
 	t_seqevent *ep;
 	float prevtime = 0;
-	int i = -1;
 	if (!seq_dogrowing(x, nevents, 0))
 	    return (0);
+	i = -1;
 	nevents = 0;
-	ac = binbuf_getnatom(bb);
-	av = binbuf_getvec(bb);
 	ep = x->x_sequence;
 	while (ac--)
 	{
@@ -887,8 +883,12 @@ static int seq_frombinbuf(t_seq *x, t_binbuf *bb)
 	    {
 		if (i < 0)
 		{
-		    ep->e_delta = av->a_w.w_float - prevtime;
-		    prevtime = av->a_w.w_float;
+		    if (abstime)
+		    {
+			ep->e_delta = av->a_w.w_float - prevtime;
+			prevtime = av->a_w.w_float;
+		    }
+		    else ep->e_delta = av->a_w.w_float;
 		    i = 0;
 		}
 		else if (i < 4)
@@ -945,7 +945,8 @@ static void seq_textread(t_seq *x, char *path)
     }
     else
     {
-	int nlines = seq_frombinbuf(x, bb);
+	int nlines = /* CHECKED absolute timestamps */
+	    seq_fromatoms(x, binbuf_getnatom(bb), binbuf_getvec(bb), 1);
 	if (nlines < 0)
 	    /* CHECKED "bad MIDI file (truncated)" alert, even if a text file */
 	    loud_error((t_pd *)x, "bad text file (truncated)");
@@ -1047,11 +1048,13 @@ static void seq_write(t_seq *x, t_symbol *s)
 			 canvas_getdir(x->x_canvas), x->x_defname);
 }
 
-static void seq_eventstring(t_seq *x, char *buf, t_seqevent *ep)
+static void seq_eventstring(t_seq *x, char *buf, t_seqevent *ep, int editable)
 {
     unsigned char *bp = ep->e_bytes;
     int i;
-    if (*bp < 128 || *bp == 247)
+    if (editable)
+	sprintf(buf, "%g", ep->e_delta);
+    else if (*bp < 128 || *bp == 247)
 	sprintf(buf, "(%g)->", ep->e_delta);
     else
 	sprintf(buf, "(%g)", ep->e_delta);
@@ -1079,9 +1082,8 @@ static void seq_print(t_seq *x)
 	    truncated = 0;
 	endpost();
 	while (nevents--)
-	{
-	    /* CHECKED bytes are space-separated, no semi */
-	    seq_eventstring(x, buf, ep);
+	{  /* CHECKED bytes are space-separated, no semi */
+	    seq_eventstring(x, buf, ep, 0);
 	    post(buf);
 	    ep++;
 	}
@@ -1090,22 +1092,28 @@ static void seq_print(t_seq *x)
     else post(" no sequence");  /* CHECKED */
 }
 
-static void seq_properties(t_gobj *z, t_glist *glist)
+static void seq_editorhook(t_pd *z, t_symbol *s, int ac, t_atom *av)
+{
+    seq_fromatoms((t_seq *)z, ac, av, 0);
+}
+
+static void seq_click(t_seq *x, t_floatarg xpos, t_floatarg ypos,
+		      t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
 {
-    t_seq *x = (t_seq *)z;
     t_seqevent *ep = x->x_sequence;
     int nevents = x->x_nevents;
     char buf[MAXPDSTRING+2];
-    sprintf(buf, "seq: %s", (x->x_defname && x->x_defname != &s_ ?
-			     x->x_defname->s_name : "<anonymous>"));
-    hammereditor_open(x->x_filehandle, buf);
+    hammereditor_open(x->x_filehandle,
+		      (x->x_defname && x->x_defname != &s_ ?
+		       x->x_defname->s_name : "<anonymous>"), 0);
     while (nevents--)
-    {
-	seq_eventstring(x, buf, ep);
-	strcat(buf, "\n");
+    {  /* LATER rethink sysex continuation */
+	seq_eventstring(x, buf, ep, 1);
+	strcat(buf, ";\n");
 	hammereditor_append(x->x_filehandle, buf);
 	ep++;
     }
+    hammereditor_setdirty(x->x_filehandle, 0);
 }
 
 static void seq_free(t_seq *x)
@@ -1129,8 +1137,8 @@ static void *seq_new(t_symbol *s)
 	warned = 1;
     }
     x->x_canvas = canvas_getcurrent();
-    x->x_filehandle = hammerfile_new((t_pd *)x, 0,
-				     seq_readhook, seq_writehook, 0);
+    x->x_filehandle = hammerfile_new((t_pd *)x, 0, seq_readhook, seq_writehook,
+				     seq_editorhook);
     x->x_timescale = 1.;
     x->x_newtimescale = 1.;
     x->x_prevtime = 0.;
@@ -1188,6 +1196,7 @@ void seq_setup(void)
     class_addmethod(seq_class, (t_method)seq_print,
 		    gensym("print"), 0);
 
+    /* incompatible extensions */
     class_addmethod(seq_class, (t_method)seq_pause,
 		    gensym("pause"), 0);
     class_addmethod(seq_class, (t_method)seq_continue,
@@ -1200,8 +1209,9 @@ void seq_setup(void)
 		    gensym("cd"), A_DEFSYM, 0);
     class_addmethod(seq_class, (t_method)seq_pwd,
 		    gensym("pwd"), A_SYMBOL, 0);
-
-    forky_setpropertiesfn(seq_class, seq_properties);
+    class_addmethod(seq_class, (t_method)seq_click,
+		    gensym("click"),
+		    A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
     hammerfile_setup(seq_class, 0);
     fitter_setup(seq_class, 0);
 }
-- 
cgit v1.2.1