@@ -135,7 +135,7 @@ function! padre#debugger#Debug(...)
135135endfunction
136136
137137function ! padre#debugger#Run ()
138- call padre#socket#Send ({" cmd" : " run" }, function (' padre#debugger#RunCallback ' ))
138+ call padre#socket#Send ({" cmd" : " run" }, function (' padre#debugger#GenericCallback ' ))
139139endfunction
140140
141141function ! padre#debugger#Stop ()
@@ -161,7 +161,7 @@ function! padre#debugger#Stop()
161161endfunction
162162
163163function ! s: SetBreakpointInDebugger (line , file )
164- call padre#socket#Send ({" cmd" : " breakpoint" , " file" : a: file , " line" : str2nr (a: line )}, function (' padre#debugger#BreakpointCallback ' ))
164+ call padre#socket#Send ({" cmd" : " breakpoint" , " file" : a: file , " line" : str2nr (a: line )}, function (' padre#debugger#GenericCallback ' ))
165165endfunction
166166
167167function ! padre#debugger#Breakpoint ()
@@ -173,19 +173,19 @@ function! padre#debugger#Breakpoint()
173173endfunction
174174
175175function ! padre#debugger#StepIn ()
176- call padre#socket#Send ({" cmd" : " stepIn" }, function (' padre#debugger#StepInCallback ' ))
176+ call padre#socket#Send ({" cmd" : " stepIn" }, function (' padre#debugger#GenericCallback ' ))
177177endfunction
178178
179179function ! padre#debugger#StepOver ()
180- call padre#socket#Send ({" cmd" : " stepOver" }, function (' padre#debugger#StepOverCallback ' ))
180+ call padre#socket#Send ({" cmd" : " stepOver" }, function (' padre#debugger#GenericCallback ' ))
181181endfunction
182182
183183function ! padre#debugger#PrintVariable (variable)
184184 call padre#socket#Send ({" cmd" : " print" , " variable" : a: variable }, function (' padre#debugger#PrintVariableCallback' ))
185185endfunction
186186
187187function ! padre#debugger#Continue ()
188- call padre#socket#Send ({" cmd" : " continue" }, function (' padre#debugger#ContinueCallback ' ))
188+ call padre#socket#Send ({" cmd" : " continue" }, function (' padre#debugger#GenericCallback ' ))
189189endfunction
190190
191191" """""""""""""""
@@ -198,63 +198,12 @@ function! padre#debugger#SignalPADREStarted()
198198 endfor
199199endfunction
200200
201- function ! padre#debugger#RunCallback (channel_id, data)
202- if a: data [' status' ] != ' OK'
203- call padre#debugger#Log (2 , ' Error: ' . string (a: data ))
204- return
205- endif
206-
207- if has_key (a: data , ' pid' )
208- call padre#debugger#Log (4 , ' Process ' . a: data [' pid' ] . ' Running' )
209- endif
210- endfunction
211-
212- function ! padre#debugger#BreakpointCallback (channel_id, data)
213- if a: data [' status' ] == ' OK'
214- elseif a: data [' status' ] == ' PENDING'
215- call padre#debugger#Log (4 , ' Breakpoint pending' )
216- else
217- call padre#debugger#Log (2 , ' Error: ' . string (a: data ))
218- endif
219- endfunction
220-
221- function ! padre#debugger#BreakpointSet (fileName, lineNum)
222- let l: msg = ' Breakpoint set file=' . a: fileName . ' , line=' . a: lineNum
223- call padre#debugger#Log (4 , l: msg )
224- endfunction
225-
226- function ! padre#debugger#StepInCallback (channel_id, data)
201+ function ! padre#debugger#GenericCallback (channel_id, data)
227202 if a: data [' status' ] != ' OK'
228203 call padre#debugger#Log (2 , ' Error: ' . string (a: data ))
229204 endif
230205endfunction
231206
232- function ! padre#debugger#StepOverCallback (channel_id, data)
233- if a: data [' status' ] != ' OK'
234- call padre#debugger#Log (2 , ' Error: ' . string (a: data ))
235- endif
236- endfunction
237-
238- function ! padre#debugger#ContinueCallback (channel_id, data)
239- if a: data [' status' ] != ' OK'
240- call padre#debugger#Log (2 , ' Error: ' . string (a: data ))
241- endif
242- endfunction
243-
244- function ! padre#debugger#PrintVariableCallback (channel_id, data)
245- let l: status = remove (a: data , ' status' )
246- if l: status != ' OK'
247- call padre#debugger#Log (2 , ' Error printing variable: ' . string (a: data ))
248- return
249- endif
250-
251- let l: variable_name = remove (a: data , ' variable' )
252-
253- execute " let l:json = system('python -m json.tool', '" . substitute (json_encode (a: data ), " '" , " ''" , " g" ) . " ')"
254- let l: msg = ' Variable ' . l: variable_name . " =\n " . l: json
255- call padre#debugger#Log (4 , l: msg )
256- endfunction
257-
258207function ! padre#debugger#JumpToPosition (file , line )
259208 let l: msg = ' Stopped file=' . a: file . ' line=' . a: line
260209 call padre#debugger#Log (4 , l: msg )
@@ -304,8 +253,35 @@ function! padre#debugger#JumpToPosition(file, line)
304253 redraw
305254endfunction
306255
307- function ! padre#debugger#ProcessExited (exit_code, pid)
308- call padre#debugger#Log (4 , ' Process ' . a: pid . ' finished with exit code=' . a: exit_code )
256+ function ! padre#debugger#PrintVariableCallback (channel_id, data)
257+ if a: data [' status' ] != ' OK'
258+ call padre#debugger#Log (2 , ' Error: ' . string (a: data ))
259+ endif
260+
261+ let s: text = ' Variable (' . a: data [' type' ] . ' ) ' . a: data [' variable' ] . ' =' . a: data [' value' ]
262+
263+ let l: current_tabpagenr = tabpagenr ()
264+
265+ call padre#layout#OpenTabWithBuffer (' PADRE_Logs_' . s: PadreNumber )
266+
267+ let l: current_window = winnr ()
268+ let l: logs_window = padre#layout#GetLogsWindow ()
269+
270+ if l: current_window != l: logs_window
271+ execute l: logs_window . ' wincmd w'
272+ endif
273+
274+ call padre#buffer#AppendBuffer (strftime (' %y/%m/%d %H:%M:%S ' ) . s: text , 0 )
275+
276+ if l: current_window != l: logs_window
277+ execute l: current_window . ' wincmd w'
278+ endif
279+
280+ if l: current_tabpagenr != tabpagenr ()
281+ execute l: current_tabpagenr . ' tabnext'
282+ endif
283+
284+ redraw
309285endfunction
310286
311287function ! padre#debugger#Log (level , text)
0 commit comments