Skip to content

Commit

Permalink
Fix Issue #7: Entering a command in Windows does nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
jarhart committed Aug 15, 2013
1 parent fae163d commit edcfd55
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion outputmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 13 additions & 2 deletions sbtrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
9 changes: 6 additions & 3 deletions sbtview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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'))
Expand Down

0 comments on commit edcfd55

Please sign in to comment.