@@ -4038,14 +4038,12 @@ def scan_dragto(self, x, y):
40384038 scan_mark."""
40394039 self .tk .call (self ._w , 'scan' , 'dragto' , x , y )
40404040
4041- def search (self , pattern , index , stopindex = None ,
4042- forwards = None , backwards = None , exact = None ,
4043- regexp = None , nocase = None , count = None ,
4044- elide = None , nolinestop = None , all = None ,
4045- overlap = None , strictlimits = None ):
4041+ def search (self , pattern , index , stopindex = None , * ,
4042+ forwards = None , backwards = None , exact = None ,
4043+ regexp = None , nocase = None , count = None ,
4044+ elide = None , nolinestop = None , strictlimits = None ):
40464045 """Search PATTERN beginning from INDEX until STOPINDEX.
4047- Return the index of the first character of a match or an
4048- empty string."""
4046+ Return the index of the first character of a match or an empty string."""
40494047 args = [self ._w , 'search' ]
40504048 if forwards : args .append ('-forwards' )
40514049 if backwards : args .append ('-backwards' )
@@ -4055,15 +4053,38 @@ def search(self, pattern, index, stopindex=None,
40554053 if elide : args .append ('-elide' )
40564054 if count : args .append ('-count' ); args .append (count )
40574055 if nolinestop : args .append ('-nolinestop' )
4058- if all : args .append ('-all' )
4059- if overlap : args .append ('-overlap' )
40604056 if strictlimits : args .append ('-strictlimits' )
40614057 if pattern and pattern [0 ] == '-' : args .append ('--' )
40624058 args .append (pattern )
40634059 args .append (index )
40644060 if stopindex : args .append (stopindex )
40654061 return str (self .tk .call (tuple (args )))
40664062
4063+ def search_all (self , pattern , index , stopindex = None , * ,
4064+ forwards = None , backwards = None , exact = None ,
4065+ regexp = None , nocase = None , count = None ,
4066+ elide = None , nolinestop = None , overlap = None ,
4067+ strictlimits = None ):
4068+ """Search all occurrences of PATTERN from INDEX to STOPINDEX.
4069+ Return a list of indices where matches begin."""
4070+ args = [self ._w , 'search' , '-all' ]
4071+ if forwards : args .append ('-forwards' )
4072+ if backwards : args .append ('-backwards' )
4073+ if exact : args .append ('-exact' )
4074+ if regexp : args .append ('-regexp' )
4075+ if nocase : args .append ('-nocase' )
4076+ if elide : args .append ('-elide' )
4077+ if count : args .append ('-count' ); args .append (count )
4078+ if nolinestop : args .append ('-nolinestop' )
4079+ if overlap : args .append ('-overlap' )
4080+ if strictlimits : args .append ('-strictlimits' )
4081+ if pattern and pattern [0 ] == '-' : args .append ('--' )
4082+ args .append (pattern )
4083+ args .append (index )
4084+ if stopindex : args .append (stopindex )
4085+ result = self .tk .call (tuple (args ))
4086+ return list (result .split ()) if result else []
4087+
40674088 def see (self , index ):
40684089 """Scroll such that the character at INDEX is visible."""
40694090 self .tk .call (self ._w , 'see' , index )
0 commit comments