Exemplo n.º 1
0
def send_unsaved_files(payload, sender):
	files = payload.get('files', [])
	out = []
	for f in files:
		view = eutils.view_for_file(f)
		if not view:
			continue

		content = eutils.content(view)
		if view and view.is_dirty():
			fname = view.file_name()
			pristine = None
			if not fname:
				# untitled file
				pristine = ''
			elif os.path.exists(fname):
				pristine = read_file(fname)

			if pristine is not None:
				out.append({
					'file': f,
					'pristine': pristine,
					'content': content
				})

	if out:
		ws.send({
			'action': 'unsavedFiles',
			'data': {
				'files': out
			}
		}, sender)
	else:
		logger.info('No unsaved changes')
Exemplo n.º 2
0
def _start_diff(buf_id):
    view = eutils.view_for_buffer_id(buf_id)
    if view is None:
        return

    state = _diff_state[buf_id]
    prev_content = state['content']
    content = eutils.content(view)
    syntax = get_syntax(view)

    state['required'] = False

    client = ws.find_client({'supports': 'css'})

    if client:
        logger.debug('Use connected "%s" client for diff' % client.name())
        lock_state(state)
        ws.send(
            {
                'action': 'diff',
                'data': {
                    'file': buf_id,
                    'syntax': syntax,
                    'source1': prev_content,
                    'source2': content
                }
            }, client)
    else:
        logger.error('No suitable client for diff')
Exemplo n.º 3
0
def _start_patch(buf_id, patch):
    view = eutils.view_for_buffer_id(buf_id)
    if view is None:
        logger.debug('No view to patch')
        return

    content = eutils.content(view)
    syntax = get_syntax(view)
    state = _patch_state[buf_id]

    client = ws.find_client({'supports': 'css'})
    logger.debug('Client: %s' % client)

    if client:
        logger.debug('Use connected "%s" client for patching' % client.name())
        lock_state(state)
        ws.send(
            {
                'action': 'patch',
                'data': {
                    'file': buf_id,
                    'syntax': syntax,
                    'patches': patch,
                    'source': content
                }
            }, client)
    else:
        logger.error('No suitable client for patching')
Exemplo n.º 4
0
def send_unsaved_files(payload, sender):
    files = payload.get('files', [])
    out = []
    for f in files:
        view = eutils.view_for_file(f)
        if not view:
            continue

        content = eutils.content(view)
        if view and view.is_dirty():
            fname = view.file_name()
            pristine = None
            if not fname:
                # untitled file
                pristine = ''
            elif os.path.exists(fname):
                pristine = read_file(fname)

        if pristine is not None and pristine != content:
            out.append({'file': f, 'pristine': pristine, 'content': content})

    if out:
        ws.send({'action': 'unsavedFiles', 'data': {'files': out}}, sender)
    else:
        logger.info('No unsaved changes')
Exemplo n.º 5
0
def _start_patch(buf_id, patch):
	view = eutils.view_for_buffer_id(buf_id)
	if view is None:
		logger.debug('No view to patch')
		return

	content = eutils.content(view)
	syntax = get_syntax(view)
	state = _patch_state[buf_id]


	client = ws.find_client({'supports': 'css'})
	logger.debug('Client: %s' % client)

	if client:
		logger.debug('Use connected "%s" client for patching' % client.name())
		lock_state(state)
		ws.send({
			'action': 'patch',
			'data': {
				'file': buf_id,
				'syntax': syntax,
				'patches': patch,
				'source': content
			}
		}, client)
	else:
		logger.error('No suitable client for patching')
Exemplo n.º 6
0
def send_unsaved_files(payload, sender):
    files = payload.get("files", [])
    out = []
    for f in files:
        view = eutils.view_for_file(f)
        if not view:
            continue

        content = eutils.content(view)
        if view and view.is_dirty():
            fname = view.file_name()
            pristine = None
            if not fname:
                # untitled file
                pristine = ""
            elif os.path.exists(fname):
                pristine = read_file(fname)

        if pristine is not None:
            out.append({"file": f, "pristine": pristine, "content": content})

    if out:
        ws.send({"action": "unsavedFiles", "data": {"files": out}}, sender)
    else:
        logger.info("No unsaved changes")
Exemplo n.º 7
0
def _start_diff(buf_id):
	view = eutils.view_for_buffer_id(buf_id)
	if view is None:
		return

	state = _diff_state[buf_id]
	prev_content = state['content']
	content = eutils.content(view)
	syntax = get_syntax(view)

	state['required'] = False

	client = ws.find_client({'supports': 'css'})

	if client:
		logger.debug('Use connected "%s" client for diff' % client.name())
		lock_state(state)
		ws.send({
			'action': 'diff',
			'data': {
				'file': buf_id,
				'syntax': syntax,
				'source1': prev_content,
				'source2': content
			}
		}, client)
	else:
		logger.error('No suitable client for diff')
Exemplo n.º 8
0
def send_patches(buf_id=None, p=None):
    if not buf_id or not p:
        return

    p = eutils.parse_json(p)
    view = eutils.view_for_buffer_id(buf_id)
    if p and view is not None:
        ws.send({"action": "update", "data": {"editorFile": eutils.file_name(view), "patch": p}})
Exemplo n.º 9
0
def identify_editor(socket):
	"Sends editor identification info to browser"
	ws.send({
		'action': 'id',
		'data': {
			'id': 'st%d' % sublime_ver,
			'title': 'Sublime Text %d' % sublime_ver,
			'icon': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABu0lEQVR42q2STWsTURhG3WvdCyq4CEVBAgYCM23JjEwy+cJC41gRdTIEGyELU7BNNMJQhUBBTUjSRdRI3GThRld+gbj2JwhuRFy5cZ3Ncd5LBwZCIIIXDlzmeZ9z4d458t9WoVB4XywWCcnn89i2TSaTIZvNEuRhJvtP0e7R6XT6VYJer8dkMmE0GrHf3uPxg1s8f+TR9ncZDocq63a7SiId6YogBqiPg8FASe43d3iz7/D7rcuP1zf4NnHxfV9yQc0CSFcEeihotVo0Gg22tzbh3SbP7lq4lzTuuHlqtZrkQlSgi8AIBZVKBc/zuH5lnc7tFX4OL/L9wOTJlsbGepFyuSwzUYERCqIXhGVZJJNJbqbP0b66DC8ucO/yedLptMzMF4S3X7JXeFWJ4Zln2LZPw9NT+BuxxQTquaw1Xl47yZ/WEr92j3PgnMBc08nlcvMF1Wo1DNW7G4aBpmnouo5pmtGyzM4K+v0+4/F4ITqdzqzAdV0cxyGVSsmpc5G/s1QqzQg+N5tNdUmJRIJ4PD4XkdTrdaQTClYDlvnHFXTOqu7h5mHAx4AvC/IhYE+6IliK2IwFWT3sHPsL6BnLQ4kfGmsAAAAASUVORK5CYII=',
			'files': eutils.css_files()
		}
	}, socket)
Exemplo n.º 10
0
 def on_post_save(self, view):
     k = view.id()
     new_name = eutils.file_name(view)
     if k in _view_file_names and _view_file_names[k] != new_name:
         ws.send({
             'action': 'renameFile',
             'data': {
                 'oldname': _view_file_names[k],
                 'newname': new_name
             }
         })
         _view_file_names[k] = new_name
Exemplo n.º 11
0
	def on_post_save(self, view):
		k = view.id()
		new_name = eutils.file_name(view)
		if k in _view_file_names and _view_file_names[k] != new_name:
			ws.send({
				'action': 'renameFile',
				'data': {
					'oldname': _view_file_names[k],
					'newname': new_name
				}
			})
			_view_file_names[k] = new_name
Exemplo n.º 12
0
def identify_editor(socket):
    "Sends editor identification info to browser"
    ws.send(
        {
            'action': 'id',
            'data': {
                'id': 'st%d' % sublime_ver,
                'title': 'Sublime Text %d' % sublime_ver,
                'icon':
                'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABu0lEQVR42q2STWsTURhG3WvdCyq4CEVBAgYCM23JjEwy+cJC41gRdTIEGyELU7BNNMJQhUBBTUjSRdRI3GThRld+gbj2JwhuRFy5cZ3Ncd5LBwZCIIIXDlzmeZ9z4d458t9WoVB4XywWCcnn89i2TSaTIZvNEuRhJvtP0e7R6XT6VYJer8dkMmE0GrHf3uPxg1s8f+TR9ncZDocq63a7SiId6YogBqiPg8FASe43d3iz7/D7rcuP1zf4NnHxfV9yQc0CSFcEeihotVo0Gg22tzbh3SbP7lq4lzTuuHlqtZrkQlSgi8AIBZVKBc/zuH5lnc7tFX4OL/L9wOTJlsbGepFyuSwzUYERCqIXhGVZJJNJbqbP0b66DC8ucO/yedLptMzMF4S3X7JXeFWJ4Zln2LZPw9NT+BuxxQTquaw1Xl47yZ/WEr92j3PgnMBc08nlcvMF1Wo1DNW7G4aBpmnouo5pmtGyzM4K+v0+4/F4ITqdzqzAdV0cxyGVSsmpc5G/s1QqzQg+N5tNdUmJRIJ4PD4XkdTrdaQTClYDlvnHFXTOqu7h5mHAx4AvC/IhYE+6IliK2IwFWT3sHPsL6BnLQ4kfGmsAAAAASUVORK5CYII=',
                'files': eutils.css_files()
            }
        }, socket)
Exemplo n.º 13
0
def send_patches(buf_id=None, p=None):
    if not buf_id or not p:
        return

    p = eutils.parse_json(p)
    view = eutils.view_for_buffer_id(buf_id)
    if p and view is not None:
        ws.send({
            'action': 'update',
            'data': {
                'editorFile': eutils.file_name(view),
                'patch': p
            }
        })
Exemplo n.º 14
0
def send_patches(buf_id=None, p=None):
	if not buf_id or not p:
		return

	p = eutils.parse_json(p)
	view = eutils.view_for_buffer_id(buf_id)
	if p and view is not None:
		ws.send({
			'action': 'update',
			'data': {
				'editorFile': eutils.file_name(view),
				'patch': p
			}
		})
Exemplo n.º 15
0
 def on_post_save(self, view):
     k = view.id()
     new_name = eutils.file_name(view)
     if k in _view_file_names and _view_file_names[k] != new_name:
         ws.send({"action": "renameFile", "data": {"oldname": _view_file_names[k], "newname": new_name}})
         _view_file_names[k] = new_name
Exemplo n.º 16
0
def update_files():
    ws.send({'action': 'updateFiles', 'data': eutils.css_files()})
Exemplo n.º 17
0
def update_files():
    ws.send({"action": "updateFiles", "data": eutils.css_files()})
Exemplo n.º 18
0
def update_files():
	ws.send({
		'action': 'updateFiles',
		'data': eutils.css_files()
	})