From fe6b12a98c089aaeb4b65ea6b07c1b76c6979c5f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 26 Oct 2007 04:49:50 +0000 Subject: created [add( message to append text to the existing text svn path=/trunk/externals/bbogart/; revision=8883 --- entry/entry-help.pd | 12 +++++++----- entry/entry.c | 31 ++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/entry/entry-help.pd b/entry/entry-help.pd index f528915..8642636 100644 --- a/entry/entry-help.pd +++ b/entry/entry-help.pd @@ -1,10 +1,10 @@ -#N canvas 200 48 472 591 10; +#N canvas 200 48 476 595 10; #X obj 73 212 entry 150 100 grey black; #X obj 11 84 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; #X obj 32 346 print; -#X msg 150 95 clear; -#X msg 159 117 set one two three four five six; +#X msg 100 95 clear; +#X msg 157 99 set one two three four five six; #X msg 72 50 fgcolour yellow; #X msg 50 23 bgcolour purple; #X obj 128 473 entry 100 100 grey70 purple; @@ -12,8 +12,8 @@ The width and height are in pixels.; #X obj 261 234 select return; #X obj 79 347 pddp/print; -#X obj 176 143 trigger bang bang; -#X msg 176 164 clear; +#X obj 176 163 trigger bang bang; +#X msg 176 184 clear; #X symbolatom 216 319 10 0 0 1 last_key_typed - -; #X text 266 262 ^-- hit return to output; #X msg 132 430 size 100 100; @@ -22,6 +22,7 @@ The width and height are in pixels.; #X msg 84 71 fgcolour black; #X text 13 404 The size message currently only takes affect after a save and reopen.; +#X msg 169 127 add seven eight nine; #X connect 0 0 2 0; #X connect 0 0 10 0; #X connect 0 1 9 0; @@ -39,3 +40,4 @@ save and reopen.; #X connect 16 0 7 0; #X connect 17 0 0 0; #X connect 18 0 0 0; +#X connect 20 0 0 0; diff --git a/entry/entry.c b/entry/entry.c index 1e31022..c5acc65 100644 --- a/entry/entry.c +++ b/entry/entry.c @@ -23,6 +23,7 @@ /* TODO: make "display only" option, to force box to never accept focus */ /* TODO: make focus option only accept regular and shifted chars, not Cmd, Alt, Ctrl */ /* TODO: make entry_save include whole classname, including namespace prefix */ +/* TODO: make [size( message redraw object */ /* 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 */ @@ -38,7 +39,7 @@ #define BACKGROUNDCOLOR "grey70" -#define DEBUG(x) +#define DEBUG(x) x typedef struct _entry { @@ -377,16 +378,12 @@ static void entry_vis(t_gobj *z, t_glist *glist, int vis) } } -/* Function to reset the contents of the entry box */ -static void entry_set(t_entry* x, t_symbol *s, int argc, t_atom *argv) +static void entry_add(t_entry* x, t_symbol *s, int argc, t_atom *argv) { - DEBUG(post("entry_set");); + DEBUG(post("entry_add");); int i; - t_symbol *tmp; + t_symbol *tmp = s; /* <-- this gets rid of the unused variable warning */ - tmp = s; /* <-- this gets rid of the unused variable warning */ - DEBUG(post("%s delete 0.0 end \n", x->x_widget_name);); - sys_vgui("%s delete 0.0 end \n", x->x_widget_name); for(i=0; ix_widget_name, x, x ); } +/* Function to reset the contents of the entry box */ +static void entry_set(t_entry* x, t_symbol *s, int argc, t_atom *argv) +{ + DEBUG(post("entry_set");); + int i; + + DEBUG(post("%s delete 0.0 end \n", x->x_widget_name);); + sys_vgui("%s delete 0.0 end \n", x->x_widget_name); + entry_add(x, s, argc, argv); +} + /* Clear the contents of the text widget */ static void entry_clear(t_entry* x) { @@ -585,6 +593,11 @@ void entry_setup(void) { A_GIMME, 0); + class_addmethod(entry_class, (t_method)entry_add, + gensym("add"), + A_GIMME, + 0); + class_addmethod(entry_class, (t_method)entry_clear, gensym("clear"), 0); @@ -612,7 +625,7 @@ void entry_setup(void) { up_symbol = gensym("up"); down_symbol = gensym("down"); - post("Text v0.1 Ben Bogart.\nCVS: $Revision: 1.13 $ $Date: 2007-10-25 17:07:35 $"); + post("Text v0.1 Ben Bogart.\nCVS: $Revision: 1.14 $ $Date: 2007-10-26 04:49:50 $"); } -- cgit v1.2.1