Update of /cvsroot/pure-data/externals/miXed/shared/hammer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1442/shared/hammer
Modified Files: file.c file.h Log Message: cyclone alpha53 (see notes.txt for cyclone, bin and shared)
Index: file.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/shared/hammer/file.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** file.c 27 Jan 2005 14:42:54 -0000 1.4 --- file.c 28 Feb 2005 13:10:40 -0000 1.5 *************** *** 59,67 **** }
- /* 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(" if {[winfo exists $name]} {\n"); sys_gui(" $name.text delete 1.0 end\n"); --- 59,65 ---- }
static void hammereditor_guidefs(void) { ! 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"); *************** *** 70,73 **** --- 68,76 ---- 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"); *************** *** 79,82 **** --- 82,102 ---- 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"); *************** *** 92,99 **** 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(" {incr i 1} {\n"); sys_gui(" set lin [$name.text get $i.0 $i.end]\n"); --- 112,118 ---- sys_gui("proc hammereditor_send {name} {\n"); sys_gui(" if {[winfo exists $name]} {\n"); sys_gui(" pd [concat miXed$name clear \;]\n"); sys_gui(" for {set i 1} \\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"); *************** *** 111,117 **** 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(" set title [wm title $name]\n"); sys_gui(" set answer [tk_messageBox \-type yesnocancel \\n"); sys_gui(" \-icon question \\n"); --- 130,139 ---- sys_gui("proc hammereditor_close {name ask} {\n"); sys_gui(" if {[winfo exists $name]} {\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"); *************** *** 119,146 **** sys_gui(" if {$answer == "yes"} {hammereditor_send $name}\n"); sys_gui(" if {$answer != "cancel"} {hammereditor_doclose $name}\n"); ! sys_gui(" }\n"); sys_gui(" }\n"); sys_gui("}\n"); }
! void hammereditor_open(t_hammerfile *f, char *title) { ! if (!title) title = class_getname(*f->f_master); ! sys_vgui("hammereditor_open .%x %dx%d {%s}\n", (int)f, 600, 340, title); }
static void hammereditor_tick(t_hammerfile *f) { ! sys_vgui("hammereditor_close .%x %d\n", (int)f, 1); }
void hammereditor_close(t_hammerfile *f, int ask) { ! if (ask) /* 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); }
--- 141,183 ---- sys_gui(" if {$answer == "yes"} {hammereditor_send $name}\n"); sys_gui(" if {$answer != "cancel"} {hammereditor_doclose $name}\n"); ! sys_gui(" } else {hammereditor_doclose $name}\n"); sys_gui(" }\n"); sys_gui("}\n"); }
! /* null owner defaults to class name, pass "" to supress */ ! void hammereditor_open(t_hammerfile *f, char *title, char *owner) { ! 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 1\n", (int)f); }
void hammereditor_close(t_hammerfile *f, int 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 0\n", (int)f); }
*************** *** 151,154 **** --- 188,197 ---- }
+ 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) {
Index: file.h =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/shared/hammer/file.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** file.h 27 Jan 2005 14:42:54 -0000 1.3 --- file.h 28 Feb 2005 13:10:40 -0000 1.4 *************** *** 12,18 **** typedef void (*t_hammerembedfn)(t_pd *, t_binbuf *, t_symbol *);
! void hammereditor_open(t_hammerfile *f, char *title); void hammereditor_close(t_hammerfile *f, int ask); void hammereditor_append(t_hammerfile *f, char *contents); void hammerpanel_open(t_hammerfile *f, t_symbol *inidir); void hammerpanel_setopendir(t_hammerfile *f, t_symbol *dir); --- 12,19 ---- typedef void (*t_hammerembedfn)(t_pd *, t_binbuf *, t_symbol *);
! 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);