diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-07-10 07:04:29 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-07-10 07:04:29 (GMT) |
commit | 8a4797c9a16ff548b9d7a02b28ac8df76bdb2ff0 (patch) | |
tree | c6598344952695d555c707c547fb77fe6c119688 /library/entry.tcl | |
parent | 3018d78340026597655745f383e8f4c2e4e9505d (diff) | |
download | tk-8a4797c9a16ff548b9d7a02b28ac8df76bdb2ff0.zip tk-8a4797c9a16ff548b9d7a02b28ac8df76bdb2ff0.tar.gz tk-8a4797c9a16ff548b9d7a02b28ac8df76bdb2ff0.tar.bz2 |
Minor bindings cleanup. Some removal of "expr" when we can do without it. Some KeyPress -> Key changes (which are synonymes). Some implicit <Button-1> specifications in stead of simply <1> (making clear this is not a binding to the "1" key).
Diffstat (limited to 'library/entry.tcl')
-rw-r--r-- | library/entry.tcl | 63 |
1 files changed, 27 insertions, 36 deletions
diff --git a/library/entry.tcl b/library/entry.tcl index da3f800..6539af7 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -58,7 +58,7 @@ bind Entry <<Paste>> { } bind Entry <<Clear>> { # ignore if there is no selection - catch { %W delete sel.first sel.last } + catch {%W delete sel.first sel.last} } bind Entry <<PasteSelection>> { if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)] @@ -74,7 +74,7 @@ bind Entry <<TraverseIn>> { # Standard Motif bindings: -bind Entry <1> { +bind Entry <Button-1> { tk::EntryButton1 %W %x %W selection clear } @@ -82,25 +82,25 @@ bind Entry <B1-Motion> { set tk::Priv(x) %x tk::EntryMouseSelect %W %x } -bind Entry <Double-1> { +bind Entry <Double-Button-1> { set tk::Priv(selectMode) word tk::EntryMouseSelect %W %x catch {%W icursor sel.last} } -bind Entry <Triple-1> { +bind Entry <Triple-Button-1> { set tk::Priv(selectMode) line tk::EntryMouseSelect %W %x catch {%W icursor sel.last} } -bind Entry <Shift-1> { +bind Entry <Shift-Button-1> { set tk::Priv(selectMode) char %W selection adjust @%x } -bind Entry <Double-Shift-1> { +bind Entry <Double-Shift-Button-1> { set tk::Priv(selectMode) word tk::EntryMouseSelect %W %x } -bind Entry <Triple-Shift-1> { +bind Entry <Triple-Shift-Button-1> { set tk::Priv(selectMode) line tk::EntryMouseSelect %W %x } @@ -114,22 +114,22 @@ bind Entry <B1-Enter> { bind Entry <ButtonRelease-1> { tk::CancelRepeat } -bind Entry <Control-1> { +bind Entry <Control-Button-1> { %W icursor @%x } bind Entry <<PrevChar>> { - tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + tk::EntrySetCursor %W [expr {[%W index insert]-1}] } bind Entry <<NextChar>> { - tk::EntrySetCursor %W [expr {[%W index insert] + 1}] + tk::EntrySetCursor %W [expr {[%W index insert]+1}] } bind Entry <<SelectPrevChar>> { - tk::EntryKeySelect %W [expr {[%W index insert] - 1}] + tk::EntryKeySelect %W [expr {[%W index insert]-1}] tk::EntrySeeInsert %W } bind Entry <<SelectNextChar>> { - tk::EntryKeySelect %W [expr {[%W index insert] + 1}] + tk::EntryKeySelect %W [expr {[%W index insert]+1}] tk::EntrySeeInsert %W } bind Entry <<PrevWord>> { @@ -190,19 +190,19 @@ bind Entry <<SelectAll>> { bind Entry <<SelectNone>> { %W selection clear } -bind Entry <KeyPress> { +bind Entry <Key> { tk::CancelRepeat tk::EntryInsert %W %A } # Ignore all Alt, Meta, and Control keypresses unless explicitly bound. # Otherwise, if a widget binding for one of these is defined, the -# <KeyPress> class binding will also fire and insert the character, +# <Key> class binding will also fire and insert the character, # which is wrong. Ditto for Escape, Return, and Tab. -bind Entry <Alt-KeyPress> {# nothing} -bind Entry <Meta-KeyPress> {# nothing} -bind Entry <Control-KeyPress> {# nothing} +bind Entry <Alt-Key> {# nothing} +bind Entry <Meta-Key> {# nothing} +bind Entry <Control-Key> {# nothing} bind Entry <Escape> {# nothing} bind Entry <Return> {# nothing} bind Entry <KP_Enter> {# nothing} @@ -210,7 +210,7 @@ bind Entry <Tab> {# nothing} bind Entry <Prior> {# nothing} bind Entry <Next> {# nothing} if {[tk windowingsystem] eq "aqua"} { - bind Entry <Command-KeyPress> {# nothing} + bind Entry <Command-Key> {# nothing} } # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] bind Entry <<NextLine>> {# nothing} @@ -278,7 +278,7 @@ bind Entry <<TkStartIMEMarkedText>> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Entry <<TkEndIMEMarkedText>> { - if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } { + if {[catch {dict get $::tk::Priv(IMETextMark) "%W"} mark]} { bell } else { %W selection range $mark insert @@ -294,7 +294,7 @@ bind Entry <<TkAccentBackspace>> { # A few additional bindings of my own. if {[tk windowingsystem] ne "aqua"} { - bind Entry <2> { + bind Entry <Button-2> { if {!$tk_strictMotif} { ::tk::EntryScanMark %W %x } @@ -305,7 +305,7 @@ if {[tk windowingsystem] ne "aqua"} { } } } else { - bind Entry <3> { + bind Entry <Button-3> { if {!$tk_strictMotif} { ::tk::EntryScanMark %W %x } @@ -391,10 +391,10 @@ proc ::tk::EntryMouseSelect {w x} { word { if {$cur < $anchor} { set before [tcl_wordBreakBefore [$w get] $cur] - set after [tcl_wordBreakAfter [$w get] [expr {$anchor-1}]] + set after [tcl_wordBreakAfter [$w get] $anchor-1] } elseif {$cur > $anchor} { set before [tcl_wordBreakBefore [$w get] $anchor] - set after [tcl_wordBreakAfter [$w get] [expr {$cur - 1}]] + set after [tcl_wordBreakAfter [$w get] $cur-1] } else { if {[$w index @$Priv(pressX)] < $anchor} { incr anchor -1 @@ -520,7 +520,7 @@ proc ::tk::EntryBackspace w { } else { set x [$w index insert] if {$x > 0} { - $w delete [expr {$x - 1}] + $w delete [expr {$x-1}] } if {[$w index @0] >= [$w index insert]} { set range [$w xview] @@ -580,7 +580,7 @@ proc ::tk::EntryTranspose w { } set first [expr {$i-2}] set data [$w get] - set new [string index $data [expr {$i-1}]][string index $data $first] + set new [string index $data $i-1][string index $data $first] $w delete $first $i $w insert insert $new EntrySeeInsert $w @@ -660,7 +660,7 @@ proc ::tk::EntryScanMark {w x} { proc ::tk::EntryScanDrag {w x} { # Make sure these exist, as some weird situations can trigger the # motion binding without the initial press. [Bug #220269] - if {![info exists ::tk::Priv(x)]} { set ::tk::Priv(x) $x } + if {![info exists ::tk::Priv(x)]} {set ::tk::Priv(x) $x} # allow for a delta if {abs($x-$::tk::Priv(x)) > 2} { set ::tk::Priv(mouseMoved) 1 @@ -677,19 +677,10 @@ proc ::tk::EntryScanDrag {w x} { proc ::tk::EntryGetSelection {w} { set entryString [string range [$w get] [$w index sel.first] \ - [expr {[$w index sel.last] - 1}]] + [$w index sel.last]-1] if {[$w cget -show] ne ""} { return [string repeat [string index [$w cget -show] 0] \ [string length $entryString]] } return $entryString } - - - - - - - - - |