=================================================================== RCS file: /home/cvs/OpenXM_contrib/gnuplot/term/Attic/tkcanvas.trm,v retrieving revision 1.1.1.2 retrieving revision 1.1.1.3 diff -u -p -r1.1.1.2 -r1.1.1.3 --- OpenXM_contrib/gnuplot/term/Attic/tkcanvas.trm 2000/01/22 14:16:30 1.1.1.2 +++ OpenXM_contrib/gnuplot/term/Attic/tkcanvas.trm 2003/09/15 07:09:39 1.1.1.3 @@ -1,5 +1,5 @@ /* - * $Id: tkcanvas.trm,v 1.1.1.2 2000/01/22 14:16:30 maekawa Exp $ + * $Id: tkcanvas.trm,v 1.1.1.3 2003/09/15 07:09:39 ohara Exp $ * */ @@ -166,23 +166,21 @@ TK_graphics() */ if (tk_perl) { fputs("\ -sub gnuplot {\n\ +sub {\n\ my($can) = @_;\n\ $can->delete('all');\n\ -my $cmx = ($can->configure(-width))[4];\n\ -my $cmy = ($can->configure(-height))[4];\n\ -my $cmx = $can->width - 2 * $can->cget(-border);\n\ +my $cmx = $can->width - 2 * $can->cget(-border) - 2 * $can->cget(-highlightthickness);\n\ if ($cmx <= 1) {\n$cmx = ($can->cget(-width));\n}\n\ -my $cmy = $can->height - 2 * $can->cget(-border);\n\ +my $cmy = $can->height - 2 * $can->cget(-border) - 2 * $can->cget(-highlightthickness);\n\ if ($cmy <= 1) {\n$cmy = ($can->cget(-height));\n}\n", gpoutfile); } else { fputs("\ proc gnuplot can {\n\ $can delete all\n\ -set cmx [expr [winfo width $can]-2*[$can cget -border]]\n\ +set cmx [expr [winfo width $can]-2*[$can cget -border]-2*[$can cget -highlightthickness]]\n\ if {$cmx <= 1} {set cmx [$can cget -width]}\n\ -set cmy [expr [winfo height $can]-2*[$can cget -border]]\n\ +set cmy [expr [winfo height $can]-2*[$can cget -border]-2*[$can cget -highlightthickness]]\n\ if {$cmy <= 1} {set cmy [$can cget -height]}\n", gpoutfile); } @@ -370,8 +368,8 @@ $can create line \ TERM_PUBLIC void TK_put_text(x, y, str) -unsigned int x, y; -char *str; + unsigned int x, y; + char *str; { y = 1000 - y; if (tk_perl) { @@ -383,13 +381,31 @@ $cmy * %d / 1000, \ (defined $font ? (-font => $font) : ()));\n", x, y, str, tk_colors[tk_color], tk_anchor); } else { + /* Have to quote-protect '[' and ']' characters */ + int i, newsize = 0; + char *quoted_str; + + for (i=0; str[i] != '\0'; i++) { + if ((str[i] == '[') || (str[i] == ']')) + newsize++; + newsize++; + } + quoted_str = gp_alloc(newsize + 1, "TK_put_text: quoted string"); + + for (i=0, newsize = 0; str[i] != '\0'; i++) { + if ((str[i] == '[') || (str[i] == ']')) + quoted_str[newsize++] = '\\'; + quoted_str[newsize++] = str[i]; + } + quoted_str[newsize] = '\0'; fprintf(gpoutfile,"\ eval $can create text \ [expr $cmx * %d /1000] \ [expr $cmy * %d /1000] \ -text \\{%s\\} -fill %s -anchor %s\ [expr [info exists font]?\"-font \\$font\":{}]\n", - x, y, str, tk_colors[tk_color], tk_anchor); + x, y, quoted_str, tk_colors[tk_color], tk_anchor); + free(quoted_str); } } @@ -608,10 +624,9 @@ START_HELP(tkcanvas) "", " use Tk;", " my $top = MainWindow->new;", -" my $c = $top->Canvas;", -" $c->pack();", -" do \"plot.pl\";", -" gnuplot->($c);", +" my $c = $top->Canvas->pack;", +" my $gnuplot = do \"plot.pl\";", +" $gnuplot->($c);", " MainLoop;", "", " The code generated by `gnuplot` creates a procedure called \"gnuplot\"",