diff options
Diffstat (limited to 'library/text.tcl')
-rw-r--r-- | library/text.tcl | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/library/text.tcl b/library/text.tcl index 6ef185c..a780bda 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -3,7 +3,7 @@ # This file defines the default bindings for Tk text widgets and provides # procedures that help in implementing the bindings. # -# RCS: @(#) $Id: text.tcl,v 1.5 1998/10/10 00:30:36 rjohnson Exp $ +# RCS: @(#) $Id: text.tcl,v 1.6 1999/04/16 01:51:27 stanton Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. @@ -202,7 +202,7 @@ bind Text <Return> { tkTextInsert %W \n } bind Text <Delete> { - if {[%W tag nextrange sel 1.0 end] != ""} { + if {[string compare [%W tag nextrange sel 1.0 end] ""]} { %W delete sel.first sel.last } else { %W delete insert @@ -210,7 +210,7 @@ bind Text <Delete> { } } bind Text <BackSpace> { - if {[%W tag nextrange sel 1.0 end] != ""} { + if {[string compare [%W tag nextrange sel 1.0 end] ""]} { %W delete sel.first sel.last } elseif {[%W compare insert != 1.0]} { %W delete insert-1c @@ -272,7 +272,7 @@ bind Text <Meta-KeyPress> {# nothing} bind Text <Control-KeyPress> {# nothing} bind Text <Escape> {# nothing} bind Text <KP_Enter> {# nothing} -if {$tcl_platform(platform) == "macintosh"} { +if {![string compare $tcl_platform(platform) "macintosh"]} { bind Text <Command-KeyPress> {# nothing} } @@ -334,7 +334,7 @@ bind Text <Control-t> { } } -if {$tcl_platform(platform) != "windows"} { +if {[string compare $tcl_platform(platform) "windows"]} { bind Text <Control-v> { if {!$tk_strictMotif} { tkTextScrollPages %W 1 @@ -381,7 +381,7 @@ bind Text <Meta-Delete> { # Macintosh only bindings: # if text black & highlight black -> text white, other text the same -if {$tcl_platform(platform) == "macintosh"} { +if {![string compare $tcl_platform(platform) "macintosh"]} { bind Text <FocusIn> { %W tag configure sel -borderwidth 0 %W configure -selectbackground systemHighlight -selectforeground systemHighlightText @@ -453,7 +453,7 @@ set tkPriv(prevPos) {} # on other platforms. bind Text <MouseWheel> { - %W yview scroll [expr - (%D / 120) * 4] units + %W yview scroll [expr {- (%D / 120) * 4}] units } # tkTextClosestGap -- @@ -496,7 +496,7 @@ proc tkTextButton1 {w x y} { set tkPriv(pressX) $x $w mark set insert [tkTextClosestGap $w $x $y] $w mark set anchor insert - if {[$w cget -state] == "normal"} {focus $w} + if {![string compare [$w cget -state] "normal"]} {focus $w} } # tkTextSelectTo -- @@ -551,8 +551,9 @@ proc tkTextSelectTo {w x y} { } } } - if {$tkPriv(mouseMoved) || ($tkPriv(selectMode) != "char")} { - if {$tcl_platform(platform) != "unix" && [$w compare $cur < anchor]} { + if {$tkPriv(mouseMoved) || [string compare $tkPriv(selectMode) "char"]} { + if {[string compare $tcl_platform(platform) "unix"] + && [$w compare $cur < anchor]} { $w mark set insert $first } else { $w mark set insert $last @@ -604,7 +605,7 @@ proc tkTextKeyExtend {w index} { proc tkTextPaste {w x y} { $w mark set insert [tkTextClosestGap $w $x $y] catch {$w insert insert [selection get -displayof $w]} - if {[$w cget -state] == "normal"} {focus $w} + if {![string compare [$w cget -state] "normal"]} {focus $w} } # tkTextAutoScan -- @@ -670,7 +671,7 @@ proc tkTextSetCursor {w pos} { proc tkTextKeySelect {w new} { global tkPriv - if {[$w tag nextrange sel 1.0 end] == ""} { + if {![string compare [$w tag nextrange sel 1.0 end] ""]} { if {[$w compare $new < insert]} { $w tag add sel $new insert } else { @@ -711,7 +712,7 @@ proc tkTextKeySelect {w new} { proc tkTextResetAnchor {w index} { global tkPriv - if {[$w tag ranges sel] == ""} { + if {![string compare [$w tag ranges sel] ""]} { $w mark set anchor $index return } @@ -758,7 +759,8 @@ proc tkTextResetAnchor {w index} { # s - The string to insert (usually just a single character) proc tkTextInsert {w s} { - if {($s == "") || ([$w cget -state] == "disabled")} { + if {![string compare $s ""] || + ![string compare [$w cget -state] "disabled"]} { return } catch { @@ -812,13 +814,14 @@ proc tkTextUpDownLine {w n} { proc tkTextPrevPara {w pos} { set pos [$w index "$pos linestart"] while 1 { - if {(([$w get "$pos - 1 line"] == "\n") && ([$w get $pos] != "\n")) - || ($pos == "1.0")} { + if {(![string compare [$w get "$pos - 1 line"] "\n"] + && [string compare [$w get $pos] "\n"]) + || ![string compare $pos "1.0"]} { if {[regexp -indices {^[ ]+(.)} [$w get $pos "$pos lineend"] \ dummy index]} { set pos [$w index "$pos + [lindex $index 0] chars"] } - if {[$w compare $pos != insert] || ($pos == "1.0")} { + if {[$w compare $pos != insert] || ![string compare $pos 1.0]} { return $pos } } @@ -837,13 +840,13 @@ proc tkTextPrevPara {w pos} { proc tkTextNextPara {w start} { set pos [$w index "$start linestart + 1 line"] - while {[$w get $pos] != "\n"} { + while {[string compare [$w get $pos] "\n"]} { if {[$w compare $pos == end]} { return [$w index "end - 1c"] } set pos [$w index "$pos + 1 line"] } - while {[$w get $pos] == "\n"} { + while {![string compare [$w get $pos] "\n"]} { set pos [$w index "$pos + 1 line"] if {[$w compare $pos == end]} { return [$w index "end - 1c"] @@ -871,7 +874,7 @@ proc tkTextNextPara {w start} { proc tkTextScrollPages {w count} { set bbox [$w bbox insert] $w yview scroll $count pages - if {$bbox == ""} { + if {![string compare $bbox ""]} { return [$w index @[expr {[winfo height $w]/2}],0] } return [$w index @[lindex $bbox 0],[lindex $bbox 1]] @@ -941,7 +944,7 @@ proc tk_textCut w { proc tk_textPaste w { global tcl_platform catch { - if {"$tcl_platform(platform)" != "unix"} { + if {[string compare $tcl_platform(platform) "unix"]} { catch { $w delete sel.first sel.last } @@ -960,7 +963,7 @@ proc tk_textPaste w { # w - The text window in which the cursor is to move. # start - Position at which to start search. -if {$tcl_platform(platform) == "windows"} { +if {![string compare $tcl_platform(platform) "windows"]} { proc tkTextNextWord {w start} { tkTextNextPos $w [tkTextNextPos $w $start tcl_endOfWord] \ tcl_startOfNextWord |