예제 #1
0
	def run(self, edit, **kw):
		if not eutils.is_css_view(self.view, True):
			return sublime.error_message('You should run this action on CSS file')

		# build sources list
		sources = [view for view in eutils.all_views() if re.search(r'[\/\\]lspatch-[\w\-]+\.json$', view.file_name() or '')]

		# gather all available items
		display_items = []
		patches = []

		def add_item(patch, name):
			for p in patch:
				display_items.append([p['file'], 'Updated selectors: %s' % ', '.join(p['selectors']), name])
				patches.append(json.dumps(p['data']))

		for view in sources:
			add_item(lsutils.diff.parse_patch(eutils.content(view)), view.file_name())

		# check if buffer contains valid patch
		pb =  sublime.get_clipboard()
		if lsutils.diff.is_valid_patch(pb):
			add_item(lsutils.diff.parse_patch(pb), 'Clipboard')

		def on_done(ix):
			if ix == -1: return
			apply_patch_on_view(self.view, patches[ix])

		if len(display_items) == 1:
			on_done(0)
		elif display_items:
			self.view.window().show_quick_panel(display_items, on_done)
		else:
			sublime.error_message('No patches found. You have to open patch files in Sublime Text or copy patch file contents into clipboard and run this action again.')
예제 #2
0
def start_plugin():
	ws.start(int(eutils.get_setting('port')))
	logger.setLevel(logging.DEBUG if eutils.get_setting('debug', False) else logging.INFO)

	# collect all view's file paths
	for view in eutils.all_views():
		_view_file_names[view.id()] = eutils.file_name(view)
예제 #3
0
def start_plugin():
    ws.start(int(eutils.get_setting('port')))
    logger.setLevel(
        logging.DEBUG if eutils.get_setting('debug', False) else logging.INFO)

    # collect all view's file paths
    for view in eutils.all_views():
        _view_file_names[view.id()] = eutils.file_name(view)
예제 #4
0
def start_plugin():
	global settings
	settings = sublime.load_settings('LiveStyle.sublime-settings')
	
	start_server(int(settings.get('port')))
	logger.setLevel(logging.DEBUG if settings.get('debug', False) else logging.INFO)
	settings.add_on_change('settings', handle_settings_change)

	lsutils.diff.import_pyv8()

	# collect all view's file paths
	for view in eutils.all_views():
		_view_file_names[view.id()] = eutils.file_name(view)
예제 #5
0
def start_plugin():
    global settings
    settings = sublime.load_settings('LiveStyle.sublime-settings')

    start_server(int(settings.get('port')))
    logger.setLevel(
        logging.DEBUG if settings.get('debug', False) else logging.INFO)
    settings.add_on_change('settings', handle_settings_change)

    lsutils.diff.import_pyv8()

    # collect all view's file paths
    for view in eutils.all_views():
        _view_file_names[view.id()] = eutils.file_name(view)
예제 #6
0
    def run(self, edit, **kw):
        if not eutils.is_css_view(self.view, True):
            return sublime.error_message(
                'You should run this action on CSS file')

        # build sources list
        sources = [
            view for view in eutils.all_views()
            if re.search(r'[\/\\]lspatch-[\w\-]+\.json$',
                         view.file_name() or '')
        ]

        # gather all available items
        display_items = []
        patches = []

        def add_item(patch, name):
            for p in patch:
                display_items.append([
                    p['file'],
                    'Updated selectors: %s' % ', '.join(p['selectors']), name
                ])
                patches.append(json.dumps(p['data']))

        for view in sources:
            add_item(lsutils.diff.parse_patch(eutils.content(view)),
                     view.file_name())

        # check if buffer contains valid patch
        pb = sublime.get_clipboard()
        if lsutils.diff.is_valid_patch(pb):
            add_item(lsutils.diff.parse_patch(pb), 'Clipboard')

        def on_done(ix):
            if ix == -1: return
            apply_patch_on_view(self.view, patches[ix])

        if len(display_items) == 1:
            on_done(0)
        elif display_items:
            self.view.window().show_quick_panel(display_items, on_done)
        else:
            sublime.error_message(
                'No patches found. You have to open patch files in Sublime Text or copy patch file contents into clipboard and run this action again.'
            )