aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorN.N. <krzyszcz@users.sourceforge.net>2005-02-28 13:10:41 +0000
committerN.N. <krzyszcz@users.sourceforge.net>2005-02-28 13:10:41 +0000
commit1eef182b31a4cb2f55e26e7527469fc2902368a3 (patch)
treea08b51f0c41fb879f4d62f3bb4a6d5860d22b4fe /shared
parentbfb359fd22e61faaca3a6e49ad3b7a81f2d71551 (diff)
cyclone alpha53 (see notes.txt for cyclone, bin and shared)
svn path=/trunk/externals/miXed/; revision=2590
Diffstat (limited to 'shared')
-rw-r--r--shared/common/binport.c10
-rw-r--r--shared/hammer/file.c71
-rw-r--r--shared/hammer/file.h3
-rw-r--r--shared/notes.txt8
4 files changed, 77 insertions, 15 deletions
diff --git a/shared/common/binport.c b/shared/common/binport.c
index 1df9571..90cf251 100644
--- a/shared/common/binport.c
+++ b/shared/common/binport.c
@@ -96,6 +96,7 @@ enum {
BINPORT_NULLTYPE,
BINPORT_INTTYPE = 1, BINPORT_FLOATTYPE, BINPORT_SYMTYPE,
BINPORT_DEFINTTYPE = 5, BINPORT_DEFFLOATTYPE, BINPORT_DEFSYMTYPE,
+ BINPORT_DEFDOLLSYMTYPE = 9,
BINPORT_SEMITYPE = 10, BINPORT_COMMATYPE,
BINPORT_DOLLARTYPE, BINPORT_DOLLSYMTYPE
};
@@ -535,6 +536,15 @@ static int binport_nextatom(t_binport *bp, t_atom *ap)
if (!binport_setbysymtable(bp, ap, opval))
goto badbin;
break;
+ case BINPORT_DEFDOLLSYMTYPE: /* half-byte #symbol id */
+ if (!binport_setbysymtable(bp, ap, opval))
+ goto badbin;
+ sprintf(buf, "#%s", ap->a_w.w_symbol->s_name);
+#ifdef BINPORT_DEBUG
+ binport_warning(buf);
+#endif
+ ap->a_w.w_symbol = gensym(buf);
+ break;
case BINPORT_SEMITYPE:
/* LATER warn about nonzero opval */
ap->a_type = A_SEMI;
diff --git a/shared/hammer/file.c b/shared/hammer/file.c
index ecb5006..c671946 100644
--- a/shared/hammer/file.c
+++ b/shared/hammer/file.c
@@ -58,17 +58,20 @@ static t_hammerfile *hammerfile_getproxy(t_pd *master)
return (0);
}
-/* FIXME somehow plug the "save changes" dialog into close-by-wm */
-/* FIXME dirty condition */
static void hammereditor_guidefs(void)
{
- sys_gui("proc hammereditor_open {name geometry title} {\n");
+ sys_gui("proc hammereditor_open {name geometry title sendable} {\n");
sys_gui(" if {[winfo exists $name]} {\n");
sys_gui(" $name.text delete 1.0 end\n");
sys_gui(" } else {\n");
sys_gui(" toplevel $name\n");
sys_gui(" wm title $name $title\n");
sys_gui(" wm geometry $name $geometry\n");
+ sys_gui(" if {$sendable} {\n");
+ sys_gui(" wm protocol $name WM_DELETE_WINDOW \\\n");
+ sys_gui(" [concat hammereditor_close $name 1]\n");
+ sys_gui(" bind $name <<Modified>> \"hammereditor_dodirty $name\"\n");
+ sys_gui(" }\n");
sys_gui(" text $name.text -relief raised -bd 2 \\\n");
sys_gui(" -font -*-courier-medium--normal--12-* \\\n");
sys_gui(" -yscrollcommand \"$name.scroll set\" -background lightgrey\n");
@@ -78,6 +81,23 @@ static void hammereditor_guidefs(void)
sys_gui(" }\n");
sys_gui("}\n");
+ sys_gui("proc hammereditor_dodirty {name} {\n");
+ sys_gui(" if {[catch {$name.text edit modified} dirty]} {set dirty 0}\n");
+ sys_gui(" set title [wm title $name]\n");
+ sys_gui(" set dt [string equal -length 1 $title \"*\"]\n");
+ sys_gui(" if {$dirty} {\n");
+ sys_gui(" if {$dt == 0} {wm title $name *$title}\n");
+ sys_gui(" } else {\n");
+ sys_gui(" if {$dt} {wm title $name [string range $title 1 end]}\n");
+ sys_gui(" }\n");
+ sys_gui("}\n");
+
+ sys_gui("proc hammereditor_setdirty {name flag} {\n");
+ sys_gui(" if {[winfo exists $name]} {\n");
+ sys_gui(" catch {$name.text edit modified $flag}\n");
+ sys_gui(" }\n");
+ sys_gui("}\n");
+
sys_gui("proc hammereditor_doclose {name} {\n");
sys_gui(" destroy $name\n");
sys_gui("}\n");
@@ -91,10 +111,9 @@ static void hammereditor_guidefs(void)
/* FIXME make it more reliable */
sys_gui("proc hammereditor_send {name} {\n");
sys_gui(" if {[winfo exists $name]} {\n");
- sys_gui(" set ii [$name.text index [concat end - 1 lines]]\n");
sys_gui(" pd [concat miXed$name clear \\;]\n");
sys_gui(" for {set i 1} \\\n");
- sys_gui(" {[$name.text compare $i.end < $ii]} \\\n");
+ sys_gui(" {[$name.text compare $i.end < end]} \\\n");
sys_gui(" {incr i 1} {\n");
sys_gui(" set lin [$name.text get $i.0 $i.end]\n");
sys_gui(" if {$lin != \"\"} {\n");
@@ -110,38 +129,56 @@ static void hammereditor_guidefs(void)
sys_gui("proc hammereditor_close {name ask} {\n");
sys_gui(" if {[winfo exists $name]} {\n");
- sys_gui(" set dirty $ask\n"); /* FIXME */
- sys_gui(" if {$dirty == 0} {hammereditor_doclose $name} else {\n");
+ sys_gui(" if {[catch {$name.text edit modified} dirty]} {set dirty 0}\n");
+ sys_gui(" if {$ask && $dirty} {\n");
sys_gui(" set title [wm title $name]\n");
+ sys_gui(" if {[string equal -length 1 $title \"*\"]} {\n");
+ sys_gui(" set title [string range $title 1 end]\n");
+ sys_gui(" }\n");
sys_gui(" set answer [tk_messageBox \\-type yesnocancel \\\n");
sys_gui(" \\-icon question \\\n");
sys_gui(" \\-message [concat Save changes to $title?]]\n");
sys_gui(" if {$answer == \"yes\"} {hammereditor_send $name}\n");
sys_gui(" if {$answer != \"cancel\"} {hammereditor_doclose $name}\n");
- sys_gui(" }\n");
+ sys_gui(" } else {hammereditor_doclose $name}\n");
sys_gui(" }\n");
sys_gui("}\n");
}
-void hammereditor_open(t_hammerfile *f, char *title)
+/* null owner defaults to class name, pass "" to supress */
+void hammereditor_open(t_hammerfile *f, char *title, char *owner)
{
- if (!title) title = class_getname(*f->f_master);
- sys_vgui("hammereditor_open .%x %dx%d {%s}\n", (int)f, 600, 340, title);
+ if (!owner)
+ owner = class_getname(*f->f_master);
+ if (!*owner)
+ owner = 0;
+ if (!title)
+ {
+ title = owner;
+ owner = 0;
+ }
+ if (owner)
+ sys_vgui("hammereditor_open .%x %dx%d {%s: %s} %d\n",
+ (int)f, 600, 340, owner, title, (f->f_editorfn != 0));
+ else
+ sys_vgui("hammereditor_open .%x %dx%d {%s} %d\n",
+ (int)f, 600, 340, (title ? title : "Untitled"),
+ (f->f_editorfn != 0));
}
static void hammereditor_tick(t_hammerfile *f)
{
- sys_vgui("hammereditor_close .%x %d\n", (int)f, 1);
+ sys_vgui("hammereditor_close .%x 1\n", (int)f);
}
void hammereditor_close(t_hammerfile *f, int ask)
{
- if (ask)
+ if (ask && f->f_editorfn)
/* hack: deferring modal dialog creation in order to allow for
a message box redraw to happen -- LATER investigate */
clock_delay(f->f_editorclock, 0);
else
- sys_vgui("hammereditor_close .%x %d\n", (int)f, 0);
+ sys_vgui("hammereditor_close .%x 0\n", (int)f);
}
void hammereditor_append(t_hammerfile *f, char *contents)
@@ -150,6 +187,12 @@ void hammereditor_append(t_hammerfile *f, char *contents)
sys_vgui("hammereditor_append .%x {%s}\n", (int)f, contents);
}
+void hammereditor_setdirty(t_hammerfile *f, int flag)
+{
+ if (f->f_editorfn)
+ sys_vgui("hammereditor_setdirty .%x %d\n", (int)f, flag);
+}
+
static void hammereditor_clear(t_hammerfile *f)
{
if (f->f_editorfn)
diff --git a/shared/hammer/file.h b/shared/hammer/file.h
index 13be3b8..7e68cdc 100644
--- a/shared/hammer/file.h
+++ b/shared/hammer/file.h
@@ -11,9 +11,10 @@ EXTERN_STRUCT _hammerfile;
typedef void (*t_hammerfilefn)(t_pd *, t_symbol *, int, t_atom *);
typedef void (*t_hammerembedfn)(t_pd *, t_binbuf *, t_symbol *);
-void hammereditor_open(t_hammerfile *f, char *title);
+void hammereditor_open(t_hammerfile *f, char *title, char *owner);
void hammereditor_close(t_hammerfile *f, int ask);
void hammereditor_append(t_hammerfile *f, char *contents);
+void hammereditor_setdirty(t_hammerfile *f, int flag);
void hammerpanel_open(t_hammerfile *f, t_symbol *inidir);
void hammerpanel_setopendir(t_hammerfile *f, t_symbol *dir);
t_symbol *hammerpanel_getopendir(t_hammerfile *f);
diff --git a/shared/notes.txt b/shared/notes.txt
index 44c0c11..de093b8 100644
--- a/shared/notes.txt
+++ b/shared/notes.txt
@@ -5,6 +5,14 @@ TODO for root and shared
DONE for root and shared
+with cyclone alpha53
+ * binport: added half-byte #symbol id
+ * hammereditor:
+ . fixed closing by window manager
+ . dirty flag bound, shown and observed (unless in viewer mode)
+ . title specification simplified and standardized
+ . bug fix: incomplete transfer from editor
+
with cyclone alpha52
* fragile: class name resolution based on voluntary mutation and raising
* fitter: mirroring removed