#NEWLINE# def show( self , window = None , on_done = None , menu = None , action = None , flags = 0 , on_highlight = None , level = 0 ) : #NEWLINE# #INDENT# selected_index = ( - 1 ) #NEWLINE# if ( ( window is None ) and ( self . tmp [ 'window' ] is not None ) ) : #NEWLINE# #INDENT# window = self . tmp [ 'window' ] #NEWLINE# self . tmp [ 'window' ] = None #NEWLINE# #UNINDENT# if ( ( window is None ) and ( not self . settings [ 'silent' ] ) ) : #NEWLINE# #INDENT# sublime . message_dialog ( 'No window to show' ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( ( on_done is None ) and ( self . tmp [ 'callback' ] is not None ) ) : #NEWLINE# #INDENT# on_done = self . tmp [ 'callback' ] #NEWLINE# #UNINDENT# if ( ( self . settings [ 'menu' ] is None ) or ( 'main' not in self . settings [ 'menu' ] ) or ( 'items' not in self . settings [ 'menu' ] [ 'main' ] ) ) : #NEWLINE# #INDENT# if ( not self . settings [ 'silent' ] ) : #NEWLINE# #INDENT# sublime . message_dialog ( 'No menu to show' ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if ( ( menu is None ) and ( self . tmp [ 'menu' ] is not None ) ) : #NEWLINE# #INDENT# menu = self . tmp [ 'menu' ] #NEWLINE# self . tmp [ 'menu' ] = None #NEWLINE# #UNINDENT# if ( ( menu is None ) or ( 'items' not in menu ) ) : #NEWLINE# #INDENT# menu = self . settings [ 'menu' ] [ 'main' ] #NEWLINE# #UNINDENT# if ( ( action is None ) and ( self . tmp [ 'select' ] is not None ) ) : #NEWLINE# #INDENT# action = self . tmp [ 'select' ] #NEWLINE# self . tmp [ 'select' ] = None #NEWLINE# #UNINDENT# if ( action is not None ) : #NEWLINE# #INDENT# if ( 'name' in action ) : #NEWLINE# #INDENT# if ( action [ 'name' ] not in self . settings [ 'menu' ] ) : #NEWLINE# #INDENT# if ( not self . settings [ 'silent' ] ) : #NEWLINE# #INDENT# sublime . message_dialog ( 'No menu found' ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# menu = self . settings [ 'menu' ] [ action [ 'name' ] ] #NEWLINE# if ( ( 'item' in action ) and ( 'actions' in menu ) ) : #NEWLINE# #INDENT# if ( level >= self . settings [ 'max_level' ] ) : #NEWLINE# #INDENT# if ( not self . settings [ 'silent' ] ) : #NEWLINE# #INDENT# sublime . message_dialog ( 'Seem like menu go into too many levels now...' ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if ( len ( menu [ 'actions' ] ) < action [ 'item' ] ) : #NEWLINE# #INDENT# if ( not self . settings [ 'silent' ] ) : #NEWLINE# #INDENT# sublime . message_dialog ( 'Invalid menu selection' ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# self . tmp [ 'sublime' ] = False #NEWLINE# self . show ( window , on_done , menu , menu [ 'actions' ] [ ( action [ 'item' ] - 1 ) ] , flags , on_highlight , ( level + 1 ) ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'command' in action ) : #NEWLINE# #INDENT# if ( 'args' in action ) : #NEWLINE# #INDENT# if ( action [ 'command' ] == 'message_dialog' ) : #NEWLINE# #INDENT# sublime . message_dialog ( action [ 'args' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( action [ 'command' ] == 'error_dialog' ) : #NEWLINE# #INDENT# sublime . error_message ( action [ 'args' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sublime . active_window ( ) . run_command ( action [ 'command' ] , action [ 'args' ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# sublime . active_window ( ) . run_command ( action [ 'command' ] ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not self . settings [ 'silent' ] ) : #NEWLINE# #INDENT# sublime . message_dialog ( 'No action assigned' ) #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( 'selected_index' in menu ) and ( menu [ 'selected_index' ] > 0 ) ) : #NEWLINE# #INDENT# selected_index = ( menu [ 'selected_index' ] - 1 ) #NEWLINE# #UNINDENT# if ( self . settings [ 'save_selected' ] and ( 'previous_selected_index' in menu ) and ( menu [ 'previous_selected_index' ] >= 0 ) ) : #NEWLINE# #INDENT# selected_index = menu [ 'previous_selected_index' ] #NEWLINE# #UNINDENT# self . tmp [ 'menu' ] = menu #NEWLINE# self . tmp [ 'window' ] = window #NEWLINE# self . tmp [ 'callback' ] = on_done #NEWLINE# self . tmp [ 'level' ] = ( self . tmp [ 'level' ] + 1 ) #NEWLINE# window . show_quick_panel ( menu [ 'items' ] , self . select , flags , selected_index , on_highlight )