tk_textCopy window
Copy the selected text in text widget window to the clipboard.
This function is documented with text.
This command is called in response to the receipt of a <<Copy>> event.
The actual proc is defined as:
proc ::tk_textCopy w { if {![catch {set data [$w get sel.first sel.last]}]} { clipboard clear -displayof $w clipboard append -displayof $w $data } }
which doesn't take into account the possibility of having multiple ranges with the sel tag. Here's a more complete version:
proc ::tk_textCopy {w} { set list [list] if { [catch {$w tag ranges sel} ranges] } { return } foreach {first last} $ranges { lappend list [$w get $first $last] } clipboard clear -displayof $w clipboard append -displayof $w [join $list \n] }
See also: