aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-27 06:05:48 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-27 06:05:48 +0000
commit135a99417a1a8a100630bd349bd245df3fc5220d (patch)
tree3328696a69a38d34dfee704e2ebf4a4257fe604c
parent8442ea537dd898f0328ecd03ef396571a1a68d56 (diff)
- created text_binbuf to store the text when the text widget doesn't exist so
that loadbanging [set( messages can work. The same logic needs to be applied to the options messages too... svn path=/trunk/externals/tkwidgets/; revision=9052
-rw-r--r--text-help.pd6
-rw-r--r--text-test.pd68
-rw-r--r--text.c22
3 files changed, 42 insertions, 54 deletions
diff --git a/text-help.pd b/text-help.pd
index c26f022..b8d2221 100644
--- a/text-help.pd
+++ b/text-help.pd
@@ -1,9 +1,9 @@
-#N canvas 343 45 785 704 10;
+#N canvas 245 42 785 704 10;
#X obj 52 -43 text 130 60 0;
#X obj 53 -193 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 12 65 print;
-#X msg 89 -178 clear;
+#X msg 78 -197 clear;
#X msg 107 -157 set one two three four five six;
#X obj 36 142 text 130 60 0;
#X obj 231 3 select return;
@@ -172,6 +172,7 @@ of the character:;
#X connect 12 0 0 0;
#X connect 14 0 0 0;
#X restore 199 -200 pd adding with the key message;
+#X obj 107 -177 loadbang;
#X connect 0 0 2 0;
#X connect 0 0 7 0;
#X connect 0 1 6 0;
@@ -244,3 +245,4 @@ of the character:;
#X connect 91 0 88 0;
#X connect 92 0 88 0;
#X connect 93 0 88 0;
+#X connect 95 0 4 0;
diff --git a/text-test.pd b/text-test.pd
index 38ad04f..56148ea 100644
--- a/text-test.pd
+++ b/text-test.pd
@@ -1,51 +1,21 @@
-#N canvas 137 196 721 672 10;
-#X obj 256 77 text 400 200 1;
-#X msg 47 29 size 100 100;
-#X obj 48 470 text 130 60 0;
-#X msg 130 30 size 400 200;
-#X obj 310 11 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
-1;
-#X msg 655 333;
-#X msg 23 245 highlightthickness \$1;
-#X obj 26 219 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
--1 -1 0 1;
-#X msg 49 290 padx \$1;
-#X obj 52 269 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
--1 -1 0 1;
-#X msg 110 405 font "Lucida Sans" 18 bold;
-#X msg 124 429 font Arial 16;
-#X obj 200 542 print QUERY;
-#X floatatom 309 550 5 0 0 0 - - -;
-#X obj 309 526 route highlightthickness font;
-#X obj 396 554 pddp/print;
-#X obj 309 572 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
--1 -1;
-#X msg 68 321 query highlightthickness;
-#X msg 78 345 query;
-#X msg 309 31 scrollbars \$1;
-#X msg 85 367 query size;
-#X msg 342 369;
-#X obj 310 335 prepend set;
-#X msg 250 41 bang;
-#X connect 0 0 22 0;
-#X connect 0 1 5 0;
+#N canvas 88 197 538 519 10;
+#X obj 165 127 text 227 97 1;
+#X msg 174 40 bang;
+#X msg 289 83 key \$1;
+#X msg 273 48 123;
+#X msg 305 48 124;
+#X msg 335 48 125;
+#X msg 242 49 10;
+#X msg 368 47 92;
+#X obj 177 367 text 200 60 0;
+#X obj 190 283 loadbang;
+#X msg 182 319 set blah blah blah;
#X connect 1 0 0 0;
-#X connect 2 1 14 0;
-#X connect 2 1 12 0;
-#X connect 3 0 0 0;
-#X connect 4 0 19 0;
+#X connect 2 0 0 0;
+#X connect 3 0 2 0;
+#X connect 4 0 2 0;
+#X connect 5 0 2 0;
#X connect 6 0 2 0;
-#X connect 7 0 6 0;
-#X connect 8 0 2 0;
-#X connect 9 0 8 0;
-#X connect 10 0 2 0;
-#X connect 11 0 2 0;
-#X connect 13 0 16 0;
-#X connect 14 0 13 0;
-#X connect 14 1 15 0;
-#X connect 17 0 2 0;
-#X connect 18 0 2 0;
-#X connect 19 0 0 0;
-#X connect 20 0 2 0;
-#X connect 22 0 21 0;
-#X connect 23 0 0 0;
+#X connect 7 0 2 0;
+#X connect 9 0 10 0;
+#X connect 10 0 8 0;
diff --git a/text.c b/text.c
index 9c89be7..c30f4ce 100644
--- a/text.c
+++ b/text.c
@@ -23,7 +23,7 @@
#include <string.h>
#include "shared/tkwidgets.h"
-/* TODO: set message doesnt work with a loadbang */
+/* TODO: append options messages to options_binbuf if not visible */
/* TODO: window name "handle1376fc00" already exists in parent */
/* TODO: figure out window vs. text width/height */
/* TODO: add x scrollbar */
@@ -48,6 +48,7 @@ typedef struct _textwidget
t_canvas* x_canvas; /* canvas this widget is currently drawn in */
t_glist* x_glist; /* glist that owns this widget */
t_binbuf* options_binbuf;/* binbuf to save options state in */
+ t_binbuf* text_binbuf; /* store text on copy/paste and [loadbang] set*/
int width;
int height;
@@ -206,6 +207,8 @@ static void create_widget(t_textwidget *x)
static void drawme(t_textwidget *x, t_glist *glist)
{
+ char *buf;
+ int bufsize;
DEBUG(post("drawme: firsttime %d canvas %lx glist %lx", x->x_canvas, glist););
set_tkwidgets_ids(x,glist_getcanvas(glist));
create_widget(x);
@@ -221,6 +224,10 @@ static void drawme(t_textwidget *x, t_glist *glist)
x->frame_id->s_name, x->window_tag->s_name, x->all_tag->s_name,
x->width, x->height);
tkwidgets_restore_options(x->widget_id, x->options_binbuf);
+ binbuf_gettext(x->text_binbuf, &buf, &bufsize);
+ buf[bufsize] = 0; // binbuf_gettext() doesn't terminate the string
+ post("%s insert end {%s}\n", x->widget_id->s_name, buf);
+ sys_vgui("%s insert end {%s}\n", x->widget_id->s_name, buf);
}
static void eraseme(t_textwidget* x)
@@ -468,8 +475,16 @@ static void textwidget_set(t_textwidget* x, t_symbol *s, int argc, t_atom *argv
{
DEBUG(post("textwidget_set"););
- textwidget_clear(x);
- textwidget_append(x, s, argc, argv);
+ if(glist_isvisible(x->x_glist))
+ {
+ textwidget_clear(x);
+ textwidget_append(x, s, argc, argv);
+ }
+ else
+ {
+ binbuf_clear(x->text_binbuf);
+ binbuf_add(x->text_binbuf, argc, argv);
+ }
}
static void textwidget_options(t_textwidget *x)
@@ -668,6 +683,7 @@ static void *textwidget_new(t_symbol *s, int argc, t_atom *argv)
t_textwidget *x = (t_textwidget *)pd_new(textwidget_class);
x->options_binbuf = binbuf_new();
+ x->text_binbuf = binbuf_new();
x->x_selected = 0;
x->x_resizing = 0;