@@ -13,14 +13,15 @@ def set_dc_path(self,p):
13
13
def check_paths (self ):
14
14
if not self .PYTHON or not self .DC_PATH :
15
15
print ("vim-decadence: in your .vimrc, set the locations:" )
16
- print (" let g:decadence_python = '/usr/bin/python2 '" )
16
+ print (" let g:decadence_python = '/usr/bin/python '" )
17
17
print (" let g:decadence_path = '~/bin/decadence/decadence.py'" )
18
18
print ("In the future, this will be automatic." )
19
19
return False
20
20
return True
21
21
22
22
def __init__ (self ):
23
23
self .processes = []
24
+ self .process_buf = {}
24
25
self .playing = False
25
26
self .PYTHON = None
26
27
self .DC_PATH = None
@@ -34,6 +35,7 @@ def stop(self):
34
35
except :
35
36
pass
36
37
term += 1
38
+ self .process_buf = {}
37
39
self .processes = []
38
40
return term
39
41
def refresh (self ):
@@ -45,7 +47,7 @@ def play(self):
45
47
vim .command ('call dc#starttimer()' )
46
48
vim .command ('set cursorline' )
47
49
print ('Playing' )
48
- self . processes . append ( subprocess .Popen ([\
50
+ p = subprocess .Popen ([\
49
51
self .PYTHON ,\
50
52
self .DC_PATH ,\
51
53
'--follow' ,
@@ -54,21 +56,26 @@ def play(self):
54
56
],
55
57
stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
56
58
bufsize = 1 , universal_newlines = True
57
- ))
59
+ )
60
+ self .processes .append (p )
61
+ self .process_buf [p ] = ''
58
62
def playline (self ):
59
63
if not self .check_paths (): return
60
64
self .stop ()
61
- self . processes . append ( subprocess .Popen ([\
65
+ p = subprocess .Popen ([\
62
66
self .PYTHON ,\
63
67
self .DC_PATH ,\
64
68
'-l' ,\
65
69
vim .current .line \
66
- ], stdout = self .DEVNULL , stderr = self .DEVNULL ))
70
+ ], stdout = self .DEVNULL , stderr = self .DEVNULL )
71
+ self .processes .append (p )
72
+ self .process_buf [p ] = ''
67
73
def poll (self ):
68
74
running = 0
69
75
done = False
70
76
active = 0
71
77
for p in self .processes :
78
+ # phash = hash(p)
72
79
working = False
73
80
if p .poll ()== None :
74
81
active += 1
@@ -83,15 +90,21 @@ def poll(self):
83
90
buf = p .stdout .read (1 )
84
91
if not buf :
85
92
break
93
+ pbuf = self .process_buf [p ]
86
94
if buf == '\n ' :
87
- vim .command ('normal! ' + str (buf .count ('\n ' ))+ 'j' )
95
+ # vim.command('normal! '+str(buf.count('\n'))+'j')
96
+ vim .command ('exe ' + str (int (pbuf )+ 1 ))
97
+ self .process_buf [p ] = ''
98
+ else :
99
+ self .process_buf [p ] += buf
88
100
working = True
89
101
if working :
90
102
running += 1
91
103
if not active :
92
104
print ('Stopped' )
93
105
vim .command ('call dc#stoptimer()' )
94
106
vim .command ('set cursorline&' )
107
+ return running
95
108
def reload (self ):
96
109
for i in xrange (2 ): # first 2 lines check for header
97
110
try :
0 commit comments