diff options
-rw-r--r-- | generic/tkConfig.c | 2 | ||||
-rw-r--r-- | generic/tkMenu.c | 4 | ||||
-rw-r--r-- | library/entry.tcl | 26 | ||||
-rw-r--r-- | library/spinbox.tcl | 8 | ||||
-rw-r--r-- | library/tearoff.tcl | 6 | ||||
-rw-r--r-- | library/text.tcl | 4 | ||||
-rw-r--r-- | library/ttk/entry.tcl | 10 | ||||
-rw-r--r-- | macosx/tkMacOSXDefault.h | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXNotify.c | 2 | ||||
-rw-r--r-- | unix/tkUnixDefault.h | 4 | ||||
-rw-r--r-- | win/tkWinDefault.h | 4 |
11 files changed, 41 insertions, 31 deletions
diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 1583903..a4cb367 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -1910,7 +1910,7 @@ GetObjectForOption( case TK_OPTION_INDEX: if (*((int *) internalPtr) == INT_MIN) { #if TCL_MAJOR_VERSION > 8 || defined(TK_NO_DEPRECATED) - objPtr = Tcl_NewStringObj("none", -1); + objPtr = Tcl_NewObj(); #else objPtr = Tcl_NewWideIntObj(-1); #endif diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 5ee9ede..91eb87d 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -161,7 +161,7 @@ static const Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = { TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0, (ClientData) menuStateStrings, 0}, {TK_OPTION_INDEX, "-underline", NULL, NULL, - DEF_MENU_ENTRY_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuEntry, underline), 0, NULL, 0}, + DEF_MENU_ENTRY_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuEntry, underline), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0} }; @@ -844,7 +844,7 @@ MenuWidgetObjCmd( goto error; } if (index == TCL_INDEX_NONE) { - Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1)); + Tcl_SetObjResult(interp, Tcl_NewObj()); } else { Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); } diff --git a/library/entry.tcl b/library/entry.tcl index 02384da..14c4eb9 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -119,13 +119,17 @@ bind Entry <Control-Button-1> { } bind Entry <<PrevChar>> { - tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + if {[%W index insert] != 0} { + tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + } } bind Entry <<NextChar>> { tk::EntrySetCursor %W [expr {[%W index insert] + 1}] } bind Entry <<SelectPrevChar>> { - tk::EntryKeySelect %W [expr {[%W index insert] - 1}] + if {[%W index insert] != 0} { + tk::EntryKeySelect %W [expr {[%W index insert] - 1}] + } tk::EntrySeeInsert %W } bind Entry <<SelectNextChar>> { @@ -518,9 +522,9 @@ proc ::tk::EntryBackspace w { if {[$w selection present]} { $w delete sel.first sel.last } else { - set x [expr {[$w index insert] - 1}] - if {$x >= 0} { - $w delete $x + set x [$w index insert] + if {$x > 0} { + $w delete [expr {$x - 1}] } if {[$w index @0] >= [$w index insert]} { set range [$w xview] @@ -575,10 +579,10 @@ proc ::tk::EntryTranspose w { if {$i < [$w index end]} { incr i } - set first [expr {$i-2}] - if {$first < 0} { + if {$first < 2} { return } + set first [expr {$i-2}] set data [$w get] set new [string index $data [expr {$i-1}]][string index $data $first] $w delete $first $i @@ -599,10 +603,10 @@ proc ::tk::EntryTranspose w { if {[tk windowingsystem] eq "win32"} { proc ::tk::EntryNextWord {w start} { set pos [tcl_endOfWord [$w get] [$w index $start]] - if {$pos >= 0} { + if {![string is none $pos]} { set pos [tcl_startOfNextWord [$w get] $pos] } - if {$pos < 0} { + if {[string is none $pos]} { return end } return $pos @@ -610,7 +614,7 @@ if {[tk windowingsystem] eq "win32"} { } else { proc ::tk::EntryNextWord {w start} { set pos [tcl_endOfWord [$w get] [$w index $start]] - if {$pos < 0} { + if {[string is none $pos]} { return end } return $pos @@ -628,7 +632,7 @@ if {[tk windowingsystem] eq "win32"} { proc ::tk::EntryPreviousWord {w start} { set pos [tcl_startOfPreviousWord [$w get] [$w index $start]] - if {$pos < 0} { + if {[string is none $pos]} { return 0 } return $pos diff --git a/library/spinbox.tcl b/library/spinbox.tcl index 909405e..3f101e3 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -129,13 +129,17 @@ bind Spinbox <<NextLine>> { } bind Spinbox <<PrevChar>> { - ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + if {[%W index insert] != 0} { + ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + } } bind Spinbox <<NextChar>> { ::tk::EntrySetCursor %W [expr {[%W index insert] + 1}] } bind Spinbox <<SelectPrevChar>> { - ::tk::EntryKeySelect %W [expr {[%W index insert] - 1}] + if {[%W index insert] != 0} { + ::tk::EntryKeySelect %W [expr {[%W index insert] - 1}] + } ::tk::EntrySeeInsert %W } bind Spinbox <<SelectNextChar>> { diff --git a/library/tearoff.tcl b/library/tearoff.tcl index c2d2d6b..79e9783 100644 --- a/library/tearoff.tcl +++ b/library/tearoff.tcl @@ -135,7 +135,7 @@ proc ::tk::MenuDup {src dst type} { } eval $cmd set last [$src index last] - if {$last eq "none"} { + if {[string is none $last]} { return } for {set i [$src cget -tearoff]} {$i <= $last} {incr i} { @@ -153,7 +153,7 @@ proc ::tk::MenuDup {src dst type} { # Copy tags to x, replacing each substring of src with dst. - while {[set index [string first $src $tags]] != -1} { + while {![string is none [set index [string first $src $tags]]]} { if {$index > 0} { append x [string range $tags 0 [expr {$index - 1}]]$dst } @@ -170,7 +170,7 @@ proc ::tk::MenuDup {src dst type} { # Copy script to x, replacing each substring of event with dst. - while {[set index [string first $event $script]] != -1} { + while {![string is none [set index [string first $event $script]]]} { if {$index > 0} { append x [string range $script 0 [expr {$index - 1}]] } diff --git a/library/text.tcl b/library/text.tcl index 28c6c20..8fff2c4 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -1176,7 +1176,7 @@ proc ::tk::TextNextPos {w start op} { while {[$w compare $cur < end]} { set text $text[$w get -displaychars $cur "$cur lineend + 1c"] set pos [$op $text 0] - if {$pos >= 0} { + if {![string is none $pos]} { return [$w index "$start + $pos display chars"] } set cur [$w index "$cur lineend +1c"] @@ -1199,7 +1199,7 @@ proc ::tk::TextPrevPos {w start op} { while {[$w compare $cur > 0.0]} { set text [$w get -displaychars "$cur linestart - 1c" $cur]$text set pos [$op $text end] - if {$pos >= 0} { + if {![string is none $pos]} { return [$w index "$cur linestart - 1c + $pos display chars"] } set cur [$w index "$cur linestart - 1c"] diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl index 4cdb5ac..a2fa746 100644 --- a/library/ttk/entry.tcl +++ b/library/ttk/entry.tcl @@ -228,7 +228,9 @@ proc ttk::entry::Cut {w} { proc ttk::entry::ClosestGap {w x} { set pos [$w index @$x] set bbox [$w bbox $pos] - if {$x - [lindex $bbox 0] > [lindex $bbox 2]/2} { + if {[string is none $pos]} { + set pos 0 + } elif {$x - [lindex $bbox 0] > [lindex $bbox 2]/2} { incr pos } return $pos @@ -239,7 +241,7 @@ proc ttk::entry::ClosestGap {w x} { proc ttk::entry::See {w {index insert}} { set c [$w index $index] # @@@ OR: check [$w index left] / [$w index right] - if {$c < [$w index @0] || $c >= [$w index @[winfo width $w]]} { + if {[string is none $c] || $c < [$w index @0] || $c >= [$w index @[winfo width $w]]} { $w xview $c } } @@ -258,7 +260,7 @@ proc ttk::entry::NextWord {w start} { if {$pos >= 0 && $State(startNext)} { set pos [tcl_startOfNextWord [$w get] $pos] } - if {$pos < 0} { + if {[string is none $pos]} { return end } return $pos @@ -268,7 +270,7 @@ proc ttk::entry::NextWord {w start} { # proc ttk::entry::PrevWord {w start} { set pos [tcl_startOfPreviousWord [$w get] [$w index $start]] - if {$pos < 0} { + if {[string is none $pos]} { return 0 } return $pos diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index 4dcb7d3..80ea1ee 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -309,7 +309,7 @@ #define DEF_MENU_ENTRY_CHECK_VARIABLE NULL #define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton" #define DEF_MENU_ENTRY_SELECT NULL -#define DEF_MENU_ENTRY_UNDERLINE "-1" +#define DEF_MENU_ENTRY_UNDERLINE DEF_BUTTON_UNDERLINE /* * Defaults for menus overall: diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 82ded8a..1e63279 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -13,10 +13,10 @@ * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ +#include <tclInt.h> #include "tkMacOSXPrivate.h" #include "tkMacOSXInt.h" #include "tkMacOSXConstants.h" -#include <tclInt.h> #import <objc/objc-auto.h> /* This is not used for anything at the moment. */ diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index 982f192..8678d47 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -89,7 +89,7 @@ #if TCL_MAJOR_VERSION < 9 && !defined(TK_NO_DEPRECATED) # define DEF_BUTTON_UNDERLINE "-1" #else -# define DEF_BUTTON_UNDERLINE "none" +# define DEF_BUTTON_UNDERLINE NULL #endif #define DEF_BUTTON_VALUE "" #define DEF_BUTTON_WIDTH "0" @@ -270,7 +270,7 @@ #define DEF_MENU_ENTRY_CHECK_VARIABLE NULL #define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton" #define DEF_MENU_ENTRY_SELECT NULL -#define DEF_MENU_ENTRY_UNDERLINE "-1" +#define DEF_MENU_ENTRY_UNDERLINE DEF_BUTTON_UNDERLINE /* * Defaults for menus overall: diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index e2193fd..1631b3e 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -94,7 +94,7 @@ #if TCL_MAJOR_VERSION < 9 && !defined(TK_NO_DEPRECATED) # define DEF_BUTTON_UNDERLINE "-1" #else -# define DEF_BUTTON_UNDERLINE "none" +# define DEF_BUTTON_UNDERLINE NULL #endif #define DEF_BUTTON_VALUE "" #define DEF_BUTTON_WIDTH "0" @@ -274,7 +274,7 @@ #define DEF_MENU_ENTRY_CHECK_VARIABLE NULL #define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton" #define DEF_MENU_ENTRY_SELECT NULL -#define DEF_MENU_ENTRY_UNDERLINE "-1" +#define DEF_MENU_ENTRY_UNDERLINE DEF_BUTTON_UNDERLINE /* * Defaults for menus overall: |