#NEWLINE# def run( self , edit , text = None , separator = None , clipboard = False , items = None , regex = False , keep_selection = None , update_selection = None , repeat = None , strip = None , threshold = 1 , align = None , by_rows = False ) : #NEWLINE# #INDENT# if separator : #NEWLINE# #INDENT# separator = separator . encode ( 'utf8' ) . decode ( 'unicode-escape' ) #NEWLINE# #UNINDENT# if clipboard : #NEWLINE# #INDENT# text = sublime . get_clipboard ( ) #NEWLINE# #UNINDENT# if text : #NEWLINE# #INDENT# if regex : #NEWLINE# #INDENT# items = re . split ( separator , text ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# items = text . split ( separator ) #NEWLINE# #UNINDENT# #UNINDENT# if ( items and ( len ( items ) >= threshold ) ) : #NEWLINE# #INDENT# regions = [ ] #NEWLINE# sel = self . view . sel ( ) #NEWLINE# if ( by_rows == True ) : #NEWLINE# #INDENT# items = self . by_rows ( items , sel ) #NEWLINE# #UNINDENT# if ( strip is None ) : #NEWLINE# #INDENT# strip = False #NEWLINE# if ( ( separator == '\\n' ) and settings ( ) . has ( 'clipboard_strip_newline' ) ) : #NEWLINE# #INDENT# strip = settings ( ) . get ( 'clipboard_strip_newline' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( repeat is None ) : #NEWLINE# #INDENT# if ( clipboard and settings ( ) . has ( 'repeat_clipboard' ) ) : #NEWLINE# #INDENT# repeat = settings ( ) . get ( 'repeat_clipboard' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if settings ( ) . has ( 'repeat_words' ) : #NEWLINE# #INDENT# repeat = settings ( ) . get ( 'repeat_words' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( repeat and items ) : #NEWLINE# #INDENT# while ( len ( items ) < len ( sel ) ) : #NEWLINE# #INDENT# items . extend ( items ) #NEWLINE# #UNINDENT# #UNINDENT# last_region = None #NEWLINE# for ( idx , region ) in enumerate ( sel ) : #NEWLINE# #INDENT# if ( idx < len ( items ) ) : #NEWLINE# #INDENT# current = items [ idx ] #NEWLINE# if strip : #NEWLINE# #INDENT# current = current . strip ( ) #NEWLINE# #UNINDENT# if ( align == 'prepend' ) : #NEWLINE# #INDENT# self . view . insert ( edit , region . begin ( ) , current ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( align == 'append' ) : #NEWLINE# #INDENT# self . view . insert ( edit , region . end ( ) , current ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . view . replace ( edit , region , current ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# regions . append ( region ) #NEWLINE# #UNINDENT# last_region = region #NEWLINE# #UNINDENT# if ( keep_selection is None ) : #NEWLINE# #INDENT# keep_selection = settings ( ) . get ( 'keep_selection' , False ) #NEWLINE# #UNINDENT# if ( update_selection is None ) : #NEWLINE# #INDENT# update_selection = settings ( ) . get ( 'update_selection' , None ) #NEWLINE# #UNINDENT# cursorPos = [ ( r . begin ( ) , r . end ( ) ) for r in sel ] #NEWLINE# if ( not keep_selection ) : #NEWLINE# #INDENT# sel . clear ( ) #NEWLINE# for region in regions : #NEWLINE# #INDENT# sel . add ( sublime . Region ( region . begin ( ) , region . end ( ) ) ) #NEWLINE# #UNINDENT# if ( len ( sel ) == 0 ) : #NEWLINE# #INDENT# ( begin , end ) = cursorPos [ ( - 1 ) ] #NEWLINE# sel . add ( sublime . Region ( begin , end ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( update_selection == 'begin' ) : #NEWLINE# #INDENT# sel . clear ( ) #NEWLINE# for ( begin , end ) in cursorPos : #NEWLINE# #INDENT# sel . add ( sublime . Region ( begin , begin ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( update_selection == 'end' ) : #NEWLINE# #INDENT# sel . clear ( ) #NEWLINE# for ( begin , end ) in cursorPos : #NEWLINE# #INDENT# sel . add ( sublime . Region ( end , end ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# sublime . status_message ( 'No text found for Insert Text, fall back to auto_step' ) #NEWLINE# self . view . run_command ( 'text_pastry_auto_step' , { #NEWLINE# #INDENT# 'text' : text , #NEWLINE# #UNINDENT# } )