<s> import sublime <EOL> import sublime_plugin <EOL> import re <EOL> import sys <EOL> from time import time <EOL> def plugin_loaded ( ) : <EOL> global Pref <EOL> class Pref : <EOL> def load ( self ) : <EOL> Pref . display_file = settings . get ( '<STR_LIT>' , False ) <EOL> Pref . display_class = settings . get ( '<STR_LIT>' , False ) <EOL> Pref . display_function = settings . get ( '<STR_LIT>' , True ) <EOL> Pref . display_arguments = settings . get ( '<STR_LIT>' , False ) <EOL> Pref . wait_time = <NUM_LIT> <EOL> Pref . time = time ( ) <EOL> settings = sublime . load_settings ( '<STR_LIT>' ) <EOL> Pref = Pref ( ) <EOL> Pref . load ( ) <EOL> settings . add_on_change ( '<STR_LIT>' , lambda : Pref . load ( ) ) <EOL> if sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:2> : <EOL> plugin_loaded ( ) <EOL> clean_name = re . compile ( '<STR_LIT>' , re . I ) <EOL> class FunctionNameStatusEventHandler ( sublime_plugin . EventListener ) : <EOL> def on_activated ( self , view ) : <EOL> Pref . time = time ( ) <EOL> view . settings ( ) . set ( '<STR_LIT>' , - <NUM_LIT:1> ) <EOL> sublime . set_timeout ( lambda : self . display_current_class_and_function ( view , '<STR_LIT>' ) , <NUM_LIT:0> ) <EOL> def on_modified ( self , view ) : <EOL> Pref . time = time ( ) <EOL> def on_selection_modified ( self , view ) : <EOL> now = time ( ) <EOL> if now - Pref . time > Pref . wait_time : <EOL> sublime . set_timeout ( lambda : self . display_current_class_and_function ( view , '<STR_LIT>' ) , <NUM_LIT:0> ) <EOL> else : <EOL> sublime . set_timeout ( lambda : self . display_current_class_and_function_delayed ( view ) , int ( <NUM_LIT:1000> * Pref . wait_time ) ) <EOL> Pref . time = now <EOL> def display_current_class_and_function_delayed ( self , view ) : <EOL> now = time ( ) <EOL> if ( now - Pref . time >= Pref . wait_time ) : <EOL> self . display_current_class_and_function ( view , '<STR_LIT>' ) <EOL> def display_current_class_and_function ( self , view , where ) : <EOL> view_settings = view . settings ( ) <EOL> if view_settings . get ( '<STR_LIT>' ) : <EOL> return <EOL> for region in view . sel ( ) : <EOL> region_row , region_col = view . rowcol ( region . begin ( ) ) <EOL> if region_row != view_settings . get ( '<STR_LIT>' , - <NUM_LIT:1> ) : <EOL> view_settings . set ( '<STR_LIT>' , region_row ) <EOL> else : <EOL> return <EOL> s = "<STR_LIT>" <EOL> found = False <EOL> fname = view . file_name ( ) <EOL> if Pref . display_file and None != fname : <EOL> s = fname + "<STR_LIT:U+0020>" <EOL> if Pref . display_class : <EOL> class_regions = view . find_by_selector ( '<STR_LIT>' ) <EOL> for r in reversed ( class_regions ) : <EOL> row , col = view . rowcol ( r . begin ( ) ) <EOL> if row <= region_row : <EOL> s += view . substr ( r ) <EOL> found = True <EOL> break ; <EOL> if Pref . display_function : <EOL> function_regions = view . find_by_selector ( '<STR_LIT>' ) <EOL> if function_regions : <EOL> for r in reversed ( function_regions ) : <EOL> row , col = view . rowcol ( r . begin ( ) ) <EOL> if row <= region_row : <EOL> if Pref . display_class and s : <EOL> s += "<STR_LIT>" <EOL> lines = view . substr ( r ) . splitlines ( ) <EOL> name = clean_name . sub ( '<STR_LIT>' , lines [ <NUM_LIT:0> ] ) <EOL> if Pref . display_arguments : <EOL> s += name . strip ( ) <EOL> else : <EOL> if '<STR_LIT>' in view . settings ( ) . get ( '<STR_LIT>' ) : <EOL> if Pref . display_class or len ( name . split ( '<STR_LIT:(>' ) [ <NUM_LIT:0> ] . split ( '<STR_LIT>' ) ) < <NUM_LIT:2> : <EOL> s += name . split ( '<STR_LIT:(>' ) [ <NUM_LIT:0> ] . strip ( ) <EOL> else : <EOL> s += name . split ( '<STR_LIT:(>' ) [ <NUM_LIT:0> ] . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] . strip ( ) <EOL> else : <EOL> s += name . split ( '<STR_LIT:(>' ) [ <NUM_LIT:0> ] . split ( '<STR_LIT::>' ) [ <NUM_LIT:0> ] . strip ( ) <EOL> found = True <EOL> break <EOL> if not found : <EOL> view . erase_status ( '<STR_LIT>' ) <EOL> fname = view . file_name ( ) <EOL> if Pref . display_file and None != fname : <EOL> view . set_status ( '<STR_LIT>' , fname ) <EOL> else : <EOL> view . set_status ( '<STR_LIT>' , s ) <EOL> return <EOL> view . erase_status ( '<STR_LIT>' ) </s>
