Tcl-Tk-Tkwidget-Tix
view release on metacpan or search on metacpan
library/Console.tcl view on Meta::CPAN
}
foreach prev {Control-n Down} {
bind $win <$prev> {
tixConsoleHistory next
break
}
}
bind $win <Control-v> {
if {[%W compare insert > promptEnd]} {
catch {
%W insert insert [selection get -displayof %W] {input stdin}
%W see insert
}
}
break
}
bind $win <Insert> {
catch {tixConsoleInsert %W [selection get -displayof %W]}
break
}
bind $win <KeyPress> {
tixConsoleInsert %W %A
break
}
foreach left {Control-b Left} {
bind $win <$left> {
if {[%W compare insert == promptEnd]} {
break
}
tkTextSetCursor %W insert-1c
break
}
}
foreach right {Control-f Right} {
bind $win <$right> {
tkTextSetCursor %W insert+1c
break
}
}
bind $win <Control-Up> {
%W yview scroll -1 unit
break;
}
bind $win <Control-Down> {
%W yview scroll 1 unit
break;
}
bind $win <Prior> {
%W yview scroll -1 pages
}
bind $win <Next> {
%W yview scroll 1 pages
}
bind $win <F9> {
eval destroy [winfo child .]
source $tix_library/Console.tcl
}
foreach copy {F16 Meta-w Control-i} {
bind $win <$copy> {
if {[selection own -displayof %W] == "%W"} {
clipboard clear -displayof %W
catch {
clipboard append -displayof %W [selection get -displayof %W]
}
}
break
}
}
foreach paste {F18 Control-y} {
bind $win <$paste> {
catch {
set clip [selection get -displayof %W -selection CLIPBOARD]
set list [split $clip \n\r]
tixConsoleInsert %W [lindex $list 0]
foreach x [lrange $list 1 end] {
%W mark set insert {end - 1c}
tixConsoleInsert %W "\n"
tixConsoleInvoke
tixConsoleInsert %W $x
}
}
break
}
}
}
# tixConsoleInsert --
# Insert a string into a text at the point of the insertion cursor.
# If there is a selection in the text, and it covers the point of the
# insertion cursor, then delete the selection before inserting. Insertion
# is restricted to the prompt area.
#
# Arguments:
# w - The text window in which to insert the string
# s - The string to insert (usually just a single character)
proc tixConsoleInsert {w s} {
if ![winfo exists .console] tixConsoleInit
if {[.console dlineinfo insert] != {}} {
set setend 1
} else {
set setend 0
}
if {$s == ""} {
return
}
catch {
if {[$w compare sel.first <= insert]
&& [$w compare sel.last >= insert]} {
$w tag remove sel sel.first promptEnd
$w delete sel.first sel.last
}
}
if {[$w compare insert < promptEnd]} {
$w mark set insert end
}
$w insert insert $s {input stdin}
if $setend {
.console see insert
}
}
( run in 2.663 seconds using v1.01-cache-2.11-cpan-2398b32b56e )