Skip to content
Browse files

Added context tabs on watch window and mouse support

  • Loading branch information...
1 parent 5b5e969 commit 55d54c27a97d82d370d7801b192208c5021ccfcb @joonty committed Aug 9, 2012
Showing with 94 additions and 28 deletions.
  1. +1 −0 doc/tags
  2. +67 −17 plugin/python/debugger.py
  3. +20 −9 plugin/python/ui/vimui.py
  4. +6 −2 syntax/debugger_watch.vim
View
1 doc/tags
@@ -14,3 +14,4 @@ VdebugSourceWindow Vdebug.txt /*VdebugSourceWindow*
VdebugStart Vdebug.txt /*VdebugStart*
VdebugUI Vdebug.txt /*VdebugUI*
VdebugUsage Vdebug.txt /*VdebugUsage*
+VdebugWatchWindow Vdebug.txt /*VdebugWatchWindow*
View
84 plugin/python/debugger.py
@@ -272,21 +272,24 @@ def refresh(self,status):
stack_res = self.update_stack()
stack = stack_res.get_stack()
- filename = stack[0].get('filename')
- lineno = stack[0].get('lineno')
+ self.cur_filename = stack[0].get('filename')
+ self.cur_lineno = stack[0].get('lineno')
log.Log("Moving to current position in source window")
- self.ui.set_source_position(filename,lineno)
-
- self.ui.watchwin.clean()
- name = self.context_names[0]
- log.Log("Getting %s variables" % name)
- context_res = self.api.context_get()
- rend = ui.vimui.ContextGetResponseRenderer(\
- context_res,"%s at %s:%s" \
- %(name,self.ui.sourcewin.file,lineno),\
- self.context_names)
- self.ui.watchwin.accept_renderer(rend)
+ self.ui.set_source_position(self.cur_filename,self.cur_lineno)
+
+ self.get_context(0)
+
+ def get_context(self,context_id = 0):
+ self.ui.watchwin.clean()
+ name = self.context_names[context_id]
+ log.Log("Getting %s variables" % name)
+ context_res = self.api.context_get(context_id)
+ rend = ui.vimui.ContextGetResponseRenderer(\
+ context_res,"%s at %s:%s" \
+ %(name,self.ui.sourcewin.file,self.cur_lineno),\
+ self.context_names, context_id)
+ self.ui.watchwin.accept_renderer(rend)
def toggle_breakpoint_window(self):
"""Open or close the breakpoint window.
@@ -413,10 +416,14 @@ def handle_return_keypress(self):
log.Log("User action in watch window, line %s" % lineno,\
log.Logger.DEBUG)
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:
+ if lineno == 1:
+ self.handle_context_change(\
+ line,vim.current.window.cursor[1])
+ else:
+ index = line.find("")
+ if index > 0:
+ self.handle_property_get(lineno,line,index)
+ elif self.ui.stackwin.name in vim.current.buffer.name:
log.Log("User action in stack window, line %s" % lineno,\
log.Logger.DEBUG)
line = self.ui.stackwin.buffer[lineno-1]
@@ -428,6 +435,49 @@ def handle_return_keypress(self):
self.ui.sourcewin.set_file(file)
self.ui.sourcewin.set_line(lineno)
+ def handle_context_change(self,line,column):
+ log.Log("Finding context name at column %s" % column,\
+ log.Logger.DEBUG)
+ tab_end_pos = -1
+ tab_start_pos = -1
+
+ line_len = len(line)
+ i = column
+ while i < line_len:
+ if line[i] == ']':
+ tab_end_pos = i-1
+ break
+ i += 1
+ j = column
+ while j >= 0:
+ if line[j] == '[':
+ tab_start_pos = j+2
+ break
+ j -= 1
+ if tab_end_pos == -1 or \
+ tab_start_pos == -1:
+ self.ui.error("Failed to find context name under cursor")
+ return
+ context_name = line[tab_start_pos:tab_end_pos]
+ log.Log("Context name: %s" % context_name,\
+ log.Logger.DEBUG)
+ if context_name[0] == '*':
+ self.ui.say("This context is already showing")
+ return
+ found_id = -1
+ for id in self.context_names.keys():
+ name = self.context_names[id]
+ log.Log(name +", "+context_name)
+ if name == context_name:
+ found_id = id
+ break
+ if found_id == -1:
+ self.ui.error("Could not resolve context name")
+ return
+ else:
+ self.get_context(found_id)
+
+
def handle_property_get(self,lineno,line,pointer_index):
eq_index = line.find('=')
name = line[pointer_index+4:eq_index-1]
View
29 plugin/python/ui/vimui.py
@@ -353,6 +353,8 @@ def on_create(self):
':python vdebug.handle_return_keypress()<cr>')
self.command('nnoremap <buffer> <cr> '+\
':python vdebug.handle_return_keypress()<cr>')
+ self.command('nnoremap <buffer> <2-LeftMouse> '+\
+ ':python vdebug.handle_return_keypress()<cr>')
self.command('setlocal syntax=debugger_stack')
if self.creation_count == 1:
cmd = 'silent! au BufWinLeave %s :silent! bdelete %s' %(self.name,self.name)
@@ -369,6 +371,8 @@ def on_create(self):
':python vdebug.handle_return_keypress()<cr>')
self.command('nnoremap <buffer> <cr> '+\
':python vdebug.handle_return_keypress()<cr>')
+ self.command('nnoremap <buffer> <2-LeftMouse> '+\
+ ':python vdebug.handle_return_keypress()<cr>')
self.command('setlocal syntax=debugger_watch')
if self.creation_count == 1:
cmd = 'silent! au BufWinLeave %s :silent! bdelete %s' %(self.name,self.name)
@@ -415,22 +419,19 @@ def render(self):
class ContextGetResponseRenderer(ResponseRenderer):
- def __init__(self,response,title = None,contexts = {}):
+ def __init__(self,response,title = None,contexts = {},current_context = 0):
ResponseRenderer.__init__(self,response)
self.title = title
self.contexts = contexts
+ self.current_context = current_context
def render(self,indent = 0):
- res = ""
- if self.contexts:
- for id,name in self.contexts.iteritems():
- res += "| %-14s" % name
- res += "|\n"
- res += ("=" * 16 ) * len(self.contexts) + "=\n"
+ res = self.__create_tabs()
+
if self.title:
- res += "[ %s ]\n\n" % self.title
+ res += "- %s\n\n" % self.title
+
properties = self.response.get_context()
-
num_props = len(properties)
log.Log("Writing %i properties to the context window" % num_props,\
log.Logger.INFO )
@@ -447,6 +448,16 @@ def render(self,indent = 0):
return res
+ def __create_tabs(self):
+ res = ""
+ if self.contexts:
+ for id,name in self.contexts.iteritems():
+ if self.current_context == id:
+ name = "*"+name
+ res += "[ %s ] " % name
+ res += "\n\n"
+ return res
+
def __render_property(self,p,next_p,last = False,indent = 0):
line = "%(indent)s %(marker)s %(name)s = (%(type)s) %(value)s\n" \
%{'indent':"".rjust((p.depth * 2)+indent),\
View
8 syntax/debugger_watch.vim
@@ -7,7 +7,10 @@ if exists("b:current_syntax")
finish
endif
-syn region debuggerWatchTitle start=+^\[+ end=+\s\]$+
+syn match debuggerWatchTabLine '^\s\[.*$' contains=debuggerWatchTab
+syn match debuggerWatchTab '\[\s[^\]]\+\s\]' contains=debuggerWatchTabSel
+syn match debuggerWatchTabSel '\*[a-zA-Z\s]\+' contained
+syn match debuggerWatchTitle '^\-\s[A-Z].\+'
syn match debuggerWatchMarker '^\s\+[^|\/]'
syn match debuggerWatchJoiner '^\s\+[|\/^]'
syn match debuggerWatchNumber '\d\+\.\=\d*'
@@ -23,11 +26,12 @@ syn region debuggerWatchString start=+\s`+ skip=+\\`+ end=+`\s*$+
hi def link debuggerWatchTitle Title
hi def link debuggerWatchMarker Special
+hi def link debuggerWatchTab Special
+hi def link debuggerWatchTabSel Todo
hi def link debuggerWatchTypeContainer Type
hi def link debuggerWatchType Type
hi def link debuggerWatchString String
hi def link debuggerWatchStringKey String
-"hi def link debuggerWatchObjectProperty PreProc
hi def link debuggerWatchVarName Identifier
hi def link debuggerWatchJoiner Structure
hi def link debuggerWatchNumber Number

0 comments on commit 55d54c2

Please sign in to comment.
Something went wrong with that request. Please try again.