From edcfd55e19ce6bbdb2f34c95cb42abe1270102ec Mon Sep 17 00:00:00 2001 From: Jason Arhart Date: Thu, 15 Aug 2013 15:34:41 -0700 Subject: [PATCH] Fix Issue #7: Entering a command in Windows does nothing --- outputmon.py | 2 +- sbtrunner.py | 15 +++++++++++++-- sbtview.py | 9 ++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/outputmon.py b/outputmon.py index b60156b..3e4c52b 100644 --- a/outputmon.py +++ b/outputmon.py @@ -34,7 +34,7 @@ def _start_parsing(self, line): return parser def _strip_terminal_codes(self, line): - return re.sub(r'\033\[[0-9;]+m', '', line) + return re.sub(r'\033(?:M|\[[0-9;]+[mK])', '', line) class OutputParser(object): diff --git a/sbtrunner.py b/sbtrunner.py index 9c01b71..c105937 100644 --- a/sbtrunner.py +++ b/sbtrunner.py @@ -127,7 +127,9 @@ class SbtUnixProcess(SbtProcess): @classmethod def _popen(cls, cmdline, **kwargs): cmd = ' '.join(map(pipes.quote, cmdline)) - return subprocess.Popen(['/bin/bash', '-lc', cmd], preexec_fn=os.setpgrp, **kwargs) + return subprocess.Popen(['/bin/bash', '-lc', cmd], + preexec_fn=os.setpgrp, + **kwargs) def terminate(self): os.killpg(self._proc.pid, signal.SIGTERM) @@ -138,9 +140,18 @@ def kill(self): class SbtWindowsProcess(SbtProcess): + SBT_OPTS = '-Djline.terminal=jline.UnsupportedTerminal' + @classmethod def _popen(cls, cmdline, **kwargs): - return subprocess.Popen(cmdline, shell=True, **kwargs) + return subprocess.Popen(cmdline, + shell=True, + env=cls._sbt_env(), + **kwargs) + + @classmethod + def _sbt_env(cls): + return dict(list(os.environ.items()) + [['SBT_OPTS', cls.SBT_OPTS]]) def terminate(self): self.kill() diff --git a/sbtview.py b/sbtview.py index f755878..f83a240 100644 --- a/sbtview.py +++ b/sbtview.py @@ -74,7 +74,10 @@ def clear_output(self): def take_input(self): input_region = sublime.Region(self._output_size, self.panel.size()) input = self.panel.substr(input_region) - self._erase_output(input_region) + if sublime.platform() == 'windows': + self._append_output('\n') + else: + self._erase_output(input_region) return input def delete_left(self): @@ -124,10 +127,10 @@ def _clean_output(self, output): return self._strip_codes(self._normalize_lines(output)) def _normalize_lines(self, output): - return output.replace('\r\n', '\n').replace('\033M\033[2K', '\r') + return output.replace('\r\n', '\n').replace('\033M', '\r') def _strip_codes(self, output): - return re.sub('\\033\[[0-9;]+m', '', output) + return re.sub(r'\033\[[0-9;]+[mK]', '', output) def _update_panel_colors(self): self.panel.settings().set('color_scheme', self.settings.get('color_scheme'))