diff --git a/.hgignore b/.hgignore deleted file mode 100644 index ab016a31..00000000 --- a/.hgignore +++ /dev/null @@ -1,3 +0,0 @@ -syntax: glob -*.pyc -doc/_build/* diff --git a/.no-sublime-package b/.no-sublime-package index 8b137891..e69de29b 100644 --- a/.no-sublime-package +++ b/.no-sublime-package @@ -1 +0,0 @@ - diff --git a/README.md b/README.md index 9588c6e1..acfe059f 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,16 @@ SublimeREPL for SublimeText (2 and 3) ===================================== -IMPORTANT NOTE - DISCLAIMER ---------------------------- - -Due to and uncertain future of SublimeText and its current **abandonware** status (no new releases for several months, no communication with the community, non-existent technical support on disintegrating forums) all of my SublimeText plugins including SublimeREPL are currently **ON HOLD**. I'll reconsider support and development **if and only if** *SublimeHQ* resumes operation that can be considered acceptable for a company licensing a paid software. Until then I'm limiting time spent supporting my ST plugins to the absolute minimum. - - - -[![Stories in Ready](https://badge.waffle.io/wuub/SublimeREPL.png?label=ready)](http://waffle.io/wuub/SublimeREPL) - -If you would like to donate to support SublimeREPL development, you can do so using [GitTip](https://www.gittip.com/wuub/) or [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4DGEPH7QAVHH6&lc=GB&item_name=SublimeREPL¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted). Someone willing to take care of documentation would also be very welcome :-) +SublimeREPL +----------- +Picks up the torch where wuub left off. Features -------- #### Common - * Run an interpreter (REPL) inside SublimeText2 view/tab. + * Run an interpreter (REPL) inside SublimeText view/tab. * Per-language persistent REPL history. * Easily evaluate code in the running REPL * Replace your current build system, and use stdin in your programs. @@ -26,7 +19,7 @@ Features #### Python * Launch python in local or remote(1) virtualenv. * Quickly run selected script or launch PDB. - * Use SublimeText2 Python console with history and multiline input. + * Use SublimeText Python console with history and multiline input. (1) - (ssh, linux/osx only) @@ -50,7 +43,7 @@ Installation 2. Install SublimeREPL 1. `Preferences | Package Control | Package Control: Install Package` 2. Choose `SublimeREPL` -3. Restart SublimeText2 +3. Restart SublimeText 4. Configure `SublimeREPL` (default settings in `Preferences | Package Settings | SublimeREPL | Settings - Default` should be modified in `Preferences | Package Settings | SublimeREPL | Settings - User`, this way they will survive package upgrades! Documentation @@ -82,14 +75,12 @@ then type "SublimeREPL" and select the approperiate language. Note: ctrl+,, f means: press Ctrl and Comma, release all, press F. -License and Price +License ================= Since version 1.2.0 SublimeREPL is licensed under GPL. Previous versions were licensed under BSD. -If you're using SublimeREPL in commercial environment a donation is strongly encouraged ;-) Compatibility ================ SublimeREPL is developed against the latest dev build of SublimeText3. -Ubuntu 13.04 is main diff --git a/config/NodeJS/repl.js b/config/NodeJS/repl.js index fd39e685..d8985475 100644 --- a/config/NodeJS/repl.js +++ b/config/NodeJS/repl.js @@ -1,16 +1,15 @@ (function () { + /* global require, process */ var repl = require('repl'); var rep = repl.start({ - prompt: null, //'> ', - source: null, //process.stdin, - eval: null, //require('vm').runInThisContext, - useGlobal: true, //false + input: process.stdin, + output: process.stdout, + useGlobal: true, useColors: false }); - var net = require('net'); var ac_port = process.env.SUBLIMEREPL_AC_PORT; var client = new net.Socket(); @@ -19,7 +18,7 @@ client.on('data', function(data) { var strData = data.toString(); var index = strData.indexOf(":"); - var json = strData.slice(index+1, strData.length - 1) + var json = strData.slice(index+1, strData.length - 1); var inData = JSON.parse(json); var wordIndex = inData.line.slice(inData.cursor_pos).search(/\b/); if(wordIndex !== 0){ @@ -30,8 +29,8 @@ var comps = completions[0]; var msg = JSON.stringify([inData.line, comps]); var payload = msg.length + ":" + msg + ","; - client.write(payload) - } + client.write(payload); + }; rep.rli.completer(inData.line, send); }); diff --git a/foo.html b/foo.html deleted file mode 100644 index e69de29b..00000000 diff --git a/repls/subprocess_repl.py b/repls/subprocess_repl.py index 78917fc1..9ef619ad 100644 --- a/repls/subprocess_repl.py +++ b/repls/subprocess_repl.py @@ -208,26 +208,40 @@ def name(self): def is_alive(self): return self.popen.poll() is None - def read_bytes(self): + def read_bytes(self, buffer_size=4096): out = self.popen.stdout if POSIX: while True: i, _, _ = select.select([out], [], []) if i: - return out.read(4096) + return out.read(buffer_size) else: - # this is windows specific problem, that you cannot tell if there - # are more bytes ready, so we read only 1 at a times + import ctypes + import msvcrt + kernel32 = ctypes.windll.kernel32 - while True: - byte = self.popen.stdout.read(1) - if byte == b'\r': - # f'in HACK, for \r\n -> \n translation on windows - # I tried universal_endlines but it was pain and misery! :'( - continue - return byte + buffer_size = 1 + bytes_read = bytearray() + #wait for some output synchronously, to not cause infinite loop + bytes_read.extend(out.read(buffer_size)) + #read until end of current output + kernel32.SetNamedPipeHandleState(ctypes.c_void_p(msvcrt.get_osfhandle(out.fileno())), ctypes.byref(ctypes.c_int(1)), None, None) + #'Invalid Argument' means that there are no more bytes left to read + while True: + try: + cur_bytes_read=out.read(buffer_size) + if not cur_bytes_read: + break + bytes_read.extend(cur_bytes_read) + except (OSError, IOError): + break + kernel32.SetNamedPipeHandleState(ctypes.c_void_p(msvcrt.get_osfhandle(out.fileno())), ctypes.byref(ctypes.c_int(0)), None, None) + + # f'in HACK, for \r\n -> \n translation on windows + # I tried universal_endlines but it was pain and misery! :'( + return bytes_read.replace(b'\r\n', b'\n') def write_bytes(self, bytes): si = self.popen.stdin