Update of /cvsroot/pure-data/externals/tkwidgets
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15869
Modified Files:
text-help.pd text.c
Log Message:
- added [query id( to get the Tk id string for the widget
(i.e. .x6b1820.c.frame6b1b50.widget6b1b50) This will allow people to use
[sys_gui] to send Tcl commands to the widget in order to manipulate the
insert cursor and the tags, among other things.
- made the [key( message work with all ASCII 127 except { arg, I need to find
how on earth to escape it. Also, it would be good to support beyond ASCII
127, i.e. accents, umlauts, etc.
Index: text.c
===================================================================
RCS file: /cvsroot/pure-data/externals/tkwidgets/text.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** text.c 26 Nov 2007 23:38:41 -0000 1.18
--- text.c 27 Nov 2007 05:22:32 -0000 1.19
***************
*** 28,31 ****
--- 28,34 ----
/* TODO: figure out window vs. text width/height */
/* TODO: add x scrollbar */
+ /* TODO: make "insert" function based on the text widget "insert" */
+ /* TODO: make [key( support chars > 127 */
+
#define TEXT_DEFAULT_COLOR "grey90"
***************
*** 110,124 ****
/* common symbols to preload */
- static t_symbol *scrollbars_symbol;
- static t_symbol *size_symbol;
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;
/* -------------------- function prototypes --------------------------------- */
--- 113,129 ----
/* common symbols to preload */
static t_symbol *backspace_symbol;
! static t_symbol *down_symbol;
static t_symbol *escape_symbol;
+ static t_symbol *id_symbol;
static t_symbol *left_symbol;
+ static t_symbol *query_callback_symbol;
+ static t_symbol *return_symbol;
static t_symbol *right_symbol;
+ static t_symbol *scrollbars_symbol;
+ static t_symbol *size_symbol;
+ static t_symbol *space_symbol;
+ static t_symbol *tab_symbol;
static t_symbol *up_symbol;
/* -------------------- function prototypes --------------------------------- */
***************
*** 129,132 ****
--- 134,147 ----
/* -------------------- widget helper functions ----------------------------- */
+
+ static void query_id(t_textwidget *x)
+ {
+ t_atom id[2];
+ t_symbol *widget_id = x->widget_id;
+ SETSYMBOL(id, id_symbol);
+ SETSYMBOL(id + 1, widget_id);
+ textwidget_query_callback(x, query_callback_symbol, 2, id);
+ }
+
static void query_scrollbars(t_textwidget *x)
{
***************
*** 134,138 ****
SETSYMBOL(state, scrollbars_symbol);
SETFLOAT(state + 1, (t_float)x->have_scrollbars);
! textwidget_query_callback(x, gensym("query_callback"), 2, state);
}
--- 149,153 ----
SETSYMBOL(state, scrollbars_symbol);
SETFLOAT(state + 1, (t_float)x->have_scrollbars);
! textwidget_query_callback(x, query_callback_symbol, 2, state);
}
***************
*** 143,147 ****
SETFLOAT(coords + 1, (t_float)x->width);
SETFLOAT(coords + 2, (t_float)x->height);
! textwidget_query_callback(x, gensym("query_callback"), 3, coords);
}
--- 158,162 ----
SETFLOAT(coords + 1, (t_float)x->width);
SETFLOAT(coords + 2, (t_float)x->height);
! textwidget_query_callback(x, query_callback_symbol, 3, coords);
}
***************
*** 421,448 ****
DEBUG(post("textwidget_key"););
t_symbol *tmp_symbol = s; /* <-- this gets rid of the unused variable warning */
! t_int tmp_int;
tmp_symbol = atom_getsymbolarg(0, argc, argv);
if(tmp_symbol == &s_)
{
! tmp_int = (t_int) atom_getfloatarg(0, argc , argv);
! if(tmp_int < 10)
! {
! sys_vgui("%s insert end %d\n", x->widget_id->s_name, tmp_int);
! }
! else if(tmp_int == 10)
! {
! sys_vgui("%s insert end {\n}\n", x->widget_id->s_name);
! }
! else
! {
! sys_vgui("%s insert end [format \"%c\" %d]\n", x->widget_id->s_name, tmp_int);
! }
}
else
{
! sys_vgui("%s insert end %s\n", x->widget_id->s_name, tmp_symbol->s_name );
}
! sys_vgui("%s yview end-2char \n", x->widget_id->s_name );
}
--- 436,465 ----
DEBUG(post("textwidget_key"););
t_symbol *tmp_symbol = s; /* <-- this gets rid of the unused variable warning */
! char charbuf;
tmp_symbol = atom_getsymbolarg(0, argc, argv);
if(tmp_symbol == &s_)
+ charbuf = (t_int) atom_getfloatarg(0, argc , argv);
+ else
+ charbuf = tmp_symbol->s_name[0];
+ if(charbuf < 10)
{
! sys_vgui("%s insert end %d\n", x->widget_id->s_name, charbuf);
}
else
{
! switch(charbuf)
! {
! case '\\':
! sys_vgui("%s insert end \"\\\\\"\n", x->widget_id->s_name); break;
! case '{':
! sys_vgui("%s insert end {\\{}\n", x->widget_id->s_name); break;
! case '}':
! sys_vgui("%s insert end \"}\"\n", x->widget_id->s_name); break;
! default:
! sys_vgui("%s insert end {%c}\n", x->widget_id->s_name, charbuf);
! }
}
! sys_vgui("%s yview end-2char\n", x->widget_id->s_name );
}
***************
*** 471,477 ****
--- 488,497 ----
sizeof(textwidget_tk_options)/sizeof(char *),
textwidget_tk_options);
+ query_id(x);
query_scrollbars(x);
query_size(x);
}
+ else if(s == id_symbol)
+ query_id(x);
else if(s == scrollbars_symbol)
query_scrollbars(x);
***************
*** 731,744 ****
/* commonly used symbols */
- size_symbol = gensym("size");
- scrollbars_symbol = gensym("scrollbars");
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");
}
--- 751,766 ----
/* commonly used symbols */
backspace_symbol = gensym("backspace");
! down_symbol = gensym("down");
escape_symbol = gensym("escape");
+ id_symbol = gensym("id");
left_symbol = gensym("left");
+ query_callback_symbol = gensym("query_callback");
+ return_symbol = gensym("return");
right_symbol = gensym("right");
+ size_symbol = gensym("size");
+ scrollbars_symbol = gensym("scrollbars");
+ space_symbol = gensym("space");
+ tab_symbol = gensym("tab");
up_symbol = gensym("up");
}
Index: text-help.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/tkwidgets/text-help.pd,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** text-help.pd 24 Nov 2007 05:57:15 -0000 1.3
--- text-help.pd 27 Nov 2007 05:22:31 -0000 1.4
***************
*** 78,82 ****
#X msg 202 250 gobbler;
#X obj 404 -212 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
! -1 -1 200 1;
#X obj 470 -90 tgl 15 0 empty empty empty 0 -6 0 10 -262144 -1 -1 0
1;
--- 78,82 ----
#X msg 202 250 gobbler;
#X obj 404 -212 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
! -1 -1 0 1;
#X obj 470 -90 tgl 15 0 empty empty empty 0 -6 0 10 -262144 -1 -1 0
1;
***************
*** 100,104 ****
#X msg 582 -192 relief \$1;
#X msg 582 -58 wrap \$1;
! #X msg 328 -70 insertwidth \$1;
#X msg 557 305 undo \$1;
#X msg 652 304 state \$1;
--- 100,104 ----
#X msg 582 -192 relief \$1;
#X msg 582 -58 wrap \$1;
! #X msg 329 -70 insertwidth \$1;
#X msg 557 305 undo \$1;
#X msg 652 304 state \$1;
***************
*** 142,145 ****
--- 142,176 ----
#X msg 435 75 grey;
#X msg 471 75 black;
+ #N canvas 410 182 450 300 adding 0;
+ #X obj 90 229 text 200 60 0;
+ #X text 53 23 You can add text one character at a time using the "key"
+ message. It works either with the character itself or the ASCII value
+ of the character:;
+ #X msg 90 102 key \$1;
+ #X obj 94 77 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
+ -1 -1 0 1;
+ #X msg 126 202 key ";
+ #X msg 169 202 key a;
+ #X msg 215 202 key B;
+ #X msg 145 102 key 10;
+ #X msg 259 202 key [;
+ #X msg 145 122 key 32;
+ #X text 198 103 carriage return;
+ #X text 198 122 space;
+ #X msg 145 142 key 100;
+ #X text 198 142 letter "d";
+ #X msg 145 163 key 92;
+ #X text 199 161 backslash;
+ #X connect 2 0 0 0;
+ #X connect 3 0 2 0;
+ #X connect 4 0 0 0;
+ #X connect 5 0 0 0;
+ #X connect 6 0 0 0;
+ #X connect 7 0 0 0;
+ #X connect 8 0 0 0;
+ #X connect 9 0 0 0;
+ #X connect 12 0 0 0;
+ #X connect 14 0 0 0;
+ #X restore 199 -200 pd adding with the key message;
#X connect 0 0 2 0;
#X connect 0 0 7 0;