Update of /cvsroot/pure-data/externals/bbogart/entry In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26063
Modified Files: entry.c Log Message: almost there, I can get data out the second outlet, but it's global, the bind is to all Text widgets
Index: entry.c =================================================================== RCS file: /cvsroot/pure-data/externals/bbogart/entry/entry.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** entry.c 24 Oct 2007 05:22:45 -0000 1.8 --- entry.c 25 Oct 2007 04:45:15 -0000 1.9 *************** *** 25,28 **** --- 25,30 ---- /* TODO: make entry_save include whole classname, including namespace prefix */ /* TODO: set message doesnt work with a loadbang */ + /* TODO: add [append( message to add contents after existing contents, just + * base it on the set method, without the preceeding delete */
#ifdef _MSC_VER *************** *** 75,78 **** --- 77,91 ---- static t_class *entry_class;
+ + static t_symbol *backspace_symbol; + static t_symbol *return_symbol; + static t_symbol *space_symbol; + static t_symbol *tab_symbol; + static t_symbol *escape_symbol; + static t_symbol *left_symbol; + static t_symbol *right_symbol; + static t_symbol *up_symbol; + static t_symbol *down_symbol; + /* widget helper functions */
*************** *** 191,196 **** x->x_widget_name, x->x_widget_name); } - post("namespace eval %s {} \n", x->x_receive_name->s_name); - sys_vgui("namespace eval %s {} \n", x->x_receive_name->s_name); }
--- 204,207 ---- *************** *** 394,399 **** { /* With "," and ";" escaping thanks to JMZ */ ! post("pd [concat entry%lx output [string map {"," "\\," ";" "\\;"} [%s get 0.0 end]] \;]\n", x, x->x_widget_name); ! sys_vgui("pd [concat entry%lx output [string map {"," "\\," ";" "\\;"} [%s get 0.0 end]] \;]\n", x, x->x_widget_name);
/* Without "," and ";" escaping, left here but commented out in case we want to add a kind of "pd terminal" mode in the future. --- 405,412 ---- { /* With "," and ";" escaping thanks to JMZ */ ! post("pd [concat %s output [string map {"," "\\," ";" "\\;"} [%s get 0.0 end]] \;]\n", ! x->x_receive_name->s_name, x->x_widget_name); ! sys_vgui("pd [concat %s output [string map {"," "\\," ";" "\\;"} [%s get 0.0 end]] \;]\n", ! x->x_receive_name->s_name, x->x_widget_name);
/* Without "," and ";" escaping, left here but commented out in case we want to add a kind of "pd terminal" mode in the future. *************** *** 408,415 **** } } ! ! static void entry_keyup(t_entry *x, t_symbol *s) { ! outlet_symbol(x->x_status_outlet, s); }
--- 421,471 ---- } } ! ! static void entry_keyup(t_entry *x, t_float f) { ! int keycode = (int) f; ! char buf[10]; ! t_symbol *output_symbol; ! if( (f > 32 ) && (f < 65288) ) ! { ! snprintf(buf, 2, "%c", keycode); ! post("keyup: %c", keycode); ! output_symbol = gensym(buf); ! } else ! switch(keycode) ! { ! case 32: /* space */ ! output_symbol = space_symbol; ! break; ! case 65293: /* return */ ! output_symbol = return_symbol; ! break; ! case 65288: /* backspace */ ! output_symbol = backspace_symbol; ! break; ! case 65289: /* tab */ ! output_symbol = tab_symbol; ! break; ! case 65307: /* escape */ ! output_symbol = escape_symbol; ! break; ! case 65361: /* left */ ! output_symbol = left_symbol; ! break; ! case 65363: /* right */ ! output_symbol = right_symbol; ! break; ! case 65362: /* up */ ! output_symbol = up_symbol; ! break; ! case 65364: /* down */ ! output_symbol = down_symbol; ! break; ! default: ! snprintf(buf, 10, "key_%d", keycode); ! post("keyup: %d", keycode); ! output_symbol = gensym(buf); ! } ! outlet_symbol(x->x_status_outlet, output_symbol); }
*************** *** 493,503 **** x->x_height = x->x_char_height*5; */
/* Bind the recieve "entry%lx" to the widget instance*/ ! snprintf(buf,MAXPDSTRING,"entry%lx",(long unsigned int)x); x->x_receive_name = gensym(buf); pd_bind(&x->x_obj.ob_pd, x->x_receive_name); ! x->x_data_outlet = outlet_new(&x->x_obj, &s_float); ! x->x_status_outlet = outlet_new(&x->x_obj, &s_symbol); return (x); } --- 549,568 ---- x->x_height = x->x_char_height*5; */
+ x->x_data_outlet = outlet_new(&x->x_obj, &s_float); + x->x_status_outlet = outlet_new(&x->x_obj, &s_symbol); + /* Bind the recieve "entry%lx" to the widget instance*/ ! snprintf(buf,MAXPDSTRING,"#entry%lx",(long unsigned int)x); x->x_receive_name = gensym(buf); pd_bind(&x->x_obj.ob_pd, x->x_receive_name); + + post("bind Text <KeyRelease> {pd [concat %s keyup %%K \;]} \n", + x->x_canvas_name,x->x_receive_name->s_name); + /* sys_vgui("bind Text <KeyRelease> {pd [concat test keyup %%A \;]} \n", */ + /* x->x_canvas_name,x->x_receive_name->s_name); */ + sys_vgui("bind Text <KeyRelease> {pd %s keyup %%N \;} \n", x->x_receive_name->s_name); ! post("namespace eval entry%lx {} \n", x); ! sys_vgui("namespace eval entry%lx {} \n", x); return (x); } *************** *** 511,515 **** class_addmethod(entry_class, (t_method)entry_keyup, gensym("keyup"), ! A_DEFSYMBOL, 0);
--- 576,580 ---- class_addmethod(entry_class, (t_method)entry_keyup, gensym("keyup"), ! A_DEFFLOAT, 0);
*************** *** 548,551 **** --- 613,626 ---- #endif
+ backspace_symbol = gensym("Backspace"); + return_symbol = gensym("Return"); + space_symbol = gensym("Space"); + tab_symbol = gensym("Tab"); + escape_symbol = gensym("Escape"); + left_symbol = gensym("Left"); + right_symbol = gensym("Right"); + up_symbol = gensym("Up"); + down_symbol = gensym("Down"); + post("Text v0.1 Ben Bogart.\nCVS: $Revision$ $Date$"); }