Permalink
Browse files

Added syntax files for all windows

  • Loading branch information...
1 parent 3acdbcc commit 083bba6449eeb448b3a86e638b5847b8eca64120 @joonty committed Aug 3, 2012
View
@@ -147,8 +147,6 @@ map <Leader>dt :python debugger_command('step_out')<cr>
nnoremap <Leader>e :python debugger_watch_input("eval")<cr>A
vnoremap <Leader>e :python debugger_visual_eval()<cr>A
-nnoremap <cr> :python vdebug.handle_watch_toggle()<cr>
-
map <F5> :python vdebug.run()<cr>
map <F6> :python vdebug.close()<cr>
View
@@ -1,6 +1,7 @@
import xml.etree.ElementTree as ET
import socket
import log
+import base64
""" Response objects for the DBGP module."""
@@ -76,10 +77,20 @@ def get_stack(self):
class ContextGetResponse(Response):
"""Response object used by the context_get command."""
+ properties = []
def get_context(self):
+ for c in self.as_xml().getchildren():
+ self.__create_properties(ContextProperty(c))
+
return self.as_xml().getchildren()
+ def __create_properties(self,property):
+ self.properties.append(property)
+ for p in property.children:
+ self.__create_properties(p)
+
+
class BreakpointSetResponse(Response):
"""Response object returned by the breakpoint_set command."""
@@ -409,11 +420,99 @@ def send_msg(self, cmd):
"""
self.sock.send(cmd + '\0')
-class TimeoutError(Exception):
- pass
+class ContextProperty:
+
+ def __init__(self,node,parent = None,depth = 0):
+ self.parent = parent
+ self.__determine_type(node)
+ self.__determine_displayname(node)
+ self.encoding = node.get('encoding')
+ self.depth = depth
+ self.size = node.get('size')
+ self.value = ""
+ self.is_last_child = False
+
+ self.__determine_children(node)
+
+ if self.encoding == 'base64':
+ if node.text is None:
+ self.value = ""
+ else:
+ self.value = base64.decodestring(node.text)
+ elif not self.is_uninitialized() \
+ and not self.has_children:
+ self.value = node.text
+
+ if self.value is None:
+ self.value = ""
+
+ self.num_crs = self.value.count('\n')
+ if self.type == "string":
+ self.value = '`%s`' % self.value.replace('`','\\`')
+
+ self.__init_children(node)
+
+ def __determine_type(self,node):
+ type = node.get('classname')
+ if type is None:
+ type = node.get('type')
+ self.type = type
+
+ def __determine_displayname(self,node):
+ display_name = node.get('fullname')
+ if display_name == '::':
+ display_name = self.type
+ self.display_name = display_name
+
+ def __determine_children(self,node):
+ children = node.get('children')
+ self.num_declared_children = children
+ if children is None:
+ children = 0
+ else:
+ children = int(children)
+ self.has_children = True if children > 0 else False
+ self.children = []
+
+ def __init_children(self,node):
+ if self.has_children:
+ idx = 0
+ for c in node.getchildren():
+ idx += 1
+ p = ContextProperty(c,self,self.depth+1)
+ self.children.append(p)
+ if idx == self.num_declared_children:
+ p.mark_as_last_child()
+
+ def mark_as_last_child(self):
+ self.is_last_child = True
+
+ def is_uninitialized(self):
+ if self.type == 'uninitialized':
+ return True
+ else:
+ return False
+
+ def child_count(self):
+ return len(self.children)
+
+ def type_and_size(self):
+ size = None
+ if self.has_children:
+ size = self.num_declared_children
+ elif self.size is not None:
+ size = self.size
+
+ if size is None:
+ return self.type
+ else:
+ return "%s [%s]" %(self.type,size)
""" Errors/Exceptions """
+class TimeoutError(Exception):
+ pass
+
class DBGPError(Exception):
"""Raised when the debugger returns an error message."""
View
@@ -32,6 +32,16 @@ def handle_socket_end(self):
self.runner.ui.say("Connection to the debugger has been closed")
self.runner.ui.statuswin.set_status("stopped")
+ def handle_vim_error(self,e):
+ self.runner.ui.error("A Vim error occured: "+\
+ str(e)+\
+ "\n"+ traceback.format_exc())
+
+ def handle_general_exception(self):
+ self.runner.ui.error("An error occured: "+\
+ str(sys.exc_info()[0])+\
+ "\n"+ traceback.format_exc())
+
def run(self):
try:
self.runner.run()
@@ -40,33 +50,23 @@ def run(self):
except EOFError:
self.handle_socket_end()
except vim.error, e:
- self.runner.ui.error(str(e)+"\nTraceback: "+\
- traceback.format_exc())
+ self.handle_vim_error(e)
except:
- self.runner.ui.error("An error occured: "+\
- str(sys.exc_info()[0])+\
- "\nTraceback: "+\
- traceback.format_exc())
- #self.runner.close()
- raise
+ self.handle_general_exception()
- def handle_watch_toggle(self):
+ def handle_return_keypress(self):
try:
- self.runner.handle_watch_toggle()
+ return self.runner.handle_return_keypress()
except dbgp.TimeoutError:
self.handle_timeout()
except EOFError:
self.handle_socket_end()
except vim.error, e:
+ self.handle_vim_error(e)
self.runner.ui.error(str(e)+"\nTraceback: "+\
traceback.format_exc())
except:
- self.runner.ui.error("An error occured: "+\
- str(sys.exc_info()[0])+\
- "\nTraceback: "+\
- traceback.format_exc())
- #self.runner.close()
- raise
+ self.handle_general_exception()
def step_over(self):
try:
@@ -76,13 +76,9 @@ def step_over(self):
except EOFError:
self.handle_socket_end()
except vim.error, e:
- self.runner.ui.error(e)
+ self.handle_vim_error(e)
except:
- self.runner.ui.error("An error occured: "+\
- str(sys.exc_info()[0]))
- #self.runner.close()
- raise
-
+ self.handle_general_exception()
def set_breakpoint(self,args = None):
try:
@@ -94,12 +90,9 @@ def set_breakpoint(self,args = None):
except EOFError:
self.handle_socket_end()
except vim.error, e:
- self.runner.ui.error(e)
+ self.handle_vim_error(e)
except:
- self.runner.ui.error("An error occured: "+\
- str(sys.exc_info()[0]))
- #self.runner.close()
- raise
+ self.handle_general_exception()
def close(self):
self.runner.close()
@@ -168,15 +161,16 @@ def run(self):
if not self.is_alive():
self.open()
else:
- self.ui.sourcewin.remove_pointer()
self.ui.statuswin.set_status("running")
+ self.ui.sourcewin.remove_pointer()
self.api.run()
self.refresh()
def step_over(self):
if not self.is_alive():
self.open()
else:
+ self.ui.statuswin.set_status("running")
self.ui.sourcewin.remove_pointer()
self.api.step_over()
self.refresh()
@@ -192,25 +186,34 @@ def set_breakpoint(self,args):
return
self.breakpoints.add_breakpoint(bp)
- def handle_watch_toggle(self):
- """ Return the number of lines that a property block reaches to."""
- if self.ui.watchwin.name not in vim.current.buffer.name:
- return
- log.Log("Current buffer name: "+vim.current.buffer.name)
+ def handle_return_keypress(self):
+ """ Handle what happens when the user hits return."""
+ if not self.is_alive():
+ return True
lineno = vim.current.window.cursor[0]
- log.Log("Carriage return on line "+str(lineno))
- line = self.ui.watchwin.buffer[lineno-1]
- index = line.find("")
- if index > 0:
- self.handle_open(lineno,line,index)
+ if self.ui.watchwin.name in vim.current.buffer.name:
+ log.Log("Carriage return on line "+str(lineno))
+ line = self.ui.watchwin.buffer[lineno-1]
+ index = line.find("")
+ if index > 0:
+ self.handle_property_get(lineno,line,index)
+ if self.ui.stackwin.name in vim.current.buffer.name:
+ line = self.ui.stackwin.buffer[lineno-1]
+ filename_pos = line.find("\t\t")
+ file_and_line = line[filename_pos:]
+ line_pos = file_and_line.find(":")
+ file = file_and_line[:line_pos]
+ lineno = file_and_line[line_pos+1:]
+ self.ui.sourcewin.set_file(file)
+ self.ui.sourcewin.set_line(lineno)
+
def handle_open(self,lineno,line,pointer_index):
eq_index = line.find('=')
name = line[pointer_index+4:eq_index-1]
context_res = self.api.property_get(name)
rend = ui.vimui.ContextGetResponseRenderer(context_res)
output = rend.render(pointer_index - 1)
- log.Log(output)
self.ui.watchwin.insert(output.rstrip(),lineno-1,True)
def listen(self,server,port,timeout):
Oops, something went wrong.

0 comments on commit 083bba6

Please sign in to comment.