Пример #1
0
void number_tilde_oksize(t_number_tilde *x, t_rect *newrect)
{
#ifdef __APPLE__
    newrect->width = pd_clip_min(newrect->width, sys_fontwidth(x->j_box.b_font.c_size) * 3 + 8);
#elif _WINDOWS
    newrect->width = pd_clip_min(newrect->width, sys_fontwidth(x->j_box.b_font.c_size) * 3 + 8);
#else
    newrect->width = pd_clip_min(newrect->width, sys_fontwidth(x->j_box.b_font.c_size) * 3 + 11);
#endif
    newrect->height = sys_fontheight(x->j_box.b_font.c_size) + 4;
}
Пример #2
0
static void tab_oksize(t_tab *x, t_rect *newrect)
{
    if(x->f_orientation)
    {
        newrect->width = pd_clip_min(newrect->width, sys_fontwidth(x->f_font.size) * 3);
        newrect->height = pd_clip_min(newrect->height, (x->f_font.size + 4) * pd_clip_min(x->f_nitems, 1));
    }
    else
    {
        newrect->width = pd_clip_min(newrect->width, sys_fontwidth(x->f_font.size) * 3 * pd_clip_min(x->f_nitems, 1));
        newrect->height = pd_clip_min(newrect->height, x->f_font.size + 4);
    }
}
Пример #3
0
static void pddplink_getrect(t_gobj *z, t_glist *glist,
			     int *xp1, int *yp1, int *xp2, int *yp2)
{
    t_pddplink *x = (t_pddplink *)z;
    int width, height;
    float x1, y1, x2, y2;
    if (glist->gl_editor && glist->gl_editor->e_rtext)
    {
	if (x->x_rtextactive)
	{
	    t_rtext *y = glist_findrtext(glist, (t_text *)x);
	    width = rtext_width(y);
	    height = rtext_height(y) - 2;
	}
	else
	{
	    int font = glist_getfont(glist);
	    width = x->x_vislength * sys_fontwidth(font) + 2;
	    height = sys_fontheight(font) + 2;
	}
    }
    else width = height = 10;
    x1 = text_xpix((t_text *)x, glist);
    y1 = text_ypix((t_text *)x, glist);
    x2 = x1 + width;
    y2 = y1 + height;
    y1 += 1;
    *xp1 = x1;
    *yp1 = y1;
    *xp2 = x2;
    *yp2 = y2;
}
Пример #4
0
void draw_value(t_number_tilde *x, t_object *view, t_rect *rect)
{
	t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("value_layer"), rect->width, rect->height);
	t_etext *jtl = etext_layout_create();

	if (g && jtl)
	{
        int size, inc = 0;
        float peak;
        char number[256];
        sprintf(number, "%i", (int)x->f_peak_value);
        size = strlen(number);
        // TRONQUER LE NOMBRE ENTIER
        if(size > x->f_max_decimal+1)
        {
            sprintf(number, "%i...", (int)(x->f_peak_value / powf(10, size - (x->f_max_decimal+1))));
        }
        // TRONQUER LES DECIMALS
        else
        {
            // ENLEVER LES ZERO
            peak = x->f_peak_value;
            while(peak - (int)peak != 0)
            {
                peak *= 10;
                inc++;
            }
            // TRONQUER SELON LE NOMBRE MAXIMUM DE DECIMAL
            if(inc > x->f_max_decimal - size)
                inc = x->f_max_decimal - size;
            if(inc > x->f_ndecimal)
                inc = x->f_ndecimal;

            if(inc == 0)
                sprintf(number, "%i", (int)x->f_peak_value);
            else if(inc == 1)
                sprintf(number, "%.1f", x->f_peak_value);
            else if(inc == 2)
                sprintf(number, "%.2f", x->f_peak_value);
            else if(inc == 3)
                sprintf(number, "%.3f", x->f_peak_value);
            else if(inc == 4)
                sprintf(number, "%.4f", x->f_peak_value);
            else if(inc == 5)
                sprintf(number, "%.5f", x->f_peak_value);
            else
                sprintf(number, "%.6f", x->f_peak_value);
        }
        etext_layout_settextcolor(jtl, &x->f_color_text);

        etext_layout_set(jtl, number, &x->j_box.b_font, sys_fontwidth(x->j_box.b_font.c_size) + 8, rect->height / 2., rect->width - 3, 0, ETEXT_LEFT, ETEXT_JLEFT, ETEXT_NOWRAP);

        etext_layout_draw(jtl, g);
		ebox_end_layer((t_ebox*)x, gensym("value_layer"));
	}
	ebox_paint_layer((t_ebox *)x, gensym("value_layer"), 0., 0.);
    etext_layout_destroy(jtl);
}
Пример #5
0
void magicGlass_updateText(t_magicGlass *x, int moved)
{
	//fprintf(stderr,"magicglass_updateText\n");
    int bgSize;
	x->x_display_font = sys_hostfontsize(glist_getfont(x->x_c));

    if (x->x_visible)
    {
		if (!moved) {
			char *color;
			if (x->x_issignal || strcmp(x->x_old_string, x->x_string)) {
				color = "#ffffff";
			}
			else {
				color = "#e87216";
				clock_delay(x->x_flashClock, MG_CLOCK_FLASH_DELAY);
			}
		    sys_vgui(".x%x.c itemconfigure magicGlassText -text {%s} -fill %s -font {{%s} -%d %s}\n",
		            x->x_c,
		            x->x_string,
					color,
					sys_font, x->x_display_font, sys_fontweight);
		} else {
		    sys_vgui(".x%x.c itemconfigure magicGlassText -text {%s}\n",
		            x->x_c,
		            x->x_string);
		}

        if (strlen(x->x_string) > 0)
        {
			if (strlen(x->x_string) > x->x_maxSize) x->x_maxSize = strlen(x->x_string);
        }
		bgSize = x->x_x + (sys_fontwidth(x->x_display_font) * x->x_maxSize) + 26;
		//fprintf(stderr,"%d %d %d : %d %d\n", sys_fontheight(x->x_display_font), sys_fontwidth(x->x_display_font), x->x_maxSize, x->x_x, bgSize);
        sys_vgui(".x%x.c coords magicGlassText %d %d\n",
                 x->x_c,
                 x->x_x + 20,
                 x->x_y);
        sys_vgui(".x%x.c coords magicGlassLine %d %d %d %d %d %d\n",
                 x->x_c,
                 x->x_x + 8,
                 x->x_y,
                 x->x_x + 13,
                 x->x_y + 5,
                 x->x_x + 13,
                 x->x_y - 5);
        sys_vgui(".x%x.c coords magicGlassBg %d %d %d %d\n",
                 x->x_c,
                 x->x_x + 13,
                 x->x_y - (int)(sys_fontheight(x->x_display_font)/2) - 3,
                 bgSize,
                 x->x_y + (int)(sys_fontheight(x->x_display_font)/2) + 3);
    }
}
Пример #6
0
void number_tilde_paint(t_number_tilde *x, t_object *view)
{
	t_rect rect;
#ifdef __APPLE__
    float fontwidth = sys_fontwidth(x->j_box.b_font.c_size);
#elif _WINDOWS
    float fontwidth = sys_fontwidth(x->j_box.b_font.c_size);
#else
    float fontwidth = sys_fontwidth(x->j_box.b_font.c_size) + 3;
#endif

    ebox_get_rect_for_view((t_ebox *)x, &rect);
#ifdef __APPLE__
    x->f_max_decimal = (rect.width - fontwidth - 8) / fontwidth - 2;
#elif _WINDOWS
    x->f_max_decimal = (rect.width - fontwidth - 8) / fontwidth - 2;
#else
    x->f_max_decimal = (rect.width - fontwidth - 11) / fontwidth + 1;
#endif

    draw_background(x, view, &rect);
    draw_value(x, view, &rect);
}
Пример #7
0
void draw_background(t_number_tilde *x, t_object *view, t_rect *rect)
{
	t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect->width, rect->height);
	t_etext *jtl = etext_layout_create();

	if (g && jtl)
	{
        etext_layout_set(jtl, "~", &x->j_box.b_font, 1, rect->height / 2., rect->width, 0, ETEXT_LEFT, ETEXT_JLEFT, ETEXT_NOWRAP);
        etext_layout_settextcolor(jtl, &x->f_color_text);
        etext_layout_draw(jtl, g);

        egraphics_set_line_width(g, 2);
        egraphics_set_color_rgba(g, &x->f_color_border);
        egraphics_move_to(g, 0, 0);
        egraphics_line_to(g, sys_fontwidth(x->j_box.b_font.c_size) + 6,  rect->height / 2.);
        egraphics_line_to(g, 0, rect->height);
        egraphics_stroke(g);

		ebox_end_layer((t_ebox*)x, cream_sym_background_layer);
	}
	ebox_paint_layer((t_ebox *)x, cream_sym_background_layer, 0., 0.);
    etext_layout_destroy(jtl);
}
Пример #8
0
static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
    int *indexp)
{
    //fprintf(stderr,"rtext_senditup <%s>\n", x->x_buf);
    if (x)
    {
        t_float dispx, dispy;
        char smallbuf[200], *tempbuf;
        int outchars_b = 0, nlines = 0, ncolumns = 0,
            pixwide, pixhigh, font, fontwidth, fontheight, findx, findy;
        int reportedindex = 0;
        t_canvas *canvas = glist_getcanvas(x->x_glist);
        int widthspec_c = x->x_text->te_width; // width if any specified
        // width limit in chars
        int widthlimit_c = (widthspec_c ? widthspec_c : BOXWIDTH);
        //fprintf(stderr,"senditup widthlimit_c %d %d\n",
        //    widthspec_c, widthlimit_c);
        int inindex_b = 0; // index location in the buffer
        int inindex_c = 0; // index location in the u8 chars
        int selstart_b = 0, selend_b = 0; // selection start and end
        // buffer size in u8 chars
        int x_bufsize_c = u8_charnum(x->x_buf, x->x_bufsize);
            /* if we're a GOP (the new, "goprect" style) borrow the font size
            from the inside to preserve the spacing */
        if (pd_class(&x->x_text->te_pd) == canvas_class &&
            ((t_glist *)(x->x_text))->gl_isgraph &&
            ((t_glist *)(x->x_text))->gl_goprect)
                font =  glist_getfont((t_glist *)(x->x_text));
        else font = glist_getfont(x->x_glist);
        fontwidth = sys_fontwidth(font);
        fontheight = sys_fontheight(font);
        // calculating x and y in pixels
        findx = (*widthp + (fontwidth/2)) / fontwidth;
        findy = *heightp / fontheight;
        if (x->x_bufsize >= 100)
             tempbuf = (char *)t_getbytes(2 * x->x_bufsize + 1);
        else tempbuf = smallbuf;
        while (x_bufsize_c - inindex_c > 0)
        {
            int inchars_b  = x->x_bufsize - inindex_b;
            int inchars_c  = x_bufsize_c  - inindex_c;
            int maxindex_c =
                (inchars_c > widthlimit_c ? widthlimit_c : inchars_c);
            int maxindex_b = u8_offset(x->x_buf + inindex_b, maxindex_c);
            int eatchar = 1;
            int foundit_b  = firstone(x->x_buf + inindex_b, '\n', maxindex_b);
            int foundit_c;
            //following deals with \v replacement for \n in multiline comments
            int foundit_bv  = firstone(x->x_buf + inindex_b, '\v', maxindex_b);
            //fprintf(stderr,"%d %d <%s>\n", foundit_b, foundit_bv, x->x_buf);
            if ((foundit_bv < foundit_b && foundit_bv != -1) ||
                (foundit_b == -1 && foundit_bv != -1))
                foundit_b = foundit_bv;
            if (foundit_b < 0) //if we did not find an \n
            { 
                /* too much text to fit in one line? */
                if (inchars_c > widthlimit_c)
                {
                    /* is there a space to break the line at?  OK if it's even
                    one byte past the end since in this context we know there's
                    more text */
                    foundit_b =
                        lastone(x->x_buf + inindex_b, ' ', maxindex_b + 1);
                    if (foundit_b < 0)
                    {
                        foundit_b = maxindex_b;
                        foundit_c = maxindex_c;
                        eatchar = 0;
                    }
                    else
                        foundit_c = u8_charnum(x->x_buf + inindex_b, foundit_b);
                }
                else
                {
                    foundit_b = inchars_b;
                    foundit_c = inchars_c;
                    eatchar = 0;
                }
            }
            else
                foundit_c = u8_charnum(x->x_buf + inindex_b, foundit_b);

            if (nlines == findy)
            {
                int actualx = (findx < 0 ? 0 :
                    (findx > foundit_c ? foundit_c : findx));
                *indexp = inindex_b + u8_offset(x->x_buf + inindex_b, actualx);
                reportedindex = 1;
            }
            //fprintf(stderr,"eatchar %d <%s>\n", eatchar, tempbuf);
            strncpy(tempbuf+outchars_b, x->x_buf + inindex_b, foundit_b);
            if (x->x_selstart >= inindex_b &&
                x->x_selstart <= inindex_b + foundit_b + eatchar)
                    selstart_b = x->x_selstart + outchars_b - inindex_b;
            if (x->x_selend >= inindex_b &&
                x->x_selend <= inindex_b + foundit_b + eatchar)
                    selend_b = x->x_selend + outchars_b - inindex_b;
            outchars_b += foundit_b;
            inindex_b += (foundit_b + eatchar);
            inindex_c += (foundit_c + eatchar);
            if (inindex_b < x->x_bufsize)
                tempbuf[outchars_b++] = '\n';
            // if we found a row that is longer than previous (total width)
            if (foundit_c > ncolumns)
                ncolumns = foundit_c;
            nlines++;
        }
        // append new line in case we end our input with an \n
        if (x->x_buf[x_bufsize_c - 1] == '\n')
        {
            nlines++;
        }
        if (!reportedindex)
            *indexp = outchars_b;
        dispx = text_xpix(x->x_text, x->x_glist);
        dispy = text_ypix(x->x_text, x->x_glist);
        if (nlines < 1) nlines = 1;
        if (!widthspec_c)
        {
            while (ncolumns < (x->x_text->te_type == T_TEXT ? 1 : 3))
            {
                tempbuf[outchars_b++] = ' ';
                ncolumns++;
            }
        }
        else ncolumns = widthspec_c;
        pixwide = ncolumns * fontwidth + (LMARGIN + RMARGIN);
        pixhigh = nlines * fontheight + (TMARGIN + BMARGIN);

        if (action && x->x_text->te_width && x->x_text->te_type != T_ATOM)
        {
                /* if our width is specified but the "natural" width is the
                same as the specified width, set specified width to zero
                so future text editing will automatically change width.
                Except atoms whose content changes at runtime. */
            int widthwas = x->x_text->te_width, newwidth = 0, newheight = 0,
                newindex = 0;
            x->x_text->te_width = 0;
            rtext_senditup(x, 0, &newwidth, &newheight, &newindex);
            if (newwidth/fontwidth != widthwas)
                x->x_text->te_width = widthwas;
            else x->x_text->te_width = 0;
            //fprintf(stderr,"senditup width %d %d %d\n",
            //    newwidth/fontwidth, widthwas, x->x_text->te_width);
        }
        if (action == SEND_FIRST)
        {
            //fprintf(stderr,"canvas=.x%lx %s\n", (t_int)canvas, tempbuf);
            sys_vgui("pdtk_text_new .x%lx.c {%s %s text} %f %f {%.*s} %d %s\n",
                canvas, x->x_tag, rtext_gettype(x)->s_name,
                dispx + LMARGIN, dispy + TMARGIN,
                outchars_b, tempbuf, sys_hostfontsize(font),
                (glist_isselected(x->x_glist,
                    &x->x_glist->gl_gobj)? "$pd_colors(selection)" :
                        "$pd_colors(text)"));
        }
        else if (action == SEND_UPDATE)
        {
            /*fprintf(stderr,
                "SEND_UPDATE canvas_class=%d isgraph=%d goprect=%d\n",
                (pd_class(&x->x_text->te_pd) == canvas_class ? 1 : 0),
                ((t_glist *)(x->x_text))->gl_isgraph,
                ((t_glist *)(x->x_text))->gl_goprect );*/

            sys_vgui("pdtk_text_set .x%lx.c %s {%.*s}\n",
                canvas, x->x_tag, outchars_b, tempbuf);

            /*if ( pd_class(&x->x_text->te_pd) == canvas_class &&
                ((t_glist *)(x->x_text))->gl_isgraph &&
                (((t_glist *)(x->x_text))->gl_goprect) )
            {
                fprintf(stderr, "do not update outlets\n");
            }
            else */

            if (pixwide != x->x_drawnwidth || pixhigh != x->x_drawnheight) 
                text_drawborder(x->x_text, x->x_glist, x->x_tag,
                    pixwide, pixhigh, 0);
            if (x->x_active)
            {
                if (selend_b > selstart_b)
                {
                    sys_vgui(".x%lx.c select from %s %d\n", canvas, 
                        x->x_tag, u8_charnum(tempbuf, selstart_b));
                    sys_vgui(".x%lx.c select to %s %d\n", canvas, 
                        x->x_tag, u8_charnum(tempbuf, selend_b)
                          + (sys_oldtclversion ? 0 : -1));
                    sys_vgui(".x%lx.c focus \"\"\n", canvas);        
                }
                else
                {
                    sys_vgui(".x%lx.c select clear\n", canvas);
                    sys_vgui(".x%lx.c icursor %s %d\n", canvas, x->x_tag,
                        u8_charnum(tempbuf, selstart_b));
                    sys_vgui(".x%lx.c focus %s\n", canvas, x->x_tag);        
                }
            }
        }
        x->x_drawnwidth = pixwide;
        x->x_drawnheight = pixhigh;
        
        *widthp = pixwide;
        *heightp = pixhigh;
        if (tempbuf != smallbuf)
            t_freebytes(tempbuf, 2 * x->x_bufsize + 1);
    }
}
Пример #9
0
static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
    int *indexp)
{
    //fprintf(stderr,"rtext_senditup <%s>\n", x->x_buf);
    if (x)
    {
        t_float dispx, dispy;
        char smallbuf[200] = { '\0' }, *tempbuf;
        int outchars_b = 0, nlines = 0, ncolumns = 0,
            pixwide, pixhigh, font, fontwidth, fontheight, findx, findy;
        int reportedindex = 0;
        t_canvas *canvas = glist_getcanvas(x->x_glist);
        int widthspec_c = x->x_text->te_width; // width if any specified
        // width limit in chars
        int widthlimit_c = (widthspec_c ? widthspec_c : BOXWIDTH);
        int inindex_b = 0; // index location in the buffer
        int inindex_c = 0; // index location in the u8 chars
        int selstart_b = 0, selend_b = 0; // selection start and end
        // buffer size in u8 chars
        //fprintf(stderr,"buf = <%s> | last 2 chars = %d %d\n", x->x_buf, x->x_buf[x->x_bufsize-1], x->x_buf[x->x_bufsize]);
        int x_bufsize_c = u8_charnum(x->x_buf, x->x_bufsize);
            /* if we're a GOP (the new, "goprect" style) borrow the font size
            from the inside to preserve the spacing */
        if (pd_class(&x->x_text->te_pd) == canvas_class &&
            ((t_glist *)(x->x_text))->gl_isgraph &&
            ((t_glist *)(x->x_text))->gl_goprect)
                font =  glist_getfont((t_glist *)(x->x_text));
        else font = glist_getfont(x->x_glist);
        fontwidth = sys_fontwidth(font);
        fontheight = sys_fontheight(font);
        // calculating x and y in pixels
        findx = (*widthp + (fontwidth/2)) / fontwidth;
        findy = *heightp / fontheight;
        if (x->x_bufsize >= 100)
             tempbuf = (char *)t_getbytes(2 * x->x_bufsize + 1);
        else tempbuf = smallbuf;
        while (x_bufsize_c - inindex_c > 0)
        {
            int inchars_b  = x->x_bufsize - inindex_b;
            int inchars_c  = x_bufsize_c  - inindex_c;
            int maxindex_c =
                (inchars_c > widthlimit_c ? widthlimit_c : inchars_c);
            int maxindex_b = u8_offset(x->x_buf + inindex_b, maxindex_c);
            int eatchar = 1;
            //fprintf(stderr, "firstone <%s> inindex_b=%d maxindex_b=%d\n", x->x_buf + inindex_b, inindex_b, maxindex_b);
            int foundit_b  = firstone(x->x_buf + inindex_b, '\n', maxindex_b);
            int foundit_c;
            //following deals with \v replacement for \n in multiline comments
            int foundit_bv  = firstone(x->x_buf + inindex_b, '\v', maxindex_b);
            if ((foundit_bv < foundit_b && foundit_bv != -1) ||
                (foundit_b == -1 && foundit_bv != -1))
                foundit_b = foundit_bv;
            if (foundit_b < 0) //if we did not find an \n
            { 
                /* too much text to fit in one line? */
                if (inchars_c > widthlimit_c)
                {
                    /* is there a space to break the line at?  OK if it's even
                    one byte past the end since in this context we know there's
                    more text */
                    foundit_b =
                        lastone(x->x_buf + inindex_b, ' ', maxindex_b + 1);
                    if (foundit_b < 0)
                    {
                        foundit_b = maxindex_b;
                        foundit_c = maxindex_c;
                        eatchar = 0;
                    }
                    else
                        foundit_c = u8_charnum(x->x_buf + inindex_b, foundit_b);
                }
                else
                {
                    foundit_b = inchars_b;
                    foundit_c = inchars_c;
                    eatchar = 0;
                }
            }
            else
                foundit_c = u8_charnum(x->x_buf + inindex_b, foundit_b);

            if (nlines == findy)
            {
                int actualx = (findx < 0 ? 0 :
                    (findx > foundit_c ? foundit_c : findx));
                *indexp = inindex_b + u8_offset(x->x_buf + inindex_b, actualx);
                reportedindex = 1;
            }
            strncpy(tempbuf+outchars_b, x->x_buf + inindex_b, foundit_b);
            if (x->x_selstart >= inindex_b &&
                x->x_selstart <= inindex_b + foundit_b + eatchar)
                    selstart_b = x->x_selstart + outchars_b - inindex_b;
            if (x->x_selend >= inindex_b &&
                x->x_selend <= inindex_b + foundit_b + eatchar)
                    selend_b = x->x_selend + outchars_b - inindex_b;
            outchars_b += foundit_b;
            inindex_b += (foundit_b + eatchar);
            inindex_c += (foundit_c + eatchar);
            if (inindex_b < x->x_bufsize)
                tempbuf[outchars_b++] = '\n';
            // if we found a row that is longer than previous (total width)
            if (foundit_c > ncolumns)
                ncolumns = foundit_c;
            nlines++;
        }
        // append new line in case we end our input with an \n
        if (x_bufsize_c > 0 && (x->x_buf[x_bufsize_c - 1] == '\n' || x->x_buf[x_bufsize_c - 1] == '\v'))
        {
            nlines++;
            tempbuf[outchars_b++] = '\n';
            //tempbuf[outchars_b] = '\0';
            //outchars_b++;
        }
        if (!reportedindex)
            *indexp = outchars_b;
        dispx = text_xpix(x->x_text, x->x_glist);
        dispy = text_ypix(x->x_text, x->x_glist);
        if (nlines < 1) nlines = 1;
        if (!widthspec_c)
        {
            while (ncolumns < (x->x_text->te_type == T_TEXT ? 1 : 3))
            {
                tempbuf[outchars_b++] = ' ';
                ncolumns++;
            }
        }
        else ncolumns = widthspec_c;

        // add a null character at the end of the string --for u8_charnum
        // _and_ for the new gui_vmess calls which don't use the %.*s syntax.
        // Because of the way binbuf_gettext works, we should always have
        // a space before this null character. But I'm not 100% sure this
        // space is guaranteed to be there, so we'll just filter it out on
        // the GUI side for now.
        tempbuf[outchars_b++] = '\0';

        pixwide = ncolumns * fontwidth + (LMARGIN + RMARGIN);
        pixhigh = nlines * fontheight + (TMARGIN + BMARGIN);
        //printf("outchars_b=%d bufsize=%d %d\n", outchars_b, x->x_bufsize, x->x_buf[outchars_b]);

        if (action && x->x_text->te_width && x->x_text->te_type != T_ATOM)
        {
            /* if our width is specified but the "natural" width is the
               same as the specified width, set specified width to zero
               so future text editing will automatically change width.
               Except atoms whose content changes at runtime. */
            int widthwas = x->x_text->te_width, newwidth = 0, newheight = 0,
                newindex = 0;
            x->x_text->te_width = 0;
            rtext_senditup(x, 0, &newwidth, &newheight, &newindex);
            if (newwidth/fontwidth != widthwas)
                x->x_text->te_width = widthwas;
            else x->x_text->te_width = 0;
        }
        if (action == SEND_FIRST)
        {
            //fprintf(stderr,"send_first rtext=%lx t_text=%lx\n", x, x->x_text);
            gui_vmess("gui_text_new", "xssiiisi",
                canvas, x->x_tag, rtext_gettype(x)->s_name,
                glist_isselected(x->x_glist, ((t_gobj*)x->x_text)),
                LMARGIN,
                fontheight,
                tempbuf,
                sys_hostfontsize(font));
               
        }
        else if (action == SEND_UPDATE)
        {
            gui_vmess("gui_text_set", "xss", canvas, x->x_tag, tempbuf);

            // We add the check for T_MESSAGE below so that the box border
            // gets resized correctly using our interim event handling in
            // pd_canvas.html.  I could remove the conditional, but
            // this part of Pd is convoluted enough that I'm not sure
            // if there'd be any side effects.
            if (glist_isvisible(x->x_glist) && (pixwide != x->x_drawnwidth ||
                pixhigh != x->x_drawnheight ||
                x->x_text->te_type == T_MESSAGE)) 
                text_drawborder(x->x_text, x->x_glist, x->x_tag,
                    pixwide, pixhigh, 0);
            if (x->x_active)
            {
                if (selend_b > selstart_b)
                {
                    //sys_vgui(".x%lx.c select from %s %d\n", canvas, 
                    //    x->x_tag, u8_charnum(tempbuf, selstart_b));
                    //sys_vgui(".x%lx.c select to %s %d\n", canvas, 
                    //    x->x_tag, u8_charnum(tempbuf, selend_b)
                    //      + (sys_oldtclversion ? 0 : -1));
                    //sys_vgui(".x%lx.c focus \"\"\n", canvas);        
                }
                else
                {
                    //sys_vgui(".x%lx.c select clear\n", canvas);
                    //sys_vgui(".x%lx.c icursor %s %d\n", canvas, x->x_tag,
                    //    u8_charnum(tempbuf, selstart_b));
                    //sys_vgui(".x%lx.c focus %s\n", canvas, x->x_tag);        
                }
            }
        }
        x->x_drawnwidth = pixwide;
        x->x_drawnheight = pixhigh;
        
        *widthp = pixwide;
        *heightp = pixhigh;
        if (tempbuf != smallbuf)
            t_freebytes(tempbuf, 2 * x->x_bufsize + 1);
    }
    //printf("END\n");
}