#NEWLINE# def run( self , edit , command , args = None , text = None , separator = None , items = None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# cmd = Command . create ( command , args ) #NEWLINE# if cmd : #NEWLINE# #INDENT# items = items #NEWLINE# if text : #NEWLINE# #INDENT# items = text . split ( separator ) #NEWLINE# #UNINDENT# cmd . init ( separator . view , items ) #NEWLINE# regions = [ ] #NEWLINE# sel = self . view . sel ( ) #NEWLINE# index = 0 #NEWLINE# last_region = None #NEWLINE# for region in sel : #NEWLINE# #INDENT# if cmd . has_next ( ) : #NEWLINE# #INDENT# value = cmd . next ( self . view . substr ( region ) , index , region ) #NEWLINE# if ( value is not None ) : #NEWLINE# #INDENT# self . view . replace ( edit , region , value ) #NEWLINE# regions . append ( region ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# last_region = region #NEWLINE# index += 1 #NEWLINE# #UNINDENT# if ( not global_settings ( 'keep_selection' , False ) ) : #NEWLINE# #INDENT# [ sel . subtract ( region ) for region in regions ] #NEWLINE# #UNINDENT# if ( len ( sel ) == 0 ) : #NEWLINE# #INDENT# sel . add ( sublime . Region ( last_region . end ( ) , last_region . end ( ) ) ) #NEWLINE# #UNINDENT# sublime . status_message ( ( 'Command done: ' + command ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sublime . error_message ( ( 'Command not found: ' + command ) ) #NEWLINE# #UNINDENT# #UNINDENT# except ValueError : #NEWLINE# #INDENT# sublime . status_message ( 'Error while executing Text Pastry Command, canceled' ) #NEWLINE# pass