$NetBSD: patch-ag,v 1.5 2004/01/20 10:18:25 agc Exp $ --- drivers/ntk.c 2004/01/20 09:40:12 1.1 +++ drivers/ntk.c 2004/01/20 09:43:23 @@ -105,18 +105,18 @@ tk_cmd(cmd); /* add new canvas to option menu */ - sprintf(cmd, "$plf.f1.mb.menu add command -label \"Page $ccanv\" -command { -set w $plf.f2.c%d; -$hs configure -command \"$w xview\"; -$vs configure -command \"$w yview\"; -set dname \"Page %d\"; -pack forget $ocanvas; -set ocanvas $plf.f2.c%d; -pack $ocanvas -fill both -expand 1; -scan [$w xview] \"%%f %%f\" i j; -$hs set $i $j; -scan [$w yview] \"%%f %%f\" i j; -$vs set $i $j;}", + sprintf(cmd, "$plf.f1.mb.menu add command -label \"Page $ccanv\" -command {\n" +"set w $plf.f2.c%d;\n" +"$hs configure -command \"$w xview\";\n" +"$vs configure -command \"$w yview\";\n" +"set dname \"Page %d\";\n" +"pack forget $ocanvas;\n" +"set ocanvas $plf.f2.c%d;\n" +"pack $ocanvas -fill both -expand 1;\n" +"scan [$w xview] \"%%f %%f\" i j;\n" +"$hs set $i $j;\n" +"scan [$w yview] \"%%f %%f\" i j;\n" +"$vs set $i $j;}", ccanv, ccanv, ccanv); tk_cmd(cmd); @@ -126,47 +126,47 @@ /* Shif-B1, zooms in */ /* FIXME inform the core lib of the zoom, see plframe.c around line 2818 */ - sprintf(cmd, "bind $plf.f2.c$ccanv { -set cc %d; -incr item($cc); set tt $item($cc); -if {$tt == 1} { -incr scroll_use; -pack $hs -side bottom -fill x; -pack $vs -side right -fill y; -pack forget %%W; pack %%W -fill both -expand 1} -set zx($cc,$tt) %%x; -set zy($cc,$tt) %%y; -%%W scale all %%x %%y 1.6 1.6; -%%W configure -scrollregion [%%W bbox all]; -}", ccanv); + sprintf(cmd, "bind $plf.f2.c$ccanv {\n" +"set cc %d;\n" +"incr item($cc); set tt $item($cc);\n" +"if {$tt == 1} {\n" +"incr scroll_use;\n" +"pack $hs -side bottom -fill x;\n" +"pack $vs -side right -fill y;\n" +"pack forget %%W; pack %%W -fill both -expand 1}\n" +"set zx($cc,$tt) %%x;\n" +"set zy($cc,$tt) %%y;\n" +"%%W scale all %%x %%y 1.6 1.6;\n" +"%%W configure -scrollregion [%%W bbox all];\n" +"}", ccanv); tk_cmd(cmd); /* Shif-B3, zooms out */ - sprintf(cmd,"bind $plf.f2.c$ccanv { -set cc %d; set tt $item($cc); -if {$tt != 0} { -%%W scale all $zx($cc,$tt) $zy($cc,$tt) 0.625 0.625 -%%W configure -scrollregion [%%W bbox all]; -set item($cc) [expr $tt - 1]} -if { $item($cc) == 0} { -set scroll_use [expr $scroll_use - 1]; -if {$scroll_use == 0} { -pack forget $plf.f2.hscroll $plf.f2.vscroll} -%%W configure -scrollregion \"0 0 $xmax $ymax\"}}", ccanv); + sprintf(cmd,"bind $plf.f2.c$ccanv {\n" +"set cc %d; set tt $item($cc);\n" +"if {$tt != 0} {\n" +"%%W scale all $zx($cc,$tt) $zy($cc,$tt) 0.625 0.625\n" +"%%W configure -scrollregion [%%W bbox all];\n" +"set item($cc) [expr $tt - 1]}\n" +"if { $item($cc) == 0} {\n" +"set scroll_use [expr $scroll_use - 1];\n" +"if {$scroll_use == 0} {\n" +"pack forget $plf.f2.hscroll $plf.f2.vscroll}\n" +"%%W configure -scrollregion \"0 0 $xmax $ymax\"}}", ccanv); tk_cmd(cmd); /* Shift-B2, resets */ - sprintf(cmd,"bind $plf.f2.c$ccanv { -set cc %d; set tt $item($cc); -while {$tt != 0} { -%%W scale all $zx($cc,$tt) $zy($cc,$tt) 0.625 0.625 -set tt [expr $tt - 1]}; -set item($cc) 0; -%%W configure -scrollregion \"0 0 $xmax $ymax\"; -set scroll_use [expr $scroll_use - 1]; -if {$scroll_use == 0} { -pack forget $plf.f2.hscroll $plf.f2.vscroll}}", ccanv); + sprintf(cmd,"bind $plf.f2.c$ccanv {\n" +"set cc %d; set tt $item($cc); \n" +"while {$tt != 0} {\n" +"%%W scale all $zx($cc,$tt) $zy($cc,$tt) 0.625 0.625\n" +"set tt [expr $tt - 1]};\n" +"set item($cc) 0;\n" +"%%W configure -scrollregion \"0 0 $xmax $ymax\";\n" +"set scroll_use [expr $scroll_use - 1];\n" +"if {$scroll_use == 0} {\n" +"pack forget $plf.f2.hscroll $plf.f2.vscroll}}", ccanv); tk_cmd(cmd); /* Control-B1-Motion, pan */ @@ -177,12 +177,12 @@ tk_cmd(cmd); /* Control-B2, identify and (in the far future) edit object */ - tk_cmd("bind $plf.f2.c$ccanv { -set xx [ expr [winfo pointerx .] - [winfo rootx %W]]; -set yy [ expr [winfo pointery .] - [winfo rooty %W]]; -set near [%W find closest $xx $yy]; -%W move $near 20 20; -after 500 \"%W move $near -20 -20\"}"); + tk_cmd("bind $plf.f2.c$ccanv {\n" +"set xx [ expr [winfo pointerx .] - [winfo rootx %W]];\n" +"set yy [ expr [winfo pointery .] - [winfo rooty %W]];\n" +"set near [%W find closest $xx $yy];\n" +"%W move $near 20 20;\n" +"after 500 \"%W move $near -20 -20\"}"); /* change view to the new canvas by invoking the menu buttom */ sprintf(cmd, "$plf.f1.mb.menu invoke %d", ccanv-1); @@ -247,27 +247,27 @@ tk_cmd("catch \"frame $plf\"; pack $plf -fill both -expand 1"); - sprintf(cmd, "frame $plf.f1; -frame $plf.f2 -width %d -height %d; -pack $plf.f1 -fill x; -pack $plf.f2 -fill both -expand 1", xmax, ymax); + sprintf(cmd, "frame $plf.f1;\n" +"frame $plf.f2 -width %d -height %d;\n" +"pack $plf.f1 -fill x;\n" +"pack $plf.f2 -fill both -expand 1", xmax, ymax); tk_cmd(cmd); - tk_cmd("scrollbar $plf.f2.hscroll -orient horiz; -scrollbar $plf.f2.vscroll"); + tk_cmd("scrollbar $plf.f2.hscroll -orient horiz;\n" +"scrollbar $plf.f2.vscroll"); - tk_cmd("menubutton $plf.f1.mb -text \"Page 1\" -textvariable dname -relief raised -indicatoron 1 -menu $plf.f1.mb.menu; -menu $plf.f1.mb.menu -tearoff 0; -pack $plf.f1.mb -side left"); + tk_cmd("menubutton $plf.f1.mb -text \"Page 1\" -textvariable dname -relief raised -indicatoron 1 -menu $plf.f1.mb.menu;\n" +"menu $plf.f1.mb.menu -tearoff 0;\n" +"pack $plf.f1.mb -side left"); if (local) - tk_cmd("button $plf.f1.quit -text Quit -command exit; -pack $plf.f1.quit -side right"); + tk_cmd("button $plf.f1.quit -text Quit -command exit;\n" +"pack $plf.f1.quit -side right"); else - tk_cmd("button $plf.f1.quit -text Quit -command {send -async $client exit; -destroy $plf; -wm withdraw .}; -pack $plf.f1.quit -side right"); + tk_cmd("button $plf.f1.quit -text Quit -command {send -async $client exit;\n" +"destroy $plf;\n" +"wm withdraw .};\n" +"pack $plf.f1.quit -side right"); /* FIXME: I just discovered that Tcl_Eval is slower than Tcl_EvalObj. Fix it global-wide, `man Tcl_Eval' */ @@ -403,11 +403,11 @@ tk_cmd("set ocursor [lindex [$plf.f2.c$ccanv configure -cursor] 4]"); } - tk_cmd("$plf.f2.c$ccanv configure -cursor cross; -bind $plf.f2.c$ccanv