aboutsummaryrefslogtreecommitdiff
path: root/entry
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-10-28 05:20:34 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-10-28 05:20:34 +0000
commit53af02ff5a2a73132ee4f2e0863ed00f61d8518f (patch)
tree11f41e8b811e9487c042d1d96cdf712b891fbb64 /entry
parentcd3f05f55ea955aedde21c9a0840b183ddcdc3c6 (diff)
made [option( message for passing Tcl/Tk options directly to the text widget; fixed minor bug in the output caused by adding the scrollbar
svn path=/trunk/externals/bbogart/; revision=8897
Diffstat (limited to 'entry')
-rw-r--r--entry/entry-help.pd146
-rw-r--r--entry/entry.c55
2 files changed, 177 insertions, 24 deletions
diff --git a/entry/entry-help.pd b/entry/entry-help.pd
index 1ec02bd..66b0059 100644
--- a/entry/entry-help.pd
+++ b/entry/entry-help.pd
@@ -1,4 +1,4 @@
-#N canvas 200 48 484 603 10;
+#N canvas 172 88 736 664 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;
@@ -7,27 +7,93 @@
#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;
+#X obj 142 462 entry 100 50 grey70 purple;
#X text 8 365 Creation arguments are: width height bgcolor fgcolor.
The width and height are in pixels.;
-#X obj 261 234 select return;
+#X obj 251 254 select return;
#X obj 79 347 pddp/print;
#X obj 176 173 trigger bang bang;
#X msg 176 194 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;
+#X text 255 275 ^-- hit return to output;
#X msg 219 430 size 400 200;
#X msg 29 4 bgcolour grey;
#X msg 84 71 fgcolour black;
-#X text 13 404 The size message currently only takes affect after a
+#X text 12 394 The size message currently only takes affect after a
save and reopen.;
#X msg 169 127 add seven eight nine;
#X msg 196 149 add ten eleven.;
-#X msg 26 469 fontsize \$1;
-#X msg 48 442 12;
-#X msg 16 441 9;
-#X msg 81 439 98;
+#X msg 30 459 fontsize \$1;
+#X msg 52 432 12;
+#X msg 20 431 9;
+#X msg 85 429 98;
+#X obj 166 18 pddp/pddplink http://tcl.tk/man/tcl8.4/TkCmd/text.htm
+;
+#X obj 572 91 entry 300 50 grey70 black;
+#X msg 572 67 option relief \$1;
+#X obj 571 46 symbol;
+#X msg 469 11 flat;
+#X msg 504 11 groove;
+#X msg 551 11 raised;
+#X msg 599 10 ridge;
+#X msg 640 10 solid;
+#X msg 681 10 sunken;
+#X obj 366 524 entry 124 100 grey70 black;
+#X obj 368 468 symbol;
+#X obj 558 526 entry 124 100 grey70 black;
+#X obj 558 478 symbol;
+#X msg 541 454 on;
+#X msg 575 453 off;
+#X msg 349 443 normal;
+#X msg 395 443 disabled;
+#X msg 367 491 option state \$1;
+#X msg 558 500 option undo \$1;
+#X msg 132 430 size 100 50;
+#X text 421 470 disable editing;
+#X text 608 469 turn on undo;
+#X obj 572 217 entry 100 50 grey70 black;
+#X obj 571 172 symbol;
+#X obj 502 394 entry 100 50 grey70 black;
+#X obj 501 349 symbol;
+#X msg 572 193 option wrap \$1;
+#X msg 529 147 none;
+#X msg 564 147 char;
+#X msg 601 147 word;
+#X text 618 171 word wrapping;
+#X msg 502 370 option selectbackground \$1;
+#X msg 419 304 blue;
+#X msg 454 304 purple;
+#X msg 501 304 orange;
+#X msg 549 303 magenta;
+#X obj 425 281 pddp/pddplink http://en.wikipedia.org/wiki/X11_color_names
+;
+#X msg 603 303 DarkSlateBlue;
+#X msg 603 342 limegreen;
+#X msg 603 323 lightyellow;
+#X obj 384 218 entry 100 50 grey70 black;
+#X obj 386 167 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
+-1 -1 2000 1;
+#X obj 52 601 entry 100 50 grey70 black;
+#X obj 51 556 symbol;
+#X obj 161 636 pddp/pddplink http://tcl.tk/man/tcl8.4/TkCmd/cursors.htm
+;
+#X msg 49 521 boat;
+#X msg 84 521 bogosity;
+#X msg 52 577 option cursor \$1;
+#X msg 9 521 clock;
+#X msg 145 521 dot;
+#X msg 175 521 dotbox;
+#X msg 222 521 gumby;
+#X msg 265 521 gobbler;
+#X msg 266 590 pirate;
+#X msg 266 547 mouse;
+#X msg 266 569 target;
+#X text 174 615 for more:;
+#X msg 266 611 trek;
+#X msg 384 194 option insertwidth \$1;
+#X obj 386 48 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
+-1 -1 0 1;
+#X msg 383 68 option borderwidth \$1;
#X connect 0 0 2 0;
#X connect 0 0 10 0;
#X connect 0 1 9 0;
@@ -42,12 +108,58 @@ save and reopen.;
#X connect 11 1 0 0;
#X connect 12 0 0 0;
#X connect 15 0 7 0;
-#X connect 16 0 7 0;
+#X connect 16 0 0 0;
#X connect 17 0 0 0;
-#X connect 18 0 0 0;
+#X connect 19 0 0 0;
#X connect 20 0 0 0;
-#X connect 21 0 0 0;
-#X connect 22 0 7 0;
-#X connect 23 0 22 0;
-#X connect 24 0 22 0;
-#X connect 25 0 22 0;
+#X connect 21 0 7 0;
+#X connect 22 0 21 0;
+#X connect 23 0 21 0;
+#X connect 24 0 21 0;
+#X connect 27 0 26 0;
+#X connect 28 0 27 0;
+#X connect 29 0 28 0;
+#X connect 30 0 28 0;
+#X connect 31 0 28 0;
+#X connect 32 0 28 0;
+#X connect 33 0 28 0;
+#X connect 34 0 28 0;
+#X connect 36 0 43 0;
+#X connect 38 0 44 0;
+#X connect 39 0 38 0;
+#X connect 40 0 38 0;
+#X connect 41 0 36 0;
+#X connect 42 0 36 0;
+#X connect 43 0 35 0;
+#X connect 44 0 37 0;
+#X connect 45 0 7 0;
+#X connect 49 0 52 0;
+#X connect 51 0 57 0;
+#X connect 52 0 48 0;
+#X connect 53 0 49 0;
+#X connect 54 0 49 0;
+#X connect 55 0 49 0;
+#X connect 57 0 50 0;
+#X connect 58 0 51 0;
+#X connect 59 0 51 0;
+#X connect 60 0 51 0;
+#X connect 61 0 51 0;
+#X connect 63 0 51 0;
+#X connect 64 0 51 0;
+#X connect 65 0 51 0;
+#X connect 67 0 84 0;
+#X connect 69 0 73 0;
+#X connect 71 0 69 0;
+#X connect 72 0 69 0;
+#X connect 73 0 68 0;
+#X connect 75 0 69 0;
+#X connect 76 0 69 0;
+#X connect 77 0 69 0;
+#X connect 78 0 69 0;
+#X connect 79 0 69 0;
+#X connect 80 0 69 0;
+#X connect 81 0 69 0;
+#X connect 83 0 69 0;
+#X connect 84 0 66 0;
+#X connect 85 0 86 0;
+#X connect 86 0 26 0;
diff --git a/entry/entry.c b/entry/entry.c
index f94f6bc..d5e9bc4 100644
--- a/entry/entry.c
+++ b/entry/entry.c
@@ -27,7 +27,7 @@
/* TODO: make [size( message redraw object */
/* TODO: set message doesnt work with a loadbang */
/* TODO: make message to add a single character to the existing text */
-/* TODO: complete inlet draw/erase logic */
+/* TODO: complete inlet draw/erase logic */
#ifdef _MSC_VER
#pragma warning( disable : 4244 )
@@ -62,12 +62,9 @@ typedef struct _entry
t_int x_font_size;
t_symbol *x_font_weight;
-/* TODO: these all should be settable by messages
t_float x_border;
t_float x_highlightthickness;
t_symbol *x_relief;
-*/
- t_symbol* x_contents;
t_outlet* x_data_outlet;
t_outlet* x_status_outlet;
@@ -437,6 +434,8 @@ static void entry_add(t_entry* x, t_symbol *s, int argc, t_atom *argv)
x->x_glist, x, x, x ););
sys_vgui(".x%x.c.s%x.text insert end $::entry%lx::list ; unset ::entry%lx::list \n",
x->x_glist, x, x, x );
+ DEBUG(post(".x%x.c.s%x.text yview end-2char \n", x->x_glist, x ););
+ sys_vgui(".x%x.c.s%x.text yview end-2char \n", x->x_glist, x );
}
/* Clear the contents of the text widget */
@@ -467,9 +466,11 @@ static void entry_output(t_entry* x, t_symbol *s, int argc, t_atom *argv)
static void entry_bang_output(t_entry* x)
{
/* With "," and ";" escaping thanks to JMZ */
- DEBUG(post("pd [concat %s output [string map {\",\" \"\\\\,\" \";\" \"\\\\;\"} [.x%x.c.s%x get 0.0 end]] \\;]\n",
+ DEBUG(post("pd [concat %s output [string map {\",\" \"\\\\,\" \";\" \"\\\\;\"} \
+ [.x%x.c.s%x.text get 0.0 end]] \\;]\n",
x->x_receive_name->s_name, x->x_glist, x););
- sys_vgui("pd [concat %s output [string map {\",\" \"\\\\,\" \";\" \"\\\\;\"} [.x%x.c.s%x get 0.0 end]] \\;]\n",
+ sys_vgui("pd [concat %s output [string map {\",\" \"\\\\,\" \";\" \"\\\\;\"} \
+ [.x%x.c.s%x.text get 0.0 end]] \\;]\n",
x->x_receive_name->s_name, x->x_glist, x);
DEBUG(post("bind .x%x.c.s%x.text <Leave> {focus [winfo parent .x%x.c.s%x]} \n",
@@ -537,6 +538,41 @@ static void entry_save(t_gobj *z, t_binbuf *b)
binbuf_addv(b, ";");
}
+
+static void entry_option_float(t_entry* x, t_symbol *option, t_float value)
+{
+ DEBUG(post(".x%x.c.s%x.text configure -%s %f \n",
+ x->x_glist, x, option->s_name, value););
+ sys_vgui(".x%x.c.s%x.text configure -%s %f \n",
+ x->x_glist, x, option->s_name, value);
+}
+
+static void entry_option_symbol(t_entry* x, t_symbol *option, t_symbol *value)
+{
+ DEBUG(post(".x%x.c.s%x.text configure -%s {%s} \n",
+ x->x_glist, x, option->s_name, value->s_name););
+ sys_vgui(".x%x.c.s%x.text configure -%s {%s} \n",
+ x->x_glist, x, option->s_name, value->s_name);
+}
+
+static void entry_option(t_entry *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *tmp_symbol = s; /* <-- this gets rid of the unused variable warning */
+ t_float tmp_float;
+
+ tmp_symbol = atom_getsymbolarg(1, argc, argv);
+ if(tmp_symbol == &s_)
+ {
+ entry_option_float(x,atom_getsymbolarg(0, argc, argv),
+ atom_getfloatarg(1, argc, argv));
+ }
+ else
+ {
+ entry_option_symbol(x,atom_getsymbolarg(0, argc, argv),tmp_symbol);
+ }
+}
+
+
/* function to change colour of text background */
void entry_bgcolour(t_entry* x, t_symbol* bgcol)
{
@@ -636,6 +672,11 @@ void entry_setup(void) {
A_DEFFLOAT,
0);
+ class_addmethod(entry_class, (t_method)entry_option,
+ gensym("option"),
+ A_GIMME,
+ 0);
+
class_addmethod(entry_class, (t_method)entry_size,
gensym("size"),
A_DEFFLOAT,
@@ -689,7 +730,7 @@ void entry_setup(void) {
up_symbol = gensym("up");
down_symbol = gensym("down");
- post("Text v0.1 Ben Bogart.\nCVS: $Revision: 1.17 $ $Date: 2007-10-28 03:54:54 $");
+ post("Text v0.1 Ben Bogart.\nCVS: $Revision: 1.18 $ $Date: 2007-10-28 05:20:34 $");
}