diff options
Diffstat (limited to 'library/text.tcl')
-rw-r--r-- | library/text.tcl | 138 |
1 files changed, 85 insertions, 53 deletions
diff --git a/library/text.tcl b/library/text.tcl index 279e2d9..0e43e61 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 <<PrevChar>> { +bind Text <Left> { tk::TextSetCursor %W insert-1displayindices } -bind Text <<NextChar>> { +bind Text <Right> { tk::TextSetCursor %W insert+1displayindices } -bind Text <<PrevLine>> { +bind Text <Up> { tk::TextSetCursor %W [tk::TextUpDownLine %W -1] } -bind Text <<NextLine>> { +bind Text <Down> { tk::TextSetCursor %W [tk::TextUpDownLine %W 1] } -bind Text <<SelectPrevChar>> { +bind Text <Shift-Left> { tk::TextKeySelect %W [%W index {insert - 1displayindices}] } -bind Text <<SelectNextChar>> { +bind Text <Shift-Right> { tk::TextKeySelect %W [%W index {insert + 1displayindices}] } -bind Text <<SelectPrevLine>> { +bind Text <Shift-Up> { tk::TextKeySelect %W [tk::TextUpDownLine %W -1] } -bind Text <<SelectNextLine>> { +bind Text <Shift-Down> { tk::TextKeySelect %W [tk::TextUpDownLine %W 1] } -bind Text <<PrevWord>> { +bind Text <Control-Left> { tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] } -bind Text <<NextWord>> { +bind Text <Control-Right> { tk::TextSetCursor %W [tk::TextNextWord %W insert] } -bind Text <<PrevPara>> { +bind Text <Control-Up> { tk::TextSetCursor %W [tk::TextPrevPara %W insert] } -bind Text <<NextPara>> { +bind Text <Control-Down> { tk::TextSetCursor %W [tk::TextNextPara %W insert] } -bind Text <<SelectPrevWord>> { +bind Text <Shift-Control-Left> { tk::TextKeySelect %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] } -bind Text <<SelectNextWord>> { +bind Text <Shift-Control-Right> { tk::TextKeySelect %W [tk::TextNextWord %W insert] } -bind Text <<SelectPrevPara>> { +bind Text <Shift-Control-Up> { tk::TextKeySelect %W [tk::TextPrevPara %W insert] } -bind Text <<SelectNextPara>> { +bind Text <Shift-Control-Down> { 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 <<LineStart>> { +bind Text <Home> { tk::TextSetCursor %W {insert display linestart} } -bind Text <<SelectLineStart>> { +bind Text <Shift-Home> { tk::TextKeySelect %W {insert display linestart} } -bind Text <<LineEnd>> { +bind Text <End> { tk::TextSetCursor %W {insert display lineend} } -bind Text <<SelectLineEnd>> { +bind Text <Shift-End> { tk::TextKeySelect %W {insert display lineend} } bind Text <Control-Home> { @@ -208,22 +208,18 @@ bind Text <Return> { bind Text <Delete> { if {[tk::TextCursorInSelection %W]} { %W delete sel.first sel.last - } else { - if {[%W compare end != insert+1c]} { - %W delete insert - } - %W see insert + } elseif {[%W compare end != insert+1c]} { + %W delete insert } + %W see insert } bind Text <BackSpace> { if {[tk::TextCursorInSelection %W]} { %W delete sel.first sel.last - } else { - if {[%W compare insert != 1.0]} { - %W delete insert-1c - } - %W see insert + } elseif {[%W compare insert != 1.0]} { + %W delete insert-1c } + %W see insert } bind Text <Control-space> { @@ -240,10 +236,10 @@ bind Text <Shift-Select> { set tk::Priv(selectMode) char tk::TextKeyExtend %W insert } -bind Text <<SelectAll>> { +bind Text <Control-slash> { %W tag add sel 1.0 end } -bind Text <<SelectNone>> { +bind Text <Control-backslash> { %W tag remove sel 1.0 end } bind Text <<Cut>> { @@ -287,11 +283,31 @@ 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}]} { @@ -301,12 +317,22 @@ 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 @@ -360,6 +386,30 @@ 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 } @@ -419,13 +469,6 @@ 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]} { @@ -443,16 +486,6 @@ 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 -- @@ -840,17 +873,16 @@ proc ::tk::TextInsert {w s} { } set compound 0 if {[TextCursorInSelection $w]} { - set oldSeparator [$w cget -autoseparators] - if {$oldSeparator} { + set compound [$w cget -autoseparators] + if {$compound} { $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 && $oldSeparator} { + if {$compound} { $w edit separator $w configure -autoseparators 1 } |