Skip to content

Commit

Permalink
Merge pull request wuub#60 from icholy/master
Browse files Browse the repository at this point in the history
Filter ascii color codes
  • Loading branch information
wuub committed Jul 27, 2012
2 parents 1ef2a48 + 568db56 commit 88945da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion SublimeREPL.sublime-settings
Expand Up @@ -13,5 +13,9 @@
// 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_auto_close": false,

// Some terminals output ascii color codes which are not curreclty supported
// enable this option to filter them out.
"filter_ascii_color_codes": false
}
12 changes: 11 additions & 1 deletion sublimerepl.py
Expand Up @@ -10,6 +10,7 @@
import repls
import os
import buzhug
import re

repl_views = {}

Expand Down Expand Up @@ -204,11 +205,15 @@ def __init__(self, view, repl, syntax):
self._repl_reader = ReplReader(repl)
self._repl_reader.start()

if self.external_id and sublime.load_settings(SETTINGS_FILE).get("presistent_history_enabled"):
settings = sublime.load_settings(SETTINGS_FILE)

if self.external_id and settings.get("presistent_history_enabled"):
self._history = PersistentHistory(self.external_id)
else:
self._history = MemHistory()
self._history_match = None

self._filter_color_codes = settings.get("filter_ascii_color_codes")

# begin refreshing attached view
self.update_view_loop()
Expand Down Expand Up @@ -240,6 +245,11 @@ def adjust_end(self):

def write(self, unistr):
"""Writes output from Repl into this view."""

# remove color codes
if self._filter_color_codes:
unistr = re.sub(r'\033\[\d*\w', '', unistr)

# string is assumet to be already correctly encoded
v = self._view
edit = v.begin_edit()
Expand Down

0 comments on commit 88945da

Please sign in to comment.