コード例 #1
0
 def run_emmet_action(action, contrib):
     ctx = Context(files=[os.path.join(BASE_PATH, 'editor.js')],
                   ext_path=EXT_PATH,
                   contrib=contrib)
     with ctx.js() as c:
         c.locals.pySetupEditorProxy()
         c.locals.pyRunAction(action)
コード例 #2
0
def init():
	"Init Emmet plugin"
	# load settings
	globals()['user_settings'] = sublime.load_settings('Preferences.sublime-settings')
	globals()['settings'] = sublime.load_settings('Emmet.sublime-settings')
	settings.add_on_change('extensions_path', update_settings)

	# setup environment for PyV8 loading
	pyv8_paths = [
		os.path.join(PACKAGES_PATH, 'PyV8'),
		os.path.join(PACKAGES_PATH, 'PyV8', pyv8loader.get_arch()),
		os.path.join(PACKAGES_PATH, 'PyV8', 'pyv8-%s' % pyv8loader.get_arch())
	]

	sys.path += pyv8_paths

	# unpack recently loaded binary, is exists
	for p in pyv8_paths:
		pyv8loader.unpack_pyv8(p)
	
	# provide some contributions to JS
	contrib = {
		'sublime': sublime, 
		'sublimeReplaceSubstring': replace_substring,
		'sublimeGetOption': settings.get
	}

	# create JS environment
	delegate = SublimeLoaderDelegate()
	globals()['ctx'] = Context(
		files=['../editor.js'], 
		ext_path=get_extensions_path(), 
		contrib=contrib, 
		logger=delegate.log,
		reader=js_file_reader
	)

	update_settings()

	if not settings.get('disable_pyv8_update', False):
		pyv8loader.load(pyv8_paths[1], delegate) 
	else:
		print('PyV8 auto-update is disabled')

	if settings.get('remove_html_completions', False):
		sublime.set_timeout(cmpl.remove_html_completions, 2000)
コード例 #3
0
	ctx.reset()
	ctx.load_user_data(json.dumps(payload))

# load settings
settings = sublime.load_settings('Emmet.sublime-settings')
settings.add_on_change('extensions_path', update_settings)

# provide some contributions to JS
contrib = {
	'sublime': sublime, 
	'sublimeReplaceSubstring': replace_substring
}

# create JS environment
ctx = Context(['../editor.js'], settings.get('extensions_path', None), contrib)

update_settings()

sublime.set_timeout(cmpl.remove_html_completions, 2000)

class RunEmmetAction(sublime_plugin.TextCommand):
	def run(self, edit, action=None, **kw):
		run_action(lambda i, sel: ctx.js().locals.pyRunAction(action))
		# ctx.js().locals.pyRunAction(action)

def run_action(action, view=None):
	"Runs Emmet action in multiselection mode"
	if not view:
		view = active_view()
コード例 #4
0
    return False


# load settings
settings = sublime.load_settings('Emmet.sublime-settings')
settings.add_on_change('extensions_path', update_settings)

# provide some contributions to JS
contrib = {'sublime': sublime, 'sublimeReplaceSubstring': replace_substring}

# create JS environment
delegate = SublimeLoaderDelegate()
ctx = Context(['../editor.js'],
              settings.get('extensions_path', None),
              contrib,
              pyv8_path=os.path.join(sublime.packages_path(), 'PyV8'),
              delegate=delegate)

update_settings()

if settings.get('remove_html_completions', False):
    sublime.set_timeout(cmpl.remove_html_completions, 2000)


def log(message):
    if settings.get('debug', False):
        print('Emmet: %s' % message)


class RunEmmetAction(sublime_plugin.TextCommand):
コード例 #5
0
    return len(text)


# provide some contributions to JS
contrib = {
    'notepad': Npp.notepad,
    'console': Npp.console,
    'editor': Npp.editor,
    'Npp': Npp,
    'ctb': char_to_byte,
    'btc': byte_to_char
}

# create JS environment
ctx = Context(files=[os.path.join(BASE_PATH, 'editor.js')],
              ext_path=EXT_PATH,
              contrib=contrib,
              logger=lambda msg: Npp.console.write('%s\n' % msg))


def run_action(name):
    lang = str(Npp.notepad.getLangType()).lower()
    ctx.js().locals.pySetupEditorProxy(lang)
    return ctx.js().locals.pyRunAction(name)


def expand_abbreviation(is_tab=False):
    e = Npp.editor
    if is_tab and len(e.getSelText()):
        return e.tab()

    result = run_action('expand_abbreviation')
コード例 #6
0
 def run_emmet_action(action, contrib):
     ctx = Context(files=[os.path.join(BASE_PATH, 'editor.js')], ext_path=EXT_PATH, contrib=contrib)
     with ctx.js() as c:
         c.locals.pySetupEditorProxy()
         c.locals.pyRunAction(action)