diff options
Diffstat (limited to 'library/text.tcl')
-rw-r--r-- | library/text.tcl | 138 |
1 files changed, 53 insertions, 85 deletions
diff --git a/library/text.tcl b/library/text.tcl index 0e43e61..279e2d9 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -86,52 +86,52 @@ bind Text <ButtonRelease-1> { bind Text <Control-1> { %W mark set insert @%x,%y } -bind Text <Left> { +bind Text <<PrevChar>> { tk::TextSetCursor %W insert-1displayindices } -bind Text <Right> { +bind Text <<NextChar>> { tk::TextSetCursor %W insert+1displayindices } -bind Text <Up> { +bind Text <<PrevLine>> { tk::TextSetCursor %W [tk::TextUpDownLine %W -1] } -bind Text <Down> { +bind Text <<NextLine>> { tk::TextSetCursor %W [tk::TextUpDownLine %W 1] } -bind Text <Shift-Left> { +bind Text <<SelectPrevChar>> { tk::TextKeySelect %W [%W index {insert - 1displayindices}] } -bind Text <Shift-Right> { +bind Text <<SelectNextChar>> { tk::TextKeySelect %W [%W index {insert + 1displayindices}] } -bind Text <Shift-Up> { +bind Text <<SelectPrevLine>> { tk::TextKeySelect %W [tk::TextUpDownLine %W -1] } -bind Text <Shift-Down> { +bind Text <<SelectNextLine>> { tk::TextKeySelect %W [tk::TextUpDownLine %W 1] } -bind Text <Control-Left> { +bind Text <<PrevWord>> { tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] } -bind Text <Control-Right> { +bind Text <<NextWord>> { tk::TextSetCursor %W [tk::TextNextWord %W insert] } -bind Text <Control-Up> { +bind Text <<PrevPara>> { tk::TextSetCursor %W [tk::TextPrevPara %W insert] } -bind Text <Control-Down> { +bind Text <<NextPara>> { tk::TextSetCursor %W [tk::TextNextPara %W insert] } -bind Text <Shift-Control-Left> { +bind Text <<SelectPrevWord>> { tk::TextKeySelect %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] } -bind Text <Shift-Control-Right> { +bind Text <<SelectNextWord>> { tk::TextKeySelect %W [tk::TextNextWord %W insert] } -bind Text <Shift-Control-Up> { +bind Text <<SelectPrevPara>> { tk::TextKeySelect %W [tk::TextPrevPara %W insert] } -bind Text <Shift-Control-Down> { +bind Text <<SelectNextPara>> { tk::TextKeySelect %W [tk::TextNextPara %W insert] } bind Text <Prior> { @@ -153,16 +153,16 @@ bind Text <Control-Next> { %W xview scroll 1 page } -bind Text <Home> { +bind Text <<LineStart>> { tk::TextSetCursor %W {insert display linestart} } -bind Text <Shift-Home> { +bind Text <<SelectLineStart>> { tk::TextKeySelect %W {insert display linestart} } -bind Text <End> { +bind Text <<LineEnd>> { tk::TextSetCursor %W {insert display lineend} } -bind Text <Shift-End> { +bind Text <<SelectLineEnd>> { tk::TextKeySelect %W {insert display lineend} } bind Text <Control-Home> { @@ -208,18 +208,22 @@ bind Text <Return> { bind Text <Delete> { if {[tk::TextCursorInSelection %W]} { %W delete sel.first sel.last - } elseif {[%W compare end != insert+1c]} { - %W delete insert + } else { + if {[%W compare end != insert+1c]} { + %W delete insert + } + %W see insert } - %W see insert } bind Text <BackSpace> { if {[tk::TextCursorInSelection %W]} { %W delete sel.first sel.last - } elseif {[%W compare insert != 1.0]} { - %W delete insert-1c + } else { + if {[%W compare insert != 1.0]} { + %W delete insert-1c + } + %W see insert } - %W see insert } bind Text <Control-space> { @@ -236,10 +240,10 @@ bind Text <Shift-Select> { set tk::Priv(selectMode) char tk::TextKeyExtend %W insert } -bind Text <Control-slash> { +bind Text <<SelectAll>> { %W tag add sel 1.0 end } -bind Text <Control-backslash> { +bind Text <<SelectNone>> { %W tag remove sel 1.0 end } bind Text <<Cut>> { @@ -283,31 +287,11 @@ if {[tk windowingsystem] eq "aqua"} { # Additional emacs-like bindings: -bind Text <Control-a> { - if {!$tk_strictMotif} { - tk::TextSetCursor %W {insert display linestart} - } -} -bind Text <Control-b> { - if {!$tk_strictMotif} { - tk::TextSetCursor %W insert-1displayindices - } -} bind Text <Control-d> { if {!$tk_strictMotif && [%W compare end != insert+1c]} { %W delete insert } } -bind Text <Control-e> { - if {!$tk_strictMotif} { - tk::TextSetCursor %W {insert display lineend} - } -} -bind Text <Control-f> { - if {!$tk_strictMotif} { - tk::TextSetCursor %W insert+1displayindices - } -} bind Text <Control-k> { if {!$tk_strictMotif && [%W compare end != insert+1c]} { if {[%W compare insert == {insert lineend}]} { @@ -317,22 +301,12 @@ bind Text <Control-k> { } } } -bind Text <Control-n> { - if {!$tk_strictMotif} { - tk::TextSetCursor %W [tk::TextUpDownLine %W 1] - } -} bind Text <Control-o> { if {!$tk_strictMotif} { %W insert insert \n %W mark set insert insert-1c } } -bind Text <Control-p> { - if {!$tk_strictMotif} { - tk::TextSetCursor %W [tk::TextUpDownLine %W -1] - } -} bind Text <Control-t> { if {!$tk_strictMotif} { tk::TextTranspose %W @@ -386,30 +360,6 @@ bind Text <Meta-Delete> { # Macintosh only bindings: if {[tk windowingsystem] eq "aqua"} { -bind Text <Option-Left> { - tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] -} -bind Text <Option-Right> { - tk::TextSetCursor %W [tk::TextNextWord %W insert] -} -bind Text <Option-Up> { - tk::TextSetCursor %W [tk::TextPrevPara %W insert] -} -bind Text <Option-Down> { - tk::TextSetCursor %W [tk::TextNextPara %W insert] -} -bind Text <Shift-Option-Left> { - tk::TextKeySelect %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] -} -bind Text <Shift-Option-Right> { - tk::TextKeySelect %W [tk::TextNextWord %W insert] -} -bind Text <Shift-Option-Up> { - tk::TextKeySelect %W [tk::TextPrevPara %W insert] -} -bind Text <Shift-Option-Down> { - tk::TextKeySelect %W [tk::TextNextPara %W insert] -} bind Text <Control-v> { tk::TextScrollPages %W 1 } @@ -469,6 +419,13 @@ if {[tk windowingsystem] eq "aqua"} { %W yview scroll [expr {(2-%D)/3}] pixels } } + bind Text <Shift-MouseWheel> { + if {%D >= 0} { + %W xview scroll [expr {-%D/3}] pixels + } else { + %W xview scroll [expr {(2-%D)/3}] pixels + } + } } if {"x11" eq [tk windowingsystem]} { @@ -486,6 +443,16 @@ if {"x11" eq [tk windowingsystem]} { %W yview scroll 50 pixels } } + bind Text <Shift-4> { + if {!$tk_strictMotif} { + %W xview scroll -50 pixels + } + } + bind Text <Shift-5> { + if {!$tk_strictMotif} { + %W xview scroll 50 pixels + } + } } # ::tk::TextClosestGap -- @@ -873,16 +840,17 @@ proc ::tk::TextInsert {w s} { } set compound 0 if {[TextCursorInSelection $w]} { - set compound [$w cget -autoseparators] - if {$compound} { + set oldSeparator [$w cget -autoseparators] + if {$oldSeparator} { $w configure -autoseparators 0 $w edit separator + set compound 1 } $w delete sel.first sel.last } $w insert insert $s $w see insert - if {$compound} { + if {$compound && $oldSeparator} { $w edit separator $w configure -autoseparators 1 } |