<s> """<STR_LIT>""" <EOL> import sublime <EOL> import sublime_plugin <EOL> from ColorHelper . lib . rgba import RGBA <EOL> from ColorHelper . lib import csscolors <EOL> import threading <EOL> from time import time , sleep <EOL> import re <EOL> import os <EOL> import mdpopups <EOL> import ColorHelper . color_helper_util as util <EOL> from ColorHelper . color_helper_insert import InsertCalc , PickerInsertCalc <EOL> PALETTE_MENU = '<STR_LIT>' <EOL> PICK_MENU = '<STR_LIT>' <EOL> ADD_COLOR_MENU = '<STR_LIT>' <EOL> UNMARK_MENU = '<STR_LIT>' <EOL> MARK_MENU = '<STR_LIT>' <EOL> WEB_COLOR = '''<STR_LIT>''' <EOL> HEX_COLOR = '''<STR_LIT>''' <EOL> HEXA_COLOR = '''<STR_LIT>''' <EOL> AHEX_COLOR = '''<STR_LIT>''' <EOL> RGB_COLOR = '''<STR_LIT>''' <EOL> RGBA_COLOR = '''<STR_LIT>''' <EOL> GRAY_COLOR = '''<STR_LIT>''' <EOL> GRAYA_COLOR = '''<STR_LIT>''' <EOL> HSL_COLOR = '''<STR_LIT>''' <EOL> HSLA_COLOR = '''<STR_LIT>''' <EOL> HWB_COLOR = '''<STR_LIT>''' <EOL> HWBA_COLOR = '''<STR_LIT>''' <EOL> HEXA_COLOR_ALPHA = '''<STR_LIT>''' <EOL> AHEX_COLOR_ALPHA = '''<STR_LIT>''' <EOL> RGBA_COLOR_ALPHA = '''<STR_LIT>''' <EOL> GRAYA_COLOR_ALPHA = '''<STR_LIT>''' <EOL> HSLA_COLOR_ALPHA = '''<STR_LIT>''' <EOL> HWBA_COLOR_ALPHA = '''<STR_LIT>''' <EOL> BACK_INFO_MENU = '<STR_LIT>' <EOL> BACK_PALETTE_MENU = '<STR_LIT>' <EOL> BACK_COLORS_MENU = '<STR_LIT>' <EOL> DELETE_PALETTE_MENU = '<STR_LIT>' <EOL> DELETE_COLOR_MENU = '<STR_LIT>' <EOL> DELETE_COLOR = '''<STR_LIT>''' <EOL> DELETE_PALETTE = '''<STR_LIT>''' <EOL> NEW_PALETTE = '''<STR_LIT>''' <EOL> DIVIDER = '''<STR_LIT>''' <EOL> ch_last_updated = None <EOL> ch_settings = None <EOL> if '<STR_LIT>' not in globals ( ) : <EOL> ch_thread = None <EOL> if '<STR_LIT>' not in globals ( ) : <EOL> ch_file_thread = None <EOL> def start_file_index ( view ) : <EOL> """<STR_LIT>""" <EOL> global ch_file_thread <EOL> if view is not None and ( ch_file_thread is None or not ch_file_thread . is_alive ( ) ) : <EOL> rules = util . get_rules ( view ) <EOL> if rules : <EOL> scope = util . get_scope ( view , rules , skip_sel_check = True ) <EOL> if scope : <EOL> source = [ ] <EOL> for r in view . find_by_selector ( scope ) : <EOL> source . append ( view . substr ( r ) ) <EOL> util . debug ( '<STR_LIT>' , source ) <EOL> if len ( source ) : <EOL> ch_file_thread = ChFileIndexThread ( <EOL> view , '<STR_LIT:U+0020>' . join ( source ) , <EOL> rules . get ( '<STR_LIT>' , [ ] ) , <EOL> rules . get ( '<STR_LIT>' , False ) <EOL> ) <EOL> ch_file_thread . start ( ) <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> if s . get ( '<STR_LIT>' , True ) : <EOL> sublime . status_message ( '<STR_LIT>' ) <EOL> class ColorHelperCommand ( sublime_plugin . TextCommand ) : <EOL> """<STR_LIT>""" <EOL> def on_hide ( self ) : <EOL> """<STR_LIT>""" <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , False ) <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , self . auto ) <EOL> def on_navigate ( self , href ) : <EOL> """<STR_LIT>""" <EOL> if href . startswith ( '<STR_LIT>' ) : <EOL> parts = href . split ( '<STR_LIT::>' , <NUM_LIT:3> ) <EOL> self . show_insert ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] , parts [ <NUM_LIT:3> ] ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> parts = href . split ( '<STR_LIT::>' , <NUM_LIT:2> ) <EOL> self . show_colors ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] , update = True ) <EOL> elif href == '<STR_LIT>' : <EOL> self . view . hide_popup ( ) <EOL> elif href == '<STR_LIT>' : <EOL> self . show_palettes ( update = True ) <EOL> elif href == '<STR_LIT>' : <EOL> self . show_color_info ( update = True ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> self . color_picker ( color = href . split ( '<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> self . add_fav ( href . split ( '<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> self . remove_fav ( href . split ( '<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> parts = href . split ( '<STR_LIT::>' , <NUM_LIT:2> ) <EOL> self . show_colors ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] , delete = True , update = True ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> parts = href . split ( '<STR_LIT::>' , <NUM_LIT:3> ) <EOL> self . delete_color ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] , parts [ <NUM_LIT:3> ] ) <EOL> elif href == '<STR_LIT>' : <EOL> self . show_palettes ( delete = True , update = True ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> parts = href . split ( '<STR_LIT::>' , <NUM_LIT:2> ) <EOL> self . delete_palette ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> self . show_palettes ( color = href . split ( '<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] , update = True ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> parts = href . split ( '<STR_LIT::>' , <NUM_LIT:3> ) <EOL> self . add_palette ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] , parts [ <NUM_LIT:3> ] ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> parts = href . split ( '<STR_LIT::>' , <NUM_LIT:2> ) <EOL> self . prompt_palette_name ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> parts = href . split ( '<STR_LIT::>' , <NUM_LIT:2> ) <EOL> self . insert_color ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] , alpha = True ) <EOL> elif href . startswith ( '<STR_LIT>' ) : <EOL> parts = href . split ( '<STR_LIT::>' , <NUM_LIT:2> ) <EOL> self . insert_color ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] ) <EOL> def repop ( self ) : <EOL> """<STR_LIT>""" <EOL> return <EOL> if ch_thread . ignore_all : <EOL> return <EOL> now = time ( ) <EOL> ch_thread . modified = True <EOL> ch_thread . time = now <EOL> def prompt_palette_name ( self , palette_type , color ) : <EOL> """<STR_LIT>""" <EOL> win = self . view . window ( ) <EOL> if win is not None : <EOL> self . view . hide_popup ( ) <EOL> win . show_input_panel ( <EOL> "<STR_LIT>" , '<STR_LIT>' , <EOL> on_done = lambda name , t = palette_type , c = color : self . create_palette ( name , t , color ) , <EOL> on_change = None , <EOL> on_cancel = self . repop <EOL> ) <EOL> def create_palette ( self , palette_name , palette_type , color ) : <EOL> """<STR_LIT>""" <EOL> if palette_type == '<STR_LIT>' : <EOL> color_palettes = util . get_palettes ( ) <EOL> for palette in color_palettes : <EOL> if palette_name == palette [ '<STR_LIT:name>' ] : <EOL> sublime . error_message ( '<STR_LIT>' ) <EOL> return <EOL> color_palettes . append ( { "<STR_LIT:name>" : palette_name , '<STR_LIT>' : [ color ] } ) <EOL> util . save_palettes ( color_palettes ) <EOL> elif palette_type == '<STR_LIT>' : <EOL> color_palettes = util . get_project_palettes ( self . view . window ( ) ) <EOL> for palette in color_palettes : <EOL> if palette_name == palette [ '<STR_LIT:name>' ] : <EOL> sublime . error_message ( '<STR_LIT>' ) <EOL> return <EOL> color_palettes . append ( { "<STR_LIT:name>" : palette_name , '<STR_LIT>' : [ color ] } ) <EOL> util . save_project_palettes ( self . view . window ( ) , color_palettes ) <EOL> self . repop ( ) <EOL> def add_palette ( self , color , palette_type , palette_name ) : <EOL> """<STR_LIT>""" <EOL> if palette_type == "<STR_LIT>" : <EOL> if palette_name == '<STR_LIT>' : <EOL> favs = util . get_favs ( ) [ '<STR_LIT>' ] <EOL> if color not in favs : <EOL> favs . append ( color ) <EOL> util . save_palettes ( favs , favs = True ) <EOL> self . show_color_info ( update = True ) <EOL> elif palette_type in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if palette_type == '<STR_LIT>' : <EOL> color_palettes = util . get_palettes ( ) <EOL> else : <EOL> color_palettes = util . get_project_palettes ( self . view . window ( ) ) <EOL> for palette in color_palettes : <EOL> if palette_name == palette [ '<STR_LIT:name>' ] : <EOL> if color not in palette [ '<STR_LIT>' ] : <EOL> palette [ '<STR_LIT>' ] . append ( color ) <EOL> if palette_type == '<STR_LIT>' : <EOL> util . save_palettes ( color_palettes ) <EOL> else : <EOL> util . save_project_palettes ( self . view . window ( ) , color_palettes ) <EOL> self . show_color_info ( update = True ) <EOL> break <EOL> def delete_palette ( self , palette_type , palette_name ) : <EOL> """<STR_LIT>""" <EOL> if palette_type == "<STR_LIT>" : <EOL> if palette_name == '<STR_LIT>' : <EOL> util . save_palettes ( [ ] , favs = True ) <EOL> self . show_palettes ( delete = True , update = False ) <EOL> elif palette_type in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if palette_type == '<STR_LIT>' : <EOL> color_palettes = util . get_palettes ( ) <EOL> else : <EOL> color_palettes = util . get_project_palettes ( self . view . window ( ) ) <EOL> count = - <NUM_LIT:1> <EOL> index = None <EOL> for palette in color_palettes : <EOL> count += <NUM_LIT:1> <EOL> if palette_name == palette [ '<STR_LIT:name>' ] : <EOL> index = count <EOL> break <EOL> if index is not None : <EOL> del color_palettes [ index ] <EOL> if palette_type == '<STR_LIT>' : <EOL> util . save_palettes ( color_palettes ) <EOL> else : <EOL> util . save_project_palettes ( self . view . window ( ) , color_palettes ) <EOL> self . show_palettes ( delete = True , update = False ) <EOL> def delete_color ( self , color , palette_type , palette_name ) : <EOL> """<STR_LIT>""" <EOL> if palette_type == '<STR_LIT>' : <EOL> if palette_name == "<STR_LIT>" : <EOL> favs = util . get_favs ( ) [ '<STR_LIT>' ] <EOL> if color in favs : <EOL> favs . remove ( color ) <EOL> util . save_palettes ( favs , favs = True ) <EOL> self . show_colors ( palette_type , palette_name , delete = True , update = False ) <EOL> elif palette_type in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if palette_type == '<STR_LIT>' : <EOL> color_palettes = util . get_palettes ( ) <EOL> else : <EOL> color_palettes = util . get_project_palettes ( self . view . window ( ) ) <EOL> for palette in color_palettes : <EOL> if palette_name == palette [ '<STR_LIT:name>' ] : <EOL> if color in palette [ '<STR_LIT>' ] : <EOL> palette [ '<STR_LIT>' ] . remove ( color ) <EOL> if palette_type == '<STR_LIT>' : <EOL> util . save_palettes ( color_palettes ) <EOL> else : <EOL> util . save_project_palettes ( self . view . window ( ) , color_palettes ) <EOL> self . show_colors ( palette_type , palette_name , delete = True , update = False ) <EOL> break <EOL> def add_fav ( self , color ) : <EOL> """<STR_LIT>""" <EOL> favs = util . get_favs ( ) [ '<STR_LIT>' ] <EOL> favs . append ( color ) <EOL> util . save_palettes ( favs , favs = True ) <EOL> self . show_color_info ( update = False ) <EOL> def remove_fav ( self , color ) : <EOL> """<STR_LIT>""" <EOL> favs = util . get_favs ( ) [ '<STR_LIT>' ] <EOL> favs . remove ( color ) <EOL> util . save_palettes ( favs , favs = True ) <EOL> self . show_color_info ( update = False ) <EOL> def color_picker ( self , color ) : <EOL> """<STR_LIT>""" <EOL> if self . color_picker_package : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> s . set ( '<STR_LIT>' , None ) <EOL> self . view . window ( ) . run_command ( <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' , "<STR_LIT>" : color [ <NUM_LIT:1> : ] } <EOL> ) <EOL> new_color = s . get ( '<STR_LIT>' , None ) <EOL> if new_color is not None and new_color != color : <EOL> self . insert_color ( new_color ) <EOL> else : <EOL> sublime . set_timeout ( self . show_color_info , <NUM_LIT:0> ) <EOL> else : <EOL> if not self . no_info : <EOL> on_cancel = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:args>' : { '<STR_LIT>' : "<STR_LIT:info>" , "<STR_LIT>" : self . auto } } <EOL> elif not self . no_palette : <EOL> on_cancel = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:args>' : { '<STR_LIT>' : "<STR_LIT>" , "<STR_LIT>" : self . auto } } <EOL> else : <EOL> on_cancel = None <EOL> rules = util . get_rules ( self . view ) <EOL> allowed_colors = rules . get ( '<STR_LIT>' , [ ] ) if rules else util . ALL <EOL> use_hex_argb = rules . get ( "<STR_LIT>" , False ) if rules else False <EOL> compress_hex = rules . get ( "<STR_LIT>" , False ) if rules else False <EOL> self . view . run_command ( <EOL> '<STR_LIT>' , { <EOL> '<STR_LIT>' : color , <EOL> '<STR_LIT>' : allowed_colors , <EOL> '<STR_LIT>' : use_hex_argb , <EOL> '<STR_LIT>' : compress_hex , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:args>' : { '<STR_LIT>' : "<STR_LIT>" } } , <EOL> '<STR_LIT>' : on_cancel <EOL> } <EOL> ) <EOL> def insert_color ( self , target_color , convert = None , picker = False , alpha = False ) : <EOL> """<STR_LIT>""" <EOL> sels = self . view . sel ( ) <EOL> if ( len ( sels ) == <NUM_LIT:1> and sels [ <NUM_LIT:0> ] . size ( ) == <NUM_LIT:0> ) : <EOL> point = sels [ <NUM_LIT:0> ] . begin ( ) <EOL> parts = target_color . split ( '<STR_LIT:@>' ) <EOL> target_color = parts [ <NUM_LIT:0> ] <EOL> dlevel = len ( parts [ <NUM_LIT:1> ] ) if len ( parts ) > <NUM_LIT:1> else <NUM_LIT:3> <EOL> if not picker : <EOL> rules = util . get_rules ( self . view ) <EOL> use_hex_argb = rules . get ( "<STR_LIT>" , False ) if rules else False <EOL> allowed_colors = rules . get ( '<STR_LIT>' , [ ] ) if rules else util . ALL <EOL> compress_hex = rules . get ( '<STR_LIT>' , False ) if rules else False <EOL> calc = InsertCalc ( self . view , point , target_color , convert , allowed_colors , use_hex_argb ) <EOL> calc . calc ( ) <EOL> if alpha : <EOL> calc . alpha_hex = target_color [ - <NUM_LIT:2> : ] <EOL> calc . alpha = util . fmt_float ( float ( int ( calc . alpha_hex , <NUM_LIT:16> ) ) / <NUM_LIT> , dlevel ) <EOL> if calc . web_color and not calc . alpha : <EOL> value = calc . web_color <EOL> elif calc . convert_rgb : <EOL> value = "<STR_LIT>" % ( <EOL> int ( calc . color [ <NUM_LIT:1> : <NUM_LIT:3> ] , <NUM_LIT:16> ) , <EOL> int ( calc . color [ <NUM_LIT:3> : <NUM_LIT:5> ] , <NUM_LIT:16> ) , <EOL> int ( calc . color [ <NUM_LIT:5> : <NUM_LIT:7> ] , <NUM_LIT:16> ) <EOL> ) <EOL> if calc . alpha : <EOL> value += '<STR_LIT>' % calc . alpha <EOL> value = ( "<STR_LIT>" if calc . alpha else "<STR_LIT>" ) % value <EOL> elif calc . convert_gray : <EOL> value = "<STR_LIT>" % int ( calc . color [ <NUM_LIT:1> : <NUM_LIT:3> ] , <NUM_LIT:16> ) <EOL> if calc . alpha : <EOL> value += '<STR_LIT>' % calc . alpha <EOL> value = "<STR_LIT>" % value <EOL> elif calc . convert_hsl : <EOL> hsl = RGBA ( calc . color ) <EOL> h , l , s = hsl . tohls ( ) <EOL> value = "<STR_LIT>" % ( <EOL> util . fmt_float ( h * <NUM_LIT> ) , <EOL> util . fmt_float ( s * <NUM_LIT> ) , <EOL> util . fmt_float ( l * <NUM_LIT> ) <EOL> ) <EOL> if calc . alpha : <EOL> value += '<STR_LIT>' % calc . alpha <EOL> value = ( "<STR_LIT>" if calc . alpha else "<STR_LIT>" ) % value <EOL> elif calc . convert_hwb : <EOL> hwb = RGBA ( calc . color ) <EOL> h , w , b = hwb . tohwb ( ) <EOL> value = "<STR_LIT>" % ( <EOL> util . fmt_float ( h * <NUM_LIT> ) , <EOL> util . fmt_float ( w * <NUM_LIT> ) , <EOL> util . fmt_float ( b * <NUM_LIT> ) <EOL> ) <EOL> if calc . alpha : <EOL> value += '<STR_LIT>' % calc . alpha <EOL> value = "<STR_LIT>" % value <EOL> else : <EOL> use_upper = ch_settings . get ( "<STR_LIT>" , False ) <EOL> color = calc . color <EOL> if calc . alpha_hex : <EOL> if convert == '<STR_LIT>' : <EOL> color = '<STR_LIT:#>' + calc . alpha_hex + calc . color [ <NUM_LIT:1> : ] <EOL> else : <EOL> color = calc . color + calc . alpha_hex <EOL> if compress_hex : <EOL> color = util . compress_hex ( color ) <EOL> value = color . upper ( ) if use_upper else color . lower ( ) <EOL> else : <EOL> rules = util . get_rules ( self . view ) <EOL> allowed_colors = rules . get ( '<STR_LIT>' , [ ] ) if rules else util . ALL <EOL> calc = PickerInsertCalc ( self . view , point , allowed_colors ) <EOL> calc . calc ( ) <EOL> value = target_color <EOL> self . view . sel ( ) . subtract ( sels [ <NUM_LIT:0> ] ) <EOL> self . view . sel ( ) . add ( calc . region ) <EOL> self . view . run_command ( "<STR_LIT>" , { "<STR_LIT>" : value } ) <EOL> self . view . hide_popup ( ) <EOL> def format_palettes ( self , color_list , label , palette_type , caption = None , color = None , delete = False ) : <EOL> """<STR_LIT>""" <EOL> colors = [ '<STR_LIT>' % label ] <EOL> if caption : <EOL> colors . append ( '<STR_LIT>' % caption ) <EOL> if delete : <EOL> label = '<STR_LIT>' % ( palette_type , label ) <EOL> elif color : <EOL> label = '<STR_LIT>' % ( color , palette_type , label ) <EOL> else : <EOL> label = '<STR_LIT>' % ( palette_type , label ) <EOL> colors . append ( <EOL> '<STR_LIT>' % ( <EOL> mdpopups . color_box ( <EOL> color_list , '<STR_LIT>' , '<STR_LIT>' , <EOL> height = self . color_h , width = self . color_w * <NUM_LIT:8> , border_size = <NUM_LIT:2> <EOL> ) , <EOL> label <EOL> ) <EOL> ) <EOL> return '<STR_LIT>' . join ( colors ) <EOL> def format_colors ( self , color_list , label , palette_type , delete = None ) : <EOL> """<STR_LIT>""" <EOL> colors = [ '<STR_LIT>' % label ] <EOL> count = <NUM_LIT:0> <EOL> for f in color_list : <EOL> parts = f . split ( '<STR_LIT:@>' ) <EOL> if len ( parts ) > <NUM_LIT:1> : <EOL> color = parts [ <NUM_LIT:0> ] <EOL> else : <EOL> color = f <EOL> no_alpha_color = color [ : - <NUM_LIT:2> ] if len ( f ) > <NUM_LIT:7> else color <EOL> if count != <NUM_LIT:0> and ( count % <NUM_LIT:8> == <NUM_LIT:0> ) : <EOL> colors . append ( '<STR_LIT>' ) <EOL> elif count != <NUM_LIT:0> : <EOL> if sublime . platform ( ) == '<STR_LIT>' : <EOL> colors . append ( '<STR_LIT>' ) <EOL> else : <EOL> colors . append ( '<STR_LIT>' ) <EOL> if delete : <EOL> colors . append ( <EOL> '<STR_LIT>' % ( <EOL> mdpopups . color_box ( <EOL> [ no_alpha_color , color ] , '<STR_LIT>' , '<STR_LIT>' , <EOL> height = self . color_h , width = self . color_w , border_size = <NUM_LIT:2> <EOL> ) , <EOL> f , palette_type , label , <EOL> ) <EOL> ) <EOL> else : <EOL> colors . append ( <EOL> '<STR_LIT>' % ( <EOL> mdpopups . color_box ( <EOL> [ no_alpha_color , color ] , '<STR_LIT>' , '<STR_LIT>' , <EOL> height = self . color_h , width = self . color_w , border_size = <NUM_LIT:2> <EOL> ) , f , palette_type , label <EOL> ) <EOL> ) <EOL> count += <NUM_LIT:1> <EOL> return '<STR_LIT>' . join ( colors ) <EOL> def format_info ( self , color , alpha = None ) : <EOL> """<STR_LIT>""" <EOL> rgba = RGBA ( color ) <EOL> rules = util . get_rules ( self . view ) <EOL> allowed_colors = rules . get ( '<STR_LIT>' , [ ] ) if rules else util . ALL <EOL> use_hex_argb = rules . get ( "<STR_LIT>" , False ) if rules else None <EOL> if alpha is not None : <EOL> parts = alpha . split ( '<STR_LIT:.>' ) <EOL> dlevel = len ( parts [ <NUM_LIT:1> ] ) if len ( parts ) > <NUM_LIT:1> else None <EOL> alpha_hex = alpha_hex_display = "<STR_LIT>" % ( util . round_int ( float ( alpha ) * <NUM_LIT> ) & <NUM_LIT> ) <EOL> if dlevel is not None : <EOL> alpha_hex += '<STR_LIT>' % dlevel <EOL> else : <EOL> alpha_hex = '<STR_LIT>' <EOL> try : <EOL> web_color = csscolors . hex2name ( rgba . get_rgb ( ) ) <EOL> except Exception : <EOL> web_color = None <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> show_global_palettes = s . get ( '<STR_LIT>' , True ) <EOL> show_project_palettes = s . get ( '<STR_LIT>' , True ) <EOL> show_favorite_palette = s . get ( '<STR_LIT>' , True ) <EOL> show_current_palette = s . get ( '<STR_LIT>' , True ) <EOL> show_conversions = s . get ( '<STR_LIT>' , True ) <EOL> show_picker = s . get ( '<STR_LIT>' , True ) <EOL> palettes_enabled = ( <EOL> show_global_palettes or show_project_palettes or <EOL> show_favorite_palette or show_current_palette <EOL> ) <EOL> click_color_box_to_pick = s . get ( '<STR_LIT>' , '<STR_LIT:none>' ) <EOL> if click_color_box_to_pick == '<STR_LIT>' and show_picker : <EOL> color_box_wrapper = '<STR_LIT>' + ( '<STR_LIT>' % color ) <EOL> elif click_color_box_to_pick == '<STR_LIT>' and palettes_enabled : <EOL> color_box_wrapper = '<STR_LIT>' <EOL> else : <EOL> color_box_wrapper = '<STR_LIT>' <EOL> info = [ ] <EOL> if click_color_box_to_pick != '<STR_LIT>' and palettes_enabled : <EOL> info . append ( PALETTE_MENU ) <EOL> if click_color_box_to_pick != '<STR_LIT>' and show_picker : <EOL> info . append ( PICK_MENU % color ) <EOL> if show_global_palettes or show_project_palettes : <EOL> info . append ( ADD_COLOR_MENU % color . lower ( ) ) <EOL> if show_favorite_palette : <EOL> if ( color . lower ( ) + alpha_hex ) in util . get_favs ( ) [ '<STR_LIT>' ] : <EOL> info . append ( UNMARK_MENU % ( color . lower ( ) + alpha_hex ) ) <EOL> else : <EOL> info . append ( MARK_MENU % ( color . lower ( ) + alpha_hex ) ) <EOL> no_alpha_color = color [ : - <NUM_LIT:2> ] if len ( color ) > <NUM_LIT:7> else color <EOL> info . append ( <EOL> color_box_wrapper % mdpopups . color_box ( <EOL> [ no_alpha_color , color ] , '<STR_LIT>' , '<STR_LIT>' , <EOL> height = self . preview_h , width = self . preview_w , border_size = <NUM_LIT:2> <EOL> ) <EOL> ) <EOL> if show_conversions : <EOL> info . append ( '<STR_LIT>' ) <EOL> if web_color and '<STR_LIT>' in allowed_colors : <EOL> info . append ( WEB_COLOR % ( color , web_color ) ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> info . append ( HEX_COLOR % ( color , ( color . lower ( ) if not alpha else color [ : - <NUM_LIT:2> ] . lower ( ) ) ) ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> if use_hex_argb is None or use_hex_argb is False : <EOL> info . append ( HEXA_COLOR % ( <EOL> color , rgba . get_rgb ( ) . lower ( ) , ( '<STR_LIT>' if not alpha else alpha_hex_display ) ) <EOL> ) <EOL> elif use_hex_argb is None or use_hex_argb is True : <EOL> info . append ( AHEX_COLOR % ( <EOL> color , '<STR_LIT:#>' , ( '<STR_LIT>' if not alpha else alpha_hex_display ) , rgba . get_rgb ( ) . lower ( ) [ <NUM_LIT:1> : ] ) <EOL> ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> info . append ( RGB_COLOR % ( color , rgba . r , rgba . g , rgba . b ) ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> info . append ( RGBA_COLOR % ( color , rgba . r , rgba . g , rgba . b , alpha if alpha else '<STR_LIT:1>' ) ) <EOL> if "<STR_LIT>" in allowed_colors and util . is_gray ( rgba . get_rgb ( ) ) : <EOL> info . append ( GRAY_COLOR % ( color , rgba . r ) ) <EOL> if "<STR_LIT>" in allowed_colors and util . is_gray ( rgba . get_rgb ( ) ) : <EOL> info . append ( GRAYA_COLOR % ( color , rgba . r , alpha if alpha else '<STR_LIT:1>' ) ) <EOL> h , l , s = rgba . tohls ( ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> info . append ( <EOL> HSL_COLOR % ( <EOL> color , util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( s * <NUM_LIT> ) , util . fmt_float ( l * <NUM_LIT> ) <EOL> ) <EOL> ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> info . append ( <EOL> HSLA_COLOR % ( <EOL> color , util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( s * <NUM_LIT> ) , util . fmt_float ( l * <NUM_LIT> ) , <EOL> alpha if alpha else '<STR_LIT:1>' <EOL> ) <EOL> ) <EOL> h , w , b = rgba . tohwb ( ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> info . append ( <EOL> HWB_COLOR % ( <EOL> color , util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( w * <NUM_LIT> ) , util . fmt_float ( b * <NUM_LIT> ) <EOL> ) <EOL> ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> info . append ( <EOL> HWBA_COLOR % ( <EOL> color , util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( w * <NUM_LIT> ) , util . fmt_float ( b * <NUM_LIT> ) , <EOL> alpha if alpha else '<STR_LIT:1>' <EOL> ) <EOL> ) <EOL> return '<STR_LIT>' . join ( info ) <EOL> def show_insert ( self , color , palette_type , palette_name , update = False ) : <EOL> """<STR_LIT>""" <EOL> sels = self . view . sel ( ) <EOL> if ( len ( sels ) == <NUM_LIT:1> and sels [ <NUM_LIT:0> ] . size ( ) == <NUM_LIT:0> ) : <EOL> parts = color . split ( '<STR_LIT:@>' ) <EOL> dlevel = len ( parts [ <NUM_LIT:1> ] ) if len ( parts ) > <NUM_LIT:1> else <NUM_LIT:3> <EOL> point = sels [ <NUM_LIT:0> ] . begin ( ) <EOL> rules = util . get_rules ( self . view ) <EOL> use_hex_argb = rules . get ( "<STR_LIT>" , False ) if rules else None <EOL> allowed_colors = rules . get ( '<STR_LIT>' , [ ] ) if rules else util . ALL <EOL> calc = InsertCalc ( self . view , point , parts [ <NUM_LIT:0> ] , '<STR_LIT>' , allowed_colors , bool ( use_hex_argb ) ) <EOL> found = calc . calc ( ) <EOL> rules = util . get_rules ( self . view ) <EOL> allowed_colors = rules . get ( '<STR_LIT>' , [ ] ) if rules else util . ALL <EOL> secondry_alpha = found and calc . alpha is not None and calc . alpha != '<STR_LIT:1>' <EOL> txt = [ <EOL> BACK_COLORS_MENU % ( palette_type , palette_name ) , <EOL> '<STR_LIT>' <EOL> ] <EOL> rgba = RGBA ( parts [ <NUM_LIT:0> ] ) <EOL> alpha = util . fmt_float ( float ( rgba . a ) / <NUM_LIT> , dlevel ) <EOL> try : <EOL> web_color = csscolors . hex2name ( rgba . get_rgb ( ) ) <EOL> except Exception : <EOL> web_color = None <EOL> if web_color and "<STR_LIT>" in allowed_colors : <EOL> txt . append ( WEB_COLOR % ( rgba . get_rgb ( ) , web_color ) ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( HEX_COLOR % ( rgba . get_rgb ( ) , rgba . get_rgb ( ) ) ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> if use_hex_argb is None or use_hex_argb is False : <EOL> txt . append ( HEXA_COLOR_ALPHA % ( rgba . get_rgba ( ) , rgba . get_rgb ( ) , rgba . get_rgba ( ) [ - <NUM_LIT:2> : ] ) ) <EOL> if use_hex_argb is None or use_hex_argb is True : <EOL> txt . append ( AHEX_COLOR_ALPHA % ( rgba . get_rgba ( ) , '<STR_LIT:#>' , rgba . get_rgba ( ) [ - <NUM_LIT:2> : ] , rgba . get_rgb ( ) [ <NUM_LIT:1> : ] ) ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( RGB_COLOR % ( rgba . get_rgb ( ) , rgba . r , rgba . g , rgba . b ) ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( RGBA_COLOR_ALPHA % ( rgba . get_rgba ( ) + ( "<STR_LIT>" % dlevel ) , rgba . r , rgba . g , rgba . b , alpha ) ) <EOL> if "<STR_LIT>" in allowed_colors and util . is_gray ( rgba . get_rgb ( ) ) : <EOL> txt . append ( GRAY_COLOR % ( rgba . get_rgb ( ) , rgba . r ) ) <EOL> if "<STR_LIT>" in allowed_colors and util . is_gray ( rgba . get_rgb ( ) ) : <EOL> txt . append ( GRAYA_COLOR_ALPHA % ( rgba . get_rgba ( ) + ( "<STR_LIT>" % dlevel ) , rgba . r , alpha ) ) <EOL> h , l , s = rgba . tohls ( ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( <EOL> HSL_COLOR % ( <EOL> rgba . get_rgb ( ) , <EOL> util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( s * <NUM_LIT> ) , util . fmt_float ( l * <NUM_LIT> ) <EOL> ) <EOL> ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( <EOL> HSLA_COLOR_ALPHA % ( <EOL> rgba . get_rgba ( ) + ( "<STR_LIT>" % dlevel ) , <EOL> util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( s * <NUM_LIT> ) , util . fmt_float ( l * <NUM_LIT> ) , <EOL> alpha <EOL> ) <EOL> ) <EOL> h , w , b = rgba . tohwb ( ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( <EOL> HWB_COLOR % ( <EOL> rgba . get_rgb ( ) , <EOL> util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( w * <NUM_LIT> ) , util . fmt_float ( b * <NUM_LIT> ) <EOL> ) <EOL> ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( <EOL> HWBA_COLOR_ALPHA % ( <EOL> rgba . get_rgba ( ) + ( "<STR_LIT>" % dlevel ) , <EOL> util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( w * <NUM_LIT> ) , util . fmt_float ( b * <NUM_LIT> ) , <EOL> alpha <EOL> ) <EOL> ) <EOL> if secondry_alpha : <EOL> txt . append ( '<STR_LIT>' ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> if use_hex_argb is None or use_hex_argb is False : <EOL> txt . append ( HEXA_COLOR % ( rgba . get_rgb ( ) , rgba . get_rgb ( ) , calc . alpha_hex ) ) <EOL> if use_hex_argb is None or use_hex_argb is True : <EOL> txt . append ( AHEX_COLOR % ( rgba . get_rgb ( ) , '<STR_LIT:#>' , calc . alpha_hex , rgba . get_rgb ( ) [ <NUM_LIT:1> : ] ) ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( <EOL> RGBA_COLOR % ( <EOL> rgba . get_rgb ( ) , <EOL> rgba . r , rgba . g , rgba . b , calc . alpha <EOL> ) <EOL> ) <EOL> if "<STR_LIT>" in allowed_colors and util . is_gray ( rgba . get_rgb ( ) ) : <EOL> txt . append ( GRAYA_COLOR % ( rgba . get_rgb ( ) , rgba . r , calc . alpha ) ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( <EOL> HSLA_COLOR % ( <EOL> rgba . get_rgb ( ) , <EOL> util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( s * <NUM_LIT> ) , util . fmt_float ( l * <NUM_LIT> ) , <EOL> calc . alpha <EOL> ) <EOL> ) <EOL> if "<STR_LIT>" in allowed_colors : <EOL> txt . append ( <EOL> HWBA_COLOR % ( <EOL> rgba . get_rgb ( ) , <EOL> util . fmt_float ( h * <NUM_LIT> ) , util . fmt_float ( w * <NUM_LIT> ) , util . fmt_float ( b * <NUM_LIT> ) , <EOL> calc . alpha <EOL> ) <EOL> ) <EOL> if update : <EOL> md = mdpopups . md2html ( self . view , '<STR_LIT>' . join ( txt ) ) <EOL> mdpopups . update_popup ( <EOL> self . view , <EOL> '<STR_LIT>' % md , <EOL> css = util . ADD_CSS <EOL> ) <EOL> else : <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , True ) <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , self . auto ) <EOL> md = mdpopups . md2html ( self . view , '<STR_LIT>' . join ( txt ) ) <EOL> mdpopups . show_popup ( <EOL> self . view , '<STR_LIT>' % md , <EOL> css = util . ADD_CSS , location = - <NUM_LIT:1> , max_width = <NUM_LIT> , max_height = <NUM_LIT> , <EOL> on_navigate = self . on_navigate , <EOL> on_hide = self . on_hide , <EOL> flags = sublime . COOPERATE_WITH_AUTO_COMPLETE <EOL> ) <EOL> def show_palettes ( self , delete = False , color = None , update = False ) : <EOL> """<STR_LIT>""" <EOL> show_div = False <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> show_global_palettes = s . get ( '<STR_LIT>' , True ) <EOL> show_project_palettes = s . get ( '<STR_LIT>' , True ) <EOL> show_favorite_palette = s . get ( '<STR_LIT>' , True ) <EOL> show_current_palette = s . get ( '<STR_LIT>' , True ) <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> show_picker = s . get ( '<STR_LIT>' , True ) and self . no_info <EOL> html = [ ] <EOL> if ( not self . no_info and not delete ) or color : <EOL> html . append ( BACK_INFO_MENU ) <EOL> elif delete : <EOL> html . append ( BACK_PALETTE_MENU ) <EOL> if show_picker : <EOL> html . append ( PICK_MENU % ( color if color else '<STR_LIT>' ) ) <EOL> if not delete and not color and ( show_global_palettes or show_project_palettes or show_favorite_palette ) : <EOL> html . append ( DELETE_PALETTE_MENU ) <EOL> if delete : <EOL> html . append ( DELETE_PALETTE ) <EOL> if color : <EOL> html . append ( NEW_PALETTE % { '<STR_LIT>' : color } ) <EOL> if show_favorite_palette : <EOL> favs = util . get_favs ( ) <EOL> if len ( favs [ '<STR_LIT>' ] ) or color : <EOL> show_div = True <EOL> html . append ( <EOL> self . format_palettes ( favs [ '<STR_LIT>' ] , favs [ '<STR_LIT:name>' ] , '<STR_LIT>' , delete = delete , color = color ) <EOL> ) <EOL> if show_current_palette : <EOL> current_colors = self . view . settings ( ) . get ( '<STR_LIT>' , [ ] ) <EOL> if not delete and not color and len ( current_colors ) : <EOL> show_div = True <EOL> html . append ( <EOL> self . format_palettes ( current_colors , "<STR_LIT>" , '<STR_LIT>' , delete = delete , color = color ) <EOL> ) <EOL> if show_global_palettes : <EOL> palettes = util . get_palettes ( ) <EOL> if len ( palettes ) and show_div : <EOL> show_div = False <EOL> html . append ( '<STR_LIT>' ) <EOL> for palette in palettes : <EOL> show_div = True <EOL> name = palette . get ( "<STR_LIT:name>" ) <EOL> html . append ( <EOL> self . format_palettes ( <EOL> palette . get ( '<STR_LIT>' , [ ] ) , name , '<STR_LIT>' , palette . get ( '<STR_LIT>' ) , <EOL> delete = delete , <EOL> color = color <EOL> ) <EOL> ) <EOL> if show_project_palettes : <EOL> palettes = util . get_project_palettes ( self . view . window ( ) ) <EOL> if len ( palettes ) and show_div : <EOL> show_div = False <EOL> html . append ( DIVIDER ) <EOL> for palette in palettes : <EOL> name = palette . get ( "<STR_LIT:name>" ) <EOL> html . append ( <EOL> self . format_palettes ( <EOL> palette . get ( '<STR_LIT>' , [ ] ) , name , '<STR_LIT>' , palette . get ( '<STR_LIT>' ) , <EOL> delete = delete , <EOL> color = color <EOL> ) <EOL> ) <EOL> if update : <EOL> md = mdpopups . md2html ( self . view , '<STR_LIT>' . join ( html ) ) <EOL> mdpopups . update_popup ( <EOL> self . view , <EOL> '<STR_LIT>' % md , <EOL> css = util . ADD_CSS <EOL> ) <EOL> else : <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , True ) <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , self . auto ) <EOL> md = mdpopups . md2html ( self . view , '<STR_LIT>' . join ( html ) ) <EOL> mdpopups . show_popup ( <EOL> self . view , '<STR_LIT>' % md , <EOL> css = util . ADD_CSS , location = - <NUM_LIT:1> , max_width = <NUM_LIT> , max_height = <NUM_LIT> , <EOL> on_navigate = self . on_navigate , <EOL> on_hide = self . on_hide , <EOL> flags = sublime . COOPERATE_WITH_AUTO_COMPLETE <EOL> ) <EOL> def show_colors ( self , palette_type , palette_name , delete = False , update = False ) : <EOL> """<STR_LIT>""" <EOL> target = None <EOL> current = False <EOL> if palette_type == "<STR_LIT>" : <EOL> if palette_name == "<STR_LIT>" : <EOL> current = True <EOL> target = { <EOL> "<STR_LIT:name>" : palette_name , <EOL> "<STR_LIT>" : self . view . settings ( ) . get ( '<STR_LIT>' , [ ] ) <EOL> } <EOL> elif palette_name == "<STR_LIT>" : <EOL> data = self . view . window ( ) . project_data ( ) <EOL> current = True <EOL> target = { <EOL> "<STR_LIT:name>" : palette_name , <EOL> "<STR_LIT>" : [ ] if data is None else data . get ( '<STR_LIT>' , [ ] ) <EOL> } <EOL> elif palette_name == "<STR_LIT>" : <EOL> target = util . get_favs ( ) <EOL> elif palette_type == "<STR_LIT>" : <EOL> for palette in util . get_palettes ( ) : <EOL> if palette_name == palette [ '<STR_LIT:name>' ] : <EOL> target = palette <EOL> elif palette_type == "<STR_LIT>" : <EOL> for palette in util . get_project_palettes ( self . view . window ( ) ) : <EOL> if palette_name == palette [ '<STR_LIT:name>' ] : <EOL> target = palette <EOL> if target is not None : <EOL> html = [ ] <EOL> if not delete : <EOL> html . append ( BACK_PALETTE_MENU ) <EOL> if not current : <EOL> html . append ( DELETE_COLOR_MENU % ( palette_type , target [ '<STR_LIT:name>' ] ) ) <EOL> else : <EOL> html . append ( BACK_COLORS_MENU % ( palette_type , target [ '<STR_LIT:name>' ] ) ) <EOL> if delete : <EOL> html . append ( DELETE_COLOR ) <EOL> html . append ( <EOL> self . format_colors ( target [ '<STR_LIT>' ] , target [ '<STR_LIT:name>' ] , palette_type , delete ) <EOL> ) <EOL> if update : <EOL> md = mdpopups . md2html ( self . view , '<STR_LIT>' . join ( html ) ) <EOL> mdpopups . update_popup ( <EOL> self . view , <EOL> '<STR_LIT>' % md , <EOL> css = util . ADD_CSS <EOL> ) <EOL> else : <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , True ) <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , self . auto ) <EOL> md = mdpopups . md2html ( self . view , '<STR_LIT>' . join ( html ) ) <EOL> mdpopups . show_popup ( <EOL> self . view , '<STR_LIT>' % md , <EOL> css = util . ADD_CSS , location = - <NUM_LIT:1> , max_width = <NUM_LIT> , max_height = <NUM_LIT> , <EOL> on_navigate = self . on_navigate , <EOL> on_hide = self . on_hide , <EOL> flags = sublime . COOPERATE_WITH_AUTO_COMPLETE <EOL> ) <EOL> def get_cursor_color ( self ) : <EOL> """<STR_LIT>""" <EOL> color = None <EOL> alpha = None <EOL> alpha_dec = None <EOL> sels = self . view . sel ( ) <EOL> if ( len ( sels ) == <NUM_LIT:1> and sels [ <NUM_LIT:0> ] . size ( ) == <NUM_LIT:0> ) : <EOL> point = sels [ <NUM_LIT:0> ] . begin ( ) <EOL> visible = self . view . visible_region ( ) <EOL> start = point - <NUM_LIT:50> <EOL> end = point + <NUM_LIT:50> <EOL> if start < visible . begin ( ) : <EOL> start = visible . begin ( ) <EOL> if end > visible . end ( ) : <EOL> end = visible . end ( ) <EOL> bfr = self . view . substr ( sublime . Region ( start , end ) ) <EOL> ref = point - start <EOL> rules = util . get_rules ( self . view ) <EOL> use_hex_argb = rules . get ( "<STR_LIT>" , False ) if rules else False <EOL> allowed_colors = rules . get ( '<STR_LIT>' , [ ] ) if rules else util . ALL <EOL> for m in util . COLOR_RE . finditer ( bfr ) : <EOL> if ref >= m . start ( <NUM_LIT:0> ) and ref < m . end ( <NUM_LIT:0> ) : <EOL> if m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and '<STR_LIT>' not in allowed_colors : <EOL> continue <EOL> color , alpha , alpha_dec = util . translate_color ( m , bool ( use_hex_argb ) ) <EOL> break <EOL> return color , alpha , alpha_dec <EOL> def show_color_info ( self , update = False ) : <EOL> """<STR_LIT>""" <EOL> color , alpha , alpha_dec = self . get_cursor_color ( ) <EOL> if color is not None : <EOL> if alpha is not None : <EOL> color += alpha <EOL> html = [ ] <EOL> html . append ( <EOL> self . format_info ( color . lower ( ) , alpha_dec ) <EOL> ) <EOL> if update : <EOL> md = mdpopups . md2html ( self . view , '<STR_LIT>' . join ( html ) ) <EOL> mdpopups . update_popup ( <EOL> self . view , <EOL> '<STR_LIT>' % md , <EOL> css = util . ADD_CSS <EOL> ) <EOL> else : <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , True ) <EOL> self . view . settings ( ) . set ( '<STR_LIT>' , self . auto ) <EOL> md = mdpopups . md2html ( self . view , '<STR_LIT>' . join ( html ) ) <EOL> mdpopups . show_popup ( <EOL> self . view , '<STR_LIT>' % md , <EOL> css = util . ADD_CSS , location = - <NUM_LIT:1> , max_width = <NUM_LIT> , max_height = <NUM_LIT> , <EOL> on_navigate = self . on_navigate , <EOL> on_hide = self . on_hide , <EOL> flags = sublime . COOPERATE_WITH_AUTO_COMPLETE <EOL> ) <EOL> elif update : <EOL> self . view . hide_popup ( ) <EOL> def set_sizes ( self ) : <EOL> """<STR_LIT>""" <EOL> settings = sublime . load_settings ( '<STR_LIT>' ) <EOL> self . graphic_size = settings . get ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> sizes = { <EOL> "<STR_LIT>" : ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> * <NUM_LIT:2> , <NUM_LIT> * <NUM_LIT:6> ) , <EOL> "<STR_LIT>" : ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> * <NUM_LIT:2> , <NUM_LIT> * <NUM_LIT:6> ) , <EOL> "<STR_LIT>" : ( <NUM_LIT:30> , <NUM_LIT:32> , <NUM_LIT:32> * <NUM_LIT:2> , <NUM_LIT:32> * <NUM_LIT:6> ) <EOL> } <EOL> self . color_h , self . color_w , self . preview_h , self . preview_w = sizes . get ( <EOL> self . graphic_size , <EOL> sizes [ "<STR_LIT>" ] <EOL> ) <EOL> def run ( self , edit , mode , palette_name = None , color = None , auto = False ) : <EOL> """<STR_LIT>""" <EOL> self . set_sizes ( ) <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> use_color_picker_package = s . get ( '<STR_LIT>' , False ) <EOL> self . color_picker_package = use_color_picker_package and util . color_picker_available ( ) <EOL> self . no_info = True <EOL> self . no_palette = True <EOL> self . auto = auto <EOL> if mode == "<STR_LIT>" : <EOL> self . no_palette = False <EOL> if palette_name is not None : <EOL> self . show_colors ( palette_name ) <EOL> else : <EOL> self . show_palettes ( ) <EOL> elif mode == "<STR_LIT>" : <EOL> self . no_info = True <EOL> color , alpha = self . get_cursor_color ( ) [ : - <NUM_LIT:1> ] <EOL> if color is not None : <EOL> if alpha is not None : <EOL> color += alpha <EOL> else : <EOL> color = '<STR_LIT>' <EOL> self . color_picker ( color ) <EOL> elif mode == "<STR_LIT>" : <EOL> self . insert_color ( color , picker = True ) <EOL> elif mode == "<STR_LIT:info>" : <EOL> self . no_info = False <EOL> self . no_palette = False <EOL> self . show_color_info ( ) <EOL> def is_enabled ( self , mode , palette_name = None , color = None , auto = False ) : <EOL> """<STR_LIT>""" <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> return bool ( <EOL> ( mode == "<STR_LIT:info>" and self . get_cursor_color ( ) [ <NUM_LIT:0> ] ) or <EOL> ( <EOL> mode == "<STR_LIT>" and ( <EOL> s . get ( '<STR_LIT>' , True ) or <EOL> s . get ( '<STR_LIT>' , True ) or <EOL> s . get ( '<STR_LIT>' , True ) or <EOL> s . get ( '<STR_LIT>' , True ) or <EOL> s . get ( '<STR_LIT>' , True ) <EOL> ) <EOL> ) or <EOL> mode not in ( "<STR_LIT:info>" , "<STR_LIT>" ) <EOL> ) <EOL> class ColorHelperFileIndexCommand ( sublime_plugin . TextCommand ) : <EOL> """<STR_LIT>""" <EOL> def run ( self , edit ) : <EOL> """<STR_LIT>""" <EOL> rules = util . get_rules ( self . view ) <EOL> if rules and util . get_scope ( self . view , rules , skip_sel_check = True ) : <EOL> if ch_file_thread is None or not ch_file_thread . is_alive ( ) : <EOL> start_file_index ( self . view ) <EOL> else : <EOL> sublime . error_message ( "<STR_LIT>" ) <EOL> else : <EOL> sublime . error_message ( '<STR_LIT>' ) <EOL> def is_enabled ( self ) : <EOL> """<STR_LIT>""" <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> return s . get ( '<STR_LIT>' , True ) <EOL> class ColorHelperListener ( sublime_plugin . EventListener ) : <EOL> """<STR_LIT>""" <EOL> def on_selection_modified ( self , view ) : <EOL> """<STR_LIT>""" <EOL> if ch_thread . ignore_all : <EOL> return <EOL> now = time ( ) <EOL> ch_thread . modified = True <EOL> ch_thread . time = now <EOL> on_modified = on_selection_modified <EOL> def set_file_scan_rules ( self , view ) : <EOL> """<STR_LIT>""" <EOL> file_name = view . file_name ( ) <EOL> ext = os . path . splitext ( file_name ) [ <NUM_LIT:1> ] . lower ( ) if file_name is not None else None <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> rules = s . get ( "<STR_LIT>" , [ ] ) <EOL> syntax = os . path . splitext ( view . settings ( ) . get ( '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) ) [ <NUM_LIT:0> ] <EOL> scan_scopes = [ ] <EOL> incomplete_scopes = [ ] <EOL> allowed_colors = set ( ) <EOL> use_hex_argb = False <EOL> compress_hex = False <EOL> for rule in rules : <EOL> results = [ ] <EOL> base_scopes = rule . get ( "<STR_LIT>" , [ ] ) <EOL> if not base_scopes : <EOL> results . append ( True ) <EOL> else : <EOL> results . append ( False ) <EOL> for base in rule . get ( "<STR_LIT>" , [ ] ) : <EOL> if view . score_selector ( <NUM_LIT:0> , base ) : <EOL> results [ - <NUM_LIT:1> ] = True <EOL> break <EOL> syntax_files = rule . get ( "<STR_LIT>" , [ ] ) <EOL> syntax_filter = rule . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> syntax_okay = bool ( <EOL> not syntax_files or ( <EOL> ( syntax_filter == "<STR_LIT>" and syntax in syntax_files ) or <EOL> ( syntax_filter == "<STR_LIT>" and syntax not in syntax_files ) <EOL> ) <EOL> ) <EOL> results . append ( syntax_okay ) <EOL> extensions = [ e . lower ( ) for e in rule . get ( "<STR_LIT>" , [ ] ) ] <EOL> results . append ( True if not extensions or ( ext is not None and ext in extensions ) else False ) <EOL> if False not in results : <EOL> scan_scopes += rule . get ( "<STR_LIT>" , [ ] ) <EOL> incomplete_scopes += rule . get ( "<STR_LIT>" , [ ] ) <EOL> for color in rule . get ( "<STR_LIT>" , [ ] ) : <EOL> if color == "<STR_LIT>" : <EOL> for c in util . CSS3 : <EOL> allowed_colors . add ( c ) <EOL> elif color == "<STR_LIT>" : <EOL> for c in util . CSS4 : <EOL> allowed_colors . add ( c ) <EOL> elif color == "<STR_LIT:all>" : <EOL> for c in util . ALL : <EOL> allowed_colors . add ( c ) <EOL> else : <EOL> allowed_colors . add ( color ) <EOL> if not use_hex_argb and rule . get ( "<STR_LIT>" , False ) : <EOL> use_hex_argb = True <EOL> if not compress_hex and rule . get ( "<STR_LIT>" , False ) : <EOL> compress_hex = True <EOL> if scan_scopes or incomplete_scopes : <EOL> view . settings ( ) . set ( <EOL> '<STR_LIT>' , <EOL> { <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : scan_scopes , <EOL> "<STR_LIT>" : incomplete_scopes , <EOL> "<STR_LIT>" : list ( allowed_colors ) , <EOL> "<STR_LIT>" : use_hex_argb , <EOL> "<STR_LIT>" : compress_hex , <EOL> "<STR_LIT>" : ext , <EOL> "<STR_LIT>" : syntax , <EOL> "<STR_LIT>" : ch_last_updated <EOL> } <EOL> ) <EOL> else : <EOL> view . settings ( ) . set ( <EOL> '<STR_LIT>' , <EOL> { <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT>" : ext , <EOL> "<STR_LIT>" : syntax , <EOL> "<STR_LIT>" : ch_last_updated <EOL> } <EOL> ) <EOL> view . settings ( ) . set ( '<STR_LIT>' , [ ] ) <EOL> def should_update ( self , view ) : <EOL> """<STR_LIT>""" <EOL> force_update = False <EOL> color_palette_initialized = view . settings ( ) . get ( '<STR_LIT>' , None ) is not None <EOL> rules = view . settings ( ) . get ( '<STR_LIT>' , None ) <EOL> if not color_palette_initialized : <EOL> force_update = True <EOL> elif rules : <EOL> last_updated = rules . get ( '<STR_LIT>' , None ) <EOL> if last_updated is None or last_updated < ch_last_updated : <EOL> force_update = True <EOL> file_name = view . file_name ( ) <EOL> ext = os . path . splitext ( file_name ) [ <NUM_LIT:1> ] . lower ( ) if file_name is not None else None <EOL> old_ext = rules . get ( '<STR_LIT>' ) <EOL> if ext is None or ext == old_ext : <EOL> force_update = True <EOL> syntax = os . path . splitext ( view . settings ( ) . get ( '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) ) [ <NUM_LIT:0> ] <EOL> old_syntax = rules . get ( "<STR_LIT>" ) <EOL> if old_syntax is None or old_syntax != syntax : <EOL> force_update = True <EOL> else : <EOL> force_update = True <EOL> return force_update <EOL> def on_activated ( self , view ) : <EOL> """<STR_LIT>""" <EOL> if self . should_update ( view ) : <EOL> self . set_file_scan_rules ( view ) <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> show_current_palette = s . get ( '<STR_LIT>' , True ) <EOL> view . settings ( ) . set ( '<STR_LIT>' , [ ] ) <EOL> if show_current_palette : <EOL> start_file_index ( view ) <EOL> def on_post_save ( self , view ) : <EOL> """<STR_LIT>""" <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> show_current_palette = s . get ( '<STR_LIT>' , True ) <EOL> if self . should_update ( view ) : <EOL> self . set_file_scan_rules ( view ) <EOL> if show_current_palette : <EOL> start_file_index ( view ) <EOL> def on_clone ( self , view ) : <EOL> """<STR_LIT>""" <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> show_current_palette = s . get ( '<STR_LIT>' , True ) <EOL> if show_current_palette : <EOL> start_file_index ( view ) <EOL> class ChFileIndexThread ( threading . Thread ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , view , source , allowed_colors , use_hex_argb ) : <EOL> """<STR_LIT>""" <EOL> self . abort = False <EOL> self . view = view <EOL> self . use_hex_argb = use_hex_argb <EOL> self . allowed_colors = set ( allowed_colors ) if not isinstance ( allowed_colors , set ) else allowed_colors <EOL> self . webcolor_names = re . compile ( <EOL> r'<STR_LIT>' % '<STR_LIT:|>' . join ( <EOL> [ name for name in csscolors . name2hex_map . keys ( ) ] <EOL> ) <EOL> ) <EOL> self . source = source <EOL> threading . Thread . __init__ ( self ) <EOL> def update_index ( self , view , colors ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> colors . sort ( ) <EOL> view . settings ( ) . set ( '<STR_LIT>' , colors ) <EOL> util . debug ( '<STR_LIT>' , colors ) <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> if s . get ( '<STR_LIT>' , True ) : <EOL> sublime . status_message ( '<STR_LIT>' ) <EOL> except Exception : <EOL> pass <EOL> def kill ( self ) : <EOL> """<STR_LIT>""" <EOL> self . abort = True <EOL> while self . is_alive ( ) : <EOL> pass <EOL> def run ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . source : <EOL> self . index_colors ( ) <EOL> def color_okay ( self , color_type ) : <EOL> """<STR_LIT>""" <EOL> return color_type in self . allowed_colors <EOL> def index_colors ( self ) : <EOL> """<STR_LIT>""" <EOL> colors = set ( ) <EOL> for m in util . COLOR_RE . finditer ( self . source ) : <EOL> if self . abort : <EOL> break <EOL> if m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> elif m . group ( '<STR_LIT>' ) and not self . color_okay ( '<STR_LIT>' ) : <EOL> continue <EOL> color , alpha , alpha_dec = util . translate_color ( m , self . use_hex_argb ) <EOL> color += alpha if alpha is not None else '<STR_LIT>' <EOL> if not color . lower ( ) . endswith ( '<STR_LIT>' ) : <EOL> parts = alpha_dec . split ( '<STR_LIT:.>' ) <EOL> dlevel = len ( parts [ <NUM_LIT:1> ] ) if len ( parts ) > <NUM_LIT:1> else None <EOL> if dlevel is not None : <EOL> color += '<STR_LIT>' % dlevel <EOL> colors . add ( color ) <EOL> if self . color_okay ( '<STR_LIT>' ) : <EOL> for m in self . webcolor_names . finditer ( self . source ) : <EOL> if self . abort : <EOL> break <EOL> colors . add ( csscolors . name2hex ( m . group ( <NUM_LIT:0> ) ) ) <EOL> if not self . abort : <EOL> sublime . set_timeout ( <EOL> lambda view = self . view , colors = list ( colors ) : self . update_index ( view , colors ) , <NUM_LIT:0> <EOL> ) <EOL> class ChThread ( threading . Thread ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . reset ( ) <EOL> threading . Thread . __init__ ( self ) <EOL> def reset ( self ) : <EOL> """<STR_LIT>""" <EOL> self . wait_time = <NUM_LIT> <EOL> self . time = time ( ) <EOL> self . modified = False <EOL> self . ignore_all = False <EOL> self . abort = False <EOL> self . save_palettes = False <EOL> def color_okay ( self , allowed_colors , color_type ) : <EOL> """<STR_LIT>""" <EOL> return color_type in allowed_colors <EOL> def payload ( self ) : <EOL> """<STR_LIT>""" <EOL> self . modified = False <EOL> self . ignore_all = True <EOL> window = sublime . active_window ( ) <EOL> view = window . active_view ( ) <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> auto_popup = s . get ( '<STR_LIT>' , True ) <EOL> if view is not None and auto_popup : <EOL> info = False <EOL> execute = False <EOL> sels = view . sel ( ) <EOL> rules = util . get_rules ( view ) <EOL> scope = util . get_scope ( view , rules ) <EOL> insert_scope = util . get_scope_completion ( view , rules ) <EOL> scope_okay = ( <EOL> scope and <EOL> len ( sels ) == <NUM_LIT:1> and sels [ <NUM_LIT:0> ] . size ( ) == <NUM_LIT:0> and <EOL> view . score_selector ( sels [ <NUM_LIT:0> ] . begin ( ) , scope ) <EOL> ) <EOL> insert_scope_okay = ( <EOL> scope_okay or ( <EOL> insert_scope and <EOL> len ( sels ) == <NUM_LIT:1> and sels [ <NUM_LIT:0> ] . size ( ) == <NUM_LIT:0> and <EOL> view . score_selector ( sels [ <NUM_LIT:0> ] . begin ( ) , insert_scope ) <EOL> ) <EOL> ) <EOL> if scope_okay or insert_scope_okay : <EOL> allowed_colors = rules . get ( '<STR_LIT>' , [ ] ) <EOL> point = sels [ <NUM_LIT:0> ] . begin ( ) <EOL> visible = view . visible_region ( ) <EOL> start = point - <NUM_LIT:50> <EOL> end = point + <NUM_LIT:50> <EOL> if start < visible . begin ( ) : <EOL> start = visible . begin ( ) <EOL> if end > visible . end ( ) : <EOL> end = visible . end ( ) <EOL> bfr = view . substr ( sublime . Region ( start , end ) ) <EOL> ref = point - start <EOL> for m in util . COLOR_ALL_RE . finditer ( bfr ) : <EOL> if ref >= m . start ( <NUM_LIT:0> ) and ref < m . end ( <NUM_LIT:0> ) : <EOL> if ( <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) <EOL> ) : <EOL> info = True <EOL> execute = True <EOL> break <EOL> elif ref == m . end ( <NUM_LIT:0> ) : <EOL> if ( <EOL> ( <EOL> m . group ( '<STR_LIT>' ) and ( <EOL> self . color_okay ( allowed_colors , '<STR_LIT>' ) or <EOL> self . color_okay ( allowed_colors , '<STR_LIT>' ) or <EOL> self . color_okay ( allowed_colors , '<STR_LIT>' ) or <EOL> self . color_okay ( allowed_colors , '<STR_LIT>' ) <EOL> ) <EOL> ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( m . group ( '<STR_LIT>' ) and self . color_okay ( allowed_colors , '<STR_LIT>' ) ) or <EOL> ( <EOL> m . group ( '<STR_LIT>' ) and <EOL> ( <EOL> self . color_okay ( allowed_colors , '<STR_LIT>' ) or <EOL> self . color_okay ( allowed_colors , '<STR_LIT>' ) <EOL> ) <EOL> ) or <EOL> ( <EOL> m . group ( '<STR_LIT>' ) and ( <EOL> self . color_okay ( allowed_colors , '<STR_LIT>' ) or <EOL> self . color_okay ( allowed_colors , '<STR_LIT>' ) <EOL> ) <EOL> ) <EOL> ) : <EOL> execute = True <EOL> break <EOL> if execute : <EOL> view . run_command ( '<STR_LIT>' , { "<STR_LIT>" : "<STR_LIT>" if not info else "<STR_LIT:info>" , "<STR_LIT>" : True } ) <EOL> if ( <EOL> not execute and <EOL> view . settings ( ) . get ( '<STR_LIT>' , False ) and <EOL> view . settings ( ) . get ( '<STR_LIT>' , False ) <EOL> ) : <EOL> mdpopups . hide_popup ( view ) <EOL> self . ignore_all = False <EOL> self . time = time ( ) <EOL> def kill ( self ) : <EOL> """<STR_LIT>""" <EOL> self . abort = True <EOL> while self . is_alive ( ) : <EOL> pass <EOL> self . reset ( ) <EOL> def run ( self ) : <EOL> """<STR_LIT>""" <EOL> while not self . abort : <EOL> if self . modified is True and time ( ) - self . time > self . wait_time : <EOL> sublime . set_timeout ( lambda : self . payload ( ) , <NUM_LIT:0> ) <EOL> sleep ( <NUM_LIT:0.5> ) <EOL> def settings_reload ( ) : <EOL> """<STR_LIT>""" <EOL> global ch_last_updated <EOL> ch_last_updated = time ( ) <EOL> def init_plugin ( ) : <EOL> """<STR_LIT>""" <EOL> global ch_settings <EOL> global ch_thread <EOL> global ch_file_thread <EOL> global ch_last_updated <EOL> ch_settings = sublime . load_settings ( '<STR_LIT>' ) <EOL> ch_settings . clear_on_change ( '<STR_LIT>' ) <EOL> ch_settings . add_on_change ( '<STR_LIT>' , settings_reload ) <EOL> settings_reload ( ) <EOL> if ch_thread is not None : <EOL> ch_thread . kill ( ) <EOL> ch_thread = ChThread ( ) <EOL> ch_thread . start ( ) <EOL> def plugin_loaded ( ) : <EOL> """<STR_LIT>""" <EOL> init_plugin ( ) <EOL> def plugin_unloaded ( ) : <EOL> """<STR_LIT>""" <EOL> ch_thread . kill ( ) <EOL> if ch_file_thread is not None : <EOL> ch_file_thread . kill ( ) </s>
