tk_textPaste window
Pastes the contents of the clipboard to the insertion point in a text widget window. Deletes the current selection (except on X11).
This function is documented with text.
This command is called in response to the receipt of a <<Paste>> event.
The actual proc is defined as:
proc ::tk_textPaste w { global tcl_platform if {![catch {::tk::GetSelection $w CLIPBOARD} sel]} { set oldSeparator [$w cget -autoseparators] if { $oldSeparator } { $w configure -autoseparators 0 $w edit separator } if {[string compare [tk windowingsystem] "x11"]} { catch { $w delete sel.first sel.last } } $w insert insert $sel if { $oldSeparator } { $w edit separator $w configure -autoseparators 1 } } }
which doesn't take into account the possibility of having multiple ranges with the sel tag. Here's a more complete version:
proc ::tk_textPaste w { global tcl_platform array set range {} if { [catch {$w tag ranges sel} ranges] } { return } foreach {first last} $ranges { set range($first) $last puts "set range($first) \[$last\]" } if { [catch {::tk::GetSelection $w CLIPBOARD} sel] } { return } set oldSeparator [$w cget -autoseparators] if { $oldSeparator } { $w configure -autoseparators 0 $w edit separator } if { ![string equal [tk windowingsystem] "x11"] } { foreach first [lsort -decreasing [array names range]] { $w delete $first $range($first) } } $w insert insert $sel if { $oldSeparator } { $w edit separator $w configure -autoseparators 1 } }
See also: