Permalink
Browse files

Issue #1, #2. Now possible to set a regex filter

  • Loading branch information...
1 parent 444c34e commit 1523d4731d0ae96345978c0852b10c85e5c13547 @quarnster committed Feb 13, 2012
Showing with 32 additions and 7 deletions.
  1. +23 −3 adbview.py
  2. +9 −4 adbview.sublime-commands
View
@@ -24,6 +24,7 @@
import sublime_plugin
import subprocess
import Queue
+import re
import threading
import traceback
@@ -42,6 +43,7 @@ def __init__(self, s=True, settingsprefix=None):
self.doScroll = s
self.view = None
self.settingsprefix = settingsprefix
+ self.filter = re.compile(".")
def is_open(self):
return not self.closed
@@ -52,8 +54,9 @@ def open(self, s=True):
def add_line(self, line):
if self.is_open():
- self.queue.put((ADBView.LINE, line))
- sublime.set_timeout(self.update, 0)
+ if self.filter.search(line) != None:
+ self.queue.put((ADBView.LINE, line))
+ sublime.set_timeout(self.update, 0)
def scroll(self, line):
if self.is_open():
@@ -70,6 +73,12 @@ def clear(self):
self.queue.put((ADBView.CLEAR, None))
sublime.set_timeout(self.update, 0)
+ def set_filter(self, filter):
+ try:
+ self.filter = re.compile(filter)
+ except:
+ sublime.error_message("invalid regex")
+
def create_view(self):
self.view = sublime.active_window().new_file()
self.view.set_name(self.name)
@@ -171,8 +180,19 @@ def run(self):
t.start()
def is_enabled(self):
- return True
+ return not adb_view.is_open()
+
+class AdbSetFilter(sublime_plugin.WindowCommand):
+ def set_filter(self, data):
+ adb_view.clear()
+ adb_view.set_filter(data)
+
+ def run(self):
+ self.window.show_input_panel("ADB Regex filter", adb_view.filter.pattern, self.set_filter, None, None)
+
+ def is_enabled(self):
+ return adb_process != None and adb_view.is_open()
class AdbEventListener(sublime_plugin.EventListener):
def on_close(self, view):
View
@@ -1,6 +1,11 @@
[
-{
- "caption":"launch adb",
- "command": "adb_launch"
-}
+ {
+ "caption":"ADB: Launch",
+ "command": "adb_launch"
+ },
+ {
+ "caption": "ADB: Set Regex filter",
+ "command": "adb_set_filter"
+ }
+
]

0 comments on commit 1523d47

Please sign in to comment.