1
1
import collections
2
2
import os
3
- import sublime
4
3
import threading
5
4
6
5
7
6
class OutputPanel :
8
-
9
7
def __init__ (
10
- self , name , file_regex = '' , line_regex = '' , base_dir = None ,
11
- word_wrap = False , line_numbers = False , gutter = False ,
12
- scroll_past_end = False
8
+ self ,
9
+ window ,
10
+ name ,
11
+ file_regex = "" ,
12
+ line_regex = "" ,
13
+ base_dir = None ,
14
+ word_wrap = False ,
15
+ line_numbers = False ,
16
+ gutter = False ,
17
+ scroll_past_end = False ,
13
18
):
14
19
self .name = name
15
- self .window = sublime . active_window ()
16
- self .output_view = self . window .get_output_panel (name )
20
+ self .window = window
21
+ self .output_view = window .create_output_panel (name )
17
22
18
23
# default to the current file directory
19
- if not base_dir and self .window .active_view () and \
20
- self .window .active_view ().file_name ():
21
- base_dir = os .path .dirname (self .window .active_view ().file_name ())
24
+ if not base_dir :
25
+ view = window .active_view ()
26
+ if view :
27
+ file_name = view .file_name ()
28
+ if file_name :
29
+ base_dir = os .path .dirname (file_name )
22
30
23
31
settings = self .output_view .settings ()
24
32
settings .set ("result_file_regex" , file_regex )
@@ -29,7 +37,9 @@ def __init__(
29
37
settings .set ("gutter" , gutter )
30
38
settings .set ("scroll_past_end" , scroll_past_end )
31
39
32
- self .output_view .assign_syntax ("Packages/UnitTesting/res/unit-testing-test-result.sublime-syntax" )
40
+ # make sure to apply settings
41
+ self .output_view = window .create_output_panel (name )
42
+ self .output_view .assign_syntax ("unit-testing-test-result.sublime-syntax" )
33
43
self .output_view .set_read_only (True )
34
44
self .closed = False
35
45
@@ -44,15 +54,12 @@ def writeln(self, s):
44
54
self .write (s + "\n " )
45
55
46
56
def _write (self ):
57
+ text = ""
47
58
with self .text_queue_lock :
48
- text = ''
49
59
while self .text_queue :
50
60
text += self .text_queue .popleft ()
51
61
52
- self .output_view .run_command (
53
- 'append' ,
54
- {'characters' : text , 'force' : True }
55
- )
62
+ self .output_view .run_command ("append" , {"characters" : text , "force" : True })
56
63
self .output_view .show (self .output_view .size ())
57
64
58
65
def flush (self ):
0 commit comments