Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'origin/master' into release

  • Loading branch information...
commit 5c94dec09b80b8632ed8e1340871874ba2f6b672 2 parents 1ba1a94 + 8729b17
@wuub wuub authored
View
16 Default (Linux).sublime-keymap
@@ -18,12 +18,12 @@
]
},
- { "keys": ["f2", "s"], "command": "repl_transfer_current", "args": {"scope": "selection"}},
- { "keys": ["shift+f2", "s"], "command": "repl_transfer_current", "args": {"scope": "selection", "action":"view_write"}},
- { "keys": ["f2", "f"], "command": "repl_transfer_current", "args": {"scope": "file"}},
- { "keys": ["shift+f2", "f"], "command": "repl_transfer_current", "args": {"scope": "file", "action":"view_write"}},
- { "keys": ["f2", "l"], "command": "repl_transfer_current", "args": {"scope": "lines"}},
- { "keys": ["shift+f2", "l"], "command": "repl_transfer_current", "args": {"scope": "lines", "action":"view_write"}},
- { "keys": ["f2", "b"], "command": "repl_transfer_current", "args": {"scope": "block"}},
- { "keys": ["shift+f2", "b"], "command": "repl_transfer_current", "args": {"scope": "block", "action":"view_write"}}
+ //{ "keys": ["f2", "s"], "command": "repl_transfer_current", "args": {"scope": "selection"}},
+ //{ "keys": ["shift+f2", "s"], "command": "repl_transfer_current", "args": {"scope": "selection", "action":"view_write"}},
+ //{ "keys": ["f2", "f"], "command": "repl_transfer_current", "args": {"scope": "file"}},
+ //{ "keys": ["shift+f2", "f"], "command": "repl_transfer_current", "args": {"scope": "file", "action":"view_write"}},
+ //{ "keys": ["f2", "l"], "command": "repl_transfer_current", "args": {"scope": "lines"}},
+ //{ "keys": ["shift+f2", "l"], "command": "repl_transfer_current", "args": {"scope": "lines", "action":"view_write"}},
+ //{ "keys": ["f2", "b"], "command": "repl_transfer_current", "args": {"scope": "block"}},
+ //{ "keys": ["shift+f2", "b"], "command": "repl_transfer_current", "args": {"scope": "block", "action":"view_write"}}
]
View
39 Main.sublime-menu
@@ -0,0 +1,39 @@
+[
+ {
+ "caption": "Preferences",
+ "mnemonic": "n",
+ "id": "preferences",
+ "children":
+ [
+ {
+ "caption": "Package Settings",
+ "mnemonic": "P",
+ "id": "package-settings",
+ "children":
+ [
+ {
+ "caption": "SublimeREPL",
+ "children":
+ [
+ {
+ "command": "open_file", "args":
+ {
+ "file": "${packages}/SublimeREPL/SublimeREPL.sublime-settings"
+ },
+ "caption": "Settings – Default"
+ },
+ {
+ "command": "open_file", "args":
+ {
+ "file": "${packages}/User/SublimeREPL.sublime-settings"
+ },
+ "caption": "Settings – User"
+ },
+ { "caption": "-" }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+]
View
5 README.creole
@@ -27,7 +27,10 @@ It is also periodically tested on OSX 10.6.8 and Debian 6.0.2.
== Installation
-Drop SublimeREPL into your Packages directory and you're set.
+Use Package Control.
+
+*DON'T* install directly from Github unless you want to do some development.
+However if you wish to manually place SublimeREPL inside your Packages, please use one of the tagged versions instead of most recent code.
== Documentation
View
2  SublimeREPL (OSX).sublime-settings
@@ -1,4 +1,4 @@
{
-
+ // Add to PATH /usr/local/bin by default on OSX.
"default_extend_env": {"PATH": "{PATH}:/usr/local/bin"}
}
View
12 SublimeREPL.sublime-settings
@@ -1,5 +1,17 @@
{
+ // default_extend_env are used to augment any environment variables
+ // that should be visible for all subporcess repls launched within
+ // SublimeREPL. This is a very good place to add PATH extension
+ // once "PATH": "{PATH}:/home/username/mylocalinstalls/bin" or whatever
"default_extend_env": {},
+
+ // Persistent history is stored per REPL external_id, it means that all python
+ // REPLS will share history. If you wish you can disable history altogether
"presistent_history_enabled": true,
+
+ // By default SublimeREPL leaves REPL view open once the underlying subprocess
+ // dies or closes connection. This is useful when the process dies for an unexpected
+ // reason as it allows you to inspect it output. If you want. Setting this
+ // to true will cause SublimreREPL to close view once the process died.
"view_auto_close": false
}
View
4 config/NodeJS/Main.sublime-menu
@@ -15,7 +15,9 @@
"args": {
"type": "subprocess",
"encoding": "utf8",
- "cmd": ["node", "${packages}/SublimeREPL/config/NodeJS/repl.js"],
+ "cmd": {"linux": ["node", "${packages}/SublimeREPL/config/NodeJS/repl.js"],
+ "osx": ["node", "${packages}/SublimeREPL/config/NodeJS/repl.js"],
+ "windows": ["node.exe", "${packages}/SublimeREPL/config/NodeJS/repl.js"]},
"cwd": "$file_path",
"syntax": "Packages/JavaScript/JavaScript.tmLanguage",
"external_id": "node"
View
1  config/R/Main.sublime-menu
@@ -16,6 +16,7 @@
"type": "subprocess",
"external_id": "r",
"encoding": "utf8",
+ "soft_quit": "\nquit(save=\"no\")\n",
"cmd": {"linux": ["R", "--interactive", "--no-readline"],
"osx": ["R", "--interactive", "--no-readline"],
"windows": ["Rterm.exe", "--ess"]},
View
BIN  doc/_static/menu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  doc/_static/palette.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  doc/conf.py
@@ -50,7 +50,7 @@
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
-release = '1.0.15'
+release = '1.0.30'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
View
28 doc/index.rst
@@ -6,20 +6,38 @@
SublimeREPL
===========
-SublimeREPL is a plugin for Sublime Text 2 that adds a way to run interactive
-interpreters of several languages within a normal editor tab. It also allows
+SublimeREPL is a plugin for Sublime Text 2 that lets tou run interactive
+interpreters of several languages within a normal tab. It also allows
connecting to a remote interpreter (e.g. Clojure/Lein) though a telnet port.
SublimeREPL has a built-in support for command history and transferring code from
-open buffers to the interpreter for evaluation.
-
+open buffers to the interpreters for evaluation.
Installation
------------
+Download `Package Control`__, select Install Package and pick SublimeREPL from the list of
+available packages.
+
+__ http://wbond.net/sublime_packages/package_control
+
+
Quick Start
-----------
+SublimeREPL adds itself as a submenu in Tools. You can choose any one of the preconfigured REPLs and
+if it's available in your SYSTEM PATH [#]_, it will be launched immediately.
+
+.. image:: _static/menu.png
+
+Second and more user friendly way to launch any given REPL is through Command Palette. Bring up Command Palette and type "repl". You will be presented
+with all preconfigured REPLs. Running REPL through Command Palette has exactly the same result as picking it from *Tools > SublimeREPL* menu.
+
+.. image:: _static/palette.png
+
+.. [#] One of the most frequently reported errors is SublimeREPL not being able to find interpreter executable, even if it's visible in your shell. There are several way to fix this problem that we'll discuss in FAQ.
+
+
Keyboard Shortcuts
------------------
@@ -29,6 +47,8 @@ Language specific information
Configuration
-------------
+Frequently Asked Questions
+--------------------------
View
1  gitready.bat
@@ -0,0 +1 @@
+hg bookmark -r default master -f
View
3  killableprocess/__init__.py
@@ -0,0 +1,3 @@
+from killableprocess import Popen, mswindows
+if mswindows:
+ from winprocess import STARTUPINFO, STARTF_USESHOWWINDOW
View
224 killableprocess/killableprocess.py
@@ -0,0 +1,224 @@
+# killableprocess - subprocesses which can be reliably killed
+#
+# Parts of this module are copied from the subprocess.py file contained
+# in the Python distribution.
+#
+# Copyright (c) 2003-2004 by Peter Astrand <astrand@lysator.liu.se>
+#
+# Additions and modifications written by Benjamin Smedberg
+# <benjamin@smedbergs.us> are Copyright (c) 2006 by the Mozilla Foundation
+# <http://www.mozilla.org/>
+#
+# By obtaining, using, and/or copying this software and/or its
+# associated documentation, you agree that you have read, understood,
+# and will comply with the following terms and conditions:
+#
+# Permission to use, copy, modify, and distribute this software and
+# its associated documentation for any purpose and without fee is
+# hereby granted, provided that the above copyright notice appears in
+# all copies, and that both that copyright notice and this permission
+# notice appear in supporting documentation, and that the name of the
+# author not be used in advertising or publicity pertaining to
+# distribution of the software without specific, written prior
+# permission.
+#
+# THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+r"""killableprocess - Subprocesses which can be reliably killed
+
+This module is a subclass of the builtin "subprocess" module. It allows
+processes that launch subprocesses to be reliably killed on Windows (via the Popen.kill() method.
+
+It also adds a timeout argument to Wait() for a limited period of time before
+forcefully killing the process.
+
+Note: On Windows, this module requires Windows 2000 or higher (no support for
+Windows 95, 98, or NT 4.0). It also requires ctypes, which is bundled with
+Python 2.5+ or available from http://python.net/crew/theller/ctypes/
+"""
+
+import subprocess
+import sys
+import os
+import time
+import types
+
+try:
+ from subprocess import CalledProcessError
+except ImportError:
+ # Python 2.4 doesn't implement CalledProcessError
+ class CalledProcessError(Exception):
+ """This exception is raised when a process run by check_call() returns
+ a non-zero exit status. The exit status will be stored in the
+ returncode attribute."""
+ def __init__(self, returncode, cmd):
+ self.returncode = returncode
+ self.cmd = cmd
+ def __str__(self):
+ return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
+
+mswindows = (sys.platform == "win32")
+
+if mswindows:
+ import winprocess
+else:
+ import signal
+
+def call(*args, **kwargs):
+ waitargs = {}
+ if "timeout" in kwargs:
+ waitargs["timeout"] = kwargs.pop("timeout")
+
+ return Popen(*args, **kwargs).wait(**waitargs)
+
+def check_call(*args, **kwargs):
+ """Call a program with an optional timeout. If the program has a non-zero
+ exit status, raises a CalledProcessError."""
+
+ retcode = call(*args, **kwargs)
+ if retcode:
+ cmd = kwargs.get("args")
+ if cmd is None:
+ cmd = args[0]
+ raise CalledProcessError(retcode, cmd)
+
+if not mswindows:
+ def DoNothing(*args):
+ pass
+
+class Popen(subprocess.Popen):
+ if not mswindows:
+ # Override __init__ to set a preexec_fn
+ def __init__(self, *args, **kwargs):
+ if len(args) >= 7:
+ raise Exception("Arguments preexec_fn and after must be passed by keyword.")
+
+ real_preexec_fn = kwargs.pop("preexec_fn", None)
+ def setpgid_preexec_fn():
+ os.setpgid(0, 0)
+ if real_preexec_fn:
+ apply(real_preexec_fn)
+
+ kwargs['preexec_fn'] = setpgid_preexec_fn
+
+ subprocess.Popen.__init__(self, *args, **kwargs)
+
+ if mswindows:
+ def _execute_child(self, args, executable, preexec_fn, close_fds,
+ cwd, env, universal_newlines, startupinfo,
+ creationflags, shell,
+ p2cread, p2cwrite,
+ c2pread, c2pwrite,
+ errread, errwrite):
+ if not isinstance(args, types.StringTypes):
+ args = subprocess.list2cmdline(args)
+
+ if startupinfo is None:
+ startupinfo = winprocess.STARTUPINFO()
+
+ if None not in (p2cread, c2pwrite, errwrite):
+ startupinfo.dwFlags |= winprocess.STARTF_USESTDHANDLES
+
+ startupinfo.hStdInput = int(p2cread)
+ startupinfo.hStdOutput = int(c2pwrite)
+ startupinfo.hStdError = int(errwrite)
+ if shell:
+ startupinfo.dwFlags |= winprocess.STARTF_USESHOWWINDOW
+ startupinfo.wShowWindow = winprocess.SW_HIDE
+ comspec = os.environ.get("COMSPEC", "cmd.exe")
+ args = comspec + " /c " + args
+
+ # We create a new job for this process, so that we can kill
+ # the process and any sub-processes
+ self._job = winprocess.CreateJobObject()
+
+ creationflags |= winprocess.CREATE_SUSPENDED
+ creationflags |= winprocess.CREATE_UNICODE_ENVIRONMENT
+
+ hp, ht, pid, tid = winprocess.CreateProcess(
+ executable, args,
+ None, None, # No special security
+ 1, # Must inherit handles!
+ creationflags,
+ winprocess.EnvironmentBlock(env),
+ cwd, startupinfo)
+
+ self._child_created = True
+ self._handle = hp
+ self._thread = ht
+ self.pid = pid
+
+ winprocess.AssignProcessToJobObject(self._job, hp)
+ winprocess.ResumeThread(ht)
+
+ if p2cread is not None:
+ p2cread.Close()
+ if c2pwrite is not None:
+ c2pwrite.Close()
+ if errwrite is not None:
+ errwrite.Close()
+
+ def kill(self, group=True):
+ """Kill the process. If group=True, all sub-processes will also be killed."""
+ if mswindows:
+ if group:
+ winprocess.TerminateJobObject(self._job, 127)
+ else:
+ winprocess.TerminateProcess(self._handle, 127)
+ self.returncode = 127
+ else:
+ if group:
+ os.killpg(self.pid, signal.SIGKILL)
+ else:
+ os.kill(self.pid, signal.SIGKILL)
+ self.returncode = -9
+
+ def wait(self, timeout=-1, group=True):
+ """Wait for the process to terminate. Returns returncode attribute.
+ If timeout seconds are reached and the process has not terminated,
+ it will be forcefully killed. If timeout is -1, wait will not
+ time out."""
+
+ if self.returncode is not None:
+ return self.returncode
+
+ if mswindows:
+ if timeout != -1:
+ timeout = timeout * 1000
+ rc = winprocess.WaitForSingleObject(self._handle, timeout)
+ if rc == winprocess.WAIT_TIMEOUT:
+ self.kill(group)
+ else:
+ self.returncode = winprocess.GetExitCodeProcess(self._handle)
+ else:
+ if timeout == -1:
+ subprocess.Popen.wait(self)
+ return self.returncode
+
+ starttime = time.time()
+
+ # Make sure there is a signal handler for SIGCHLD installed
+ oldsignal = signal.signal(signal.SIGCHLD, DoNothing)
+
+ while time.time() < starttime + timeout - 0.01:
+ pid, sts = os.waitpid(self.pid, os.WNOHANG)
+ if pid != 0:
+ self._handle_exitstatus(sts)
+ signal.signal(signal.SIGCHLD, oldsignal)
+ return self.returncode
+
+ # time.sleep is interrupted by signals (good!)
+ newtimeout = timeout - time.time() + starttime
+ time.sleep(newtimeout)
+
+ self.kill(group)
+ signal.signal(signal.SIGCHLD, oldsignal)
+ subprocess.Popen.wait(self)
+
+ return self.returncode
View
262 killableprocess/winprocess.py
@@ -0,0 +1,262 @@
+# A module to expose various thread/process/job related structures and
+# methods from kernel32
+#
+# The MIT License
+#
+# Copyright (c) 2006 the Mozilla Foundation <http://www.mozilla.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+from ctypes import c_void_p, POINTER, sizeof, Structure, windll, WinError, WINFUNCTYPE
+from ctypes.wintypes import BOOL, BYTE, DWORD, HANDLE, LPCWSTR, LPWSTR, UINT, WORD
+
+LPVOID = c_void_p
+LPBYTE = POINTER(BYTE)
+LPDWORD = POINTER(DWORD)
+
+def ErrCheckBool(result, func, args):
+ """errcheck function for Windows functions that return a BOOL True
+ on success"""
+ if not result:
+ raise WinError()
+ return args
+
+# CloseHandle()
+
+CloseHandleProto = WINFUNCTYPE(BOOL, HANDLE)
+CloseHandle = CloseHandleProto(("CloseHandle", windll.kernel32))
+CloseHandle.errcheck = ErrCheckBool
+
+# AutoHANDLE
+
+class AutoHANDLE(HANDLE):
+ """Subclass of HANDLE which will call CloseHandle() on deletion."""
+ def Close(self):
+ if self.value:
+ CloseHandle(self)
+ self.value = 0
+
+ def __del__(self):
+ self.Close()
+
+ def __int__(self):
+ return self.value
+
+def ErrCheckHandle(result, func, args):
+ """errcheck function for Windows functions that return a HANDLE."""
+ if not result:
+ raise WinError()
+ return AutoHANDLE(result)
+
+# PROCESS_INFORMATION structure
+
+class PROCESS_INFORMATION(Structure):
+ _fields_ = [("hProcess", HANDLE),
+ ("hThread", HANDLE),
+ ("dwProcessID", DWORD),
+ ("dwThreadID", DWORD)]
+
+ def __init__(self):
+ Structure.__init__(self)
+
+ self.cb = sizeof(self)
+
+LPPROCESS_INFORMATION = POINTER(PROCESS_INFORMATION)
+
+# STARTUPINFO structure
+
+class STARTUPINFO(Structure):
+ _fields_ = [("cb", DWORD),
+ ("lpReserved", LPWSTR),
+ ("lpDesktop", LPWSTR),
+ ("lpTitle", LPWSTR),
+ ("dwX", DWORD),
+ ("dwY", DWORD),
+ ("dwXSize", DWORD),
+ ("dwYSize", DWORD),
+ ("dwXCountChars", DWORD),
+ ("dwYCountChars", DWORD),
+ ("dwFillAttribute", DWORD),
+ ("dwFlags", DWORD),
+ ("wShowWindow", WORD),
+ ("cbReserved2", WORD),
+ ("lpReserved2", LPBYTE),
+ ("hStdInput", HANDLE),
+ ("hStdOutput", HANDLE),
+ ("hStdError", HANDLE)
+ ]
+LPSTARTUPINFO = POINTER(STARTUPINFO)
+
+STARTF_USESHOWWINDOW = 0x01
+STARTF_USESIZE = 0x02
+STARTF_USEPOSITION = 0x04
+STARTF_USECOUNTCHARS = 0x08
+STARTF_USEFILLATTRIBUTE = 0x10
+STARTF_RUNFULLSCREEN = 0x20
+STARTF_FORCEONFEEDBACK = 0x40
+STARTF_FORCEOFFFEEDBACK = 0x80
+STARTF_USESTDHANDLES = 0x100
+
+# EnvironmentBlock
+
+class EnvironmentBlock:
+ """An object which can be passed as the lpEnv parameter of CreateProcess.
+ It is initialized with a dictionary."""
+
+ def __init__(self, dict):
+ if not dict:
+ self._as_parameter_ = None
+ else:
+ values = ["%s=%s" % (key, value)
+ for (key, value) in dict.iteritems()]
+ values.append("")
+ self._as_parameter_ = LPCWSTR("\0".join(values))
+
+# CreateProcess()
+
+CreateProcessProto = WINFUNCTYPE(BOOL, # Return type
+ LPCWSTR, # lpApplicationName
+ LPWSTR, # lpCommandLine
+ LPVOID, # lpProcessAttributes
+ LPVOID, # lpThreadAttributes
+ BOOL, # bInheritHandles
+ DWORD, # dwCreationFlags
+ LPVOID, # lpEnvironment
+ LPCWSTR, # lpCurrentDirectory
+ LPSTARTUPINFO, # lpStartupInfo
+ LPPROCESS_INFORMATION # lpProcessInformation
+ )
+
+CreateProcessFlags = ((1, "lpApplicationName", None),
+ (1, "lpCommandLine"),
+ (1, "lpProcessAttributes", None),
+ (1, "lpThreadAttributes", None),
+ (1, "bInheritHandles", True),
+ (1, "dwCreationFlags", 0),
+ (1, "lpEnvironment", None),
+ (1, "lpCurrentDirectory", None),
+ (1, "lpStartupInfo"),
+ (2, "lpProcessInformation"))
+
+def ErrCheckCreateProcess(result, func, args):
+ ErrCheckBool(result, func, args)
+ # return a tuple (hProcess, hThread, dwProcessID, dwThreadID)
+ pi = args[9]
+ return AutoHANDLE(pi.hProcess), AutoHANDLE(pi.hThread), pi.dwProcessID, pi.dwThreadID
+
+CreateProcess = CreateProcessProto(("CreateProcessW", windll.kernel32),
+ CreateProcessFlags)
+CreateProcess.errcheck = ErrCheckCreateProcess
+
+CREATE_BREAKAWAY_FROM_JOB = 0x01000000
+CREATE_DEFAULT_ERROR_MODE = 0x04000000
+CREATE_NEW_CONSOLE = 0x00000010
+CREATE_NEW_PROCESS_GROUP = 0x00000200
+CREATE_NO_WINDOW = 0x08000000
+CREATE_SUSPENDED = 0x00000004
+CREATE_UNICODE_ENVIRONMENT = 0x00000400
+DEBUG_ONLY_THIS_PROCESS = 0x00000002
+DEBUG_PROCESS = 0x00000001
+DETACHED_PROCESS = 0x00000008
+
+# CreateJobObject()
+
+CreateJobObjectProto = WINFUNCTYPE(HANDLE, # Return type
+ LPVOID, # lpJobAttributes
+ LPCWSTR # lpName
+ )
+
+CreateJobObjectFlags = ((1, "lpJobAttributes", None),
+ (1, "lpName", None))
+
+CreateJobObject = CreateJobObjectProto(("CreateJobObjectW", windll.kernel32),
+ CreateJobObjectFlags)
+CreateJobObject.errcheck = ErrCheckHandle
+
+# AssignProcessToJobObject()
+
+AssignProcessToJobObjectProto = WINFUNCTYPE(BOOL, # Return type
+ HANDLE, # hJob
+ HANDLE # hProcess
+ )
+AssignProcessToJobObjectFlags = ((1, "hJob"),
+ (1, "hProcess"))
+AssignProcessToJobObject = AssignProcessToJobObjectProto(
+ ("AssignProcessToJobObject", windll.kernel32),
+ AssignProcessToJobObjectFlags)
+AssignProcessToJobObject.errcheck = ErrCheckBool
+
+# ResumeThread()
+
+def ErrCheckResumeThread(result, func, args):
+ if result == -1:
+ raise WinError()
+
+ return args
+
+ResumeThreadProto = WINFUNCTYPE(DWORD, # Return type
+ HANDLE # hThread
+ )
+ResumeThreadFlags = ((1, "hThread"),)
+ResumeThread = ResumeThreadProto(("ResumeThread", windll.kernel32),
+ ResumeThreadFlags)
+ResumeThread.errcheck = ErrCheckResumeThread
+
+# TerminateJobObject()
+
+TerminateJobObjectProto = WINFUNCTYPE(BOOL, # Return type
+ HANDLE, # hJob
+ UINT # uExitCode
+ )
+TerminateJobObjectFlags = ((1, "hJob"),
+ (1, "uExitCode", 127))
+TerminateJobObject = TerminateJobObjectProto(
+ ("TerminateJobObject", windll.kernel32),
+ TerminateJobObjectFlags)
+TerminateJobObject.errcheck = ErrCheckBool
+
+# WaitForSingleObject()
+
+WaitForSingleObjectProto = WINFUNCTYPE(DWORD, # Return type
+ HANDLE, # hHandle
+ DWORD, # dwMilliseconds
+ )
+WaitForSingleObjectFlags = ((1, "hHandle"),
+ (1, "dwMilliseconds", -1))
+WaitForSingleObject = WaitForSingleObjectProto(
+ ("WaitForSingleObject", windll.kernel32),
+ WaitForSingleObjectFlags)
+
+INFINITE = -1
+WAIT_TIMEOUT = 0x0102
+WAIT_OBJECT_0 = 0x0
+WAIT_ABANDONED = 0x0080
+
+# GetExitCodeProcess()
+
+GetExitCodeProcessProto = WINFUNCTYPE(BOOL, # Return type
+ HANDLE, # hProcess
+ LPDWORD, # lpExitCode
+ )
+GetExitCodeProcessFlags = ((1, "hProcess"),
+ (2, "lpExitCode"))
+GetExitCodeProcess = GetExitCodeProcessProto(
+ ("GetExitCodeProcess", windll.kernel32),
+ GetExitCodeProcessFlags)
+GetExitCodeProcess.errcheck = ErrCheckBool
View
4 sublimerepl.py
@@ -225,8 +225,10 @@ def user_input(self):
def adjust_end(self):
if self.repl.suppress_echo:
v = self._view
+ vsize = v.size()
+ self._output_end = min(vsize, self._output_end)
edit = v.begin_edit()
- v.erase(edit, sublime.Region(self._output_end, v.size()))
+ v.erase(edit, sublime.Region(self._output_end, vsize))
v.end_edit(edit)
else:
self._output_end = self._view.size()
View
10 subprocess_repl.py
@@ -7,10 +7,12 @@
import os
import repl
import signal
-
+import killableprocess
from sublime import load_settings
+
+
def win_find_executable(executable, env):
"""Explicetely looks for executable in env["PATH"]"""
if os.path.dirname(executable):
@@ -35,7 +37,7 @@ def __init__(self, encoding, external_id=None, cmd_postfix="\n", suppress_echo=F
env = self.env(env, extend_env, settings)
self._cmd = self.cmd(cmd, env)
self._soft_quit = soft_quit
- self.popen = subprocess.Popen(
+ self.popen = killableprocess.Popen(
self._cmd,
startupinfo=self.startupinfo(settings),
creationflags=self.creationflags(settings),
@@ -93,8 +95,8 @@ def interpolate_extend_env(self, env, extend_env):
def startupinfo(self, settings):
startupinfo = None
if os.name == 'nt':
- startupinfo = subprocess.STARTUPINFO()
- startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+ startupinfo = killableprocess.STARTUPINFO()
+ startupinfo.dwFlags |= killableprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow |= 1 # SW_SHOWNORMAL
return startupinfo
Please sign in to comment.
Something went wrong with that request. Please try again.