forked from sgricci/LiveReload-sublimetext2
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathSimpleWSCallback.py
31 lines (24 loc) · 855 Bytes
/
SimpleWSCallback.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import sublime
import sublime_plugin
# fix for import order
sys.path.append(os.path.join(sublime.packages_path(), 'LiveReload'))
LiveReload = __import__('LiveReload')
sys.path.remove(os.path.join(sublime.packages_path(), 'LiveReload'))
##Modlue name must be the same as class or else callbacks won't work
class SimpleWSCallback(LiveReload.Plugin, sublime_plugin.EventListener):
title = 'Send content on change'
description = \
'Send file content to browser console'
file_types = '*'
this_session_only = True
def on_modified_async(self, view):
if self.isEnabled:
region = sublime.Region(0, view.size())
source = view.substr(region)
self.sendRaw("socket", source)
def onReceive(self, data, origin):
print(data)