diff --git a/swi.py b/swi.py index 5cec5a9..d012ddd 100644 --- a/swi.py +++ b/swi.py @@ -846,7 +846,7 @@ def run(self, edit): line = 0 if scriptId and line > 0: - v.print_click(edit, v.size(), "%s:%d" % (url, line), lambda: open_script_and_focus_line(scriptId, str(line))) + v.print_click(edit, v.size(), "%s:%d" % (url, line), open_script_and_focus_line, scriptId, str(line)) else: v.insert(edit, v.size(), "%s:%d" % (url, line)) @@ -856,8 +856,7 @@ def run(self, edit): if len(message.parameters) > 0: for param in message.parameters: if param.type == 'object': #if channel here - callback = lambda: channel.send(webkit.Runtime.getProperties(param.objectId, True), console_add_properties, {'objectId': param.objectId}) - v.print_click(edit, v.size(), str(param) + ' ', callback) + v.print_click(edit, v.size(), str(param) + ' ', channel.send, webkit.Runtime.getProperties(param.objectId, True), console_add_properties, {'objectId': param.objectId}) else: v.insert(edit, v.size(), str(param) + ' ') else: @@ -875,8 +874,7 @@ def run(self, edit): v.insert(edit, v.size(), '\t\u21E1 ') if scriptId: - callback = lambda: open_script_and_focus_line(scriptId, str(callFrame.lineNumber)) - v.print_click(edit, v.size(), "%s:%s %s" % (file_name, callFrame.lineNumber, callFrame.functionName), callback) + v.print_click(edit, v.size(), "%s:%s %s" % (file_name, callFrame.lineNumber, callFrame.functionName), open_script_and_focus_line, scriptId, str(callFrame.lineNumber)) else: v.insert(edit, v.size(), "%s:%s %s" % (file_name, callFrame.lineNumber, callFrame.functionName)) @@ -947,8 +945,7 @@ def run(self, edit): v.insert(edit, v.size(), prop.name + ': ') if(prop.value): if prop.value.type == 'object': - callback = lambda: channel.send(webkit.Runtime.getProperties(prop.value.objectId, True), console_add_properties, {'objectId': prop.value.objectId, 'file': file, 'line': line, 'name': prop.name, 'prev': prev}) - v.print_click(edit, v.size(), str(prop.value) + '\n', callback) + v.print_click(edit, v.size(), str(prop.value) + '\n', channel.send, webkit.Runtime.getProperties(prop.value.objectId, True), console_add_properties, {'objectId': prop.value.objectId, 'file': file, 'line': line, 'name': prop.name, 'prev': prev}) else: v.insert(edit, v.size(), str(prop.value) + '\n') @@ -974,13 +971,13 @@ def run(self, edit): v.erase(edit, sublime.Region(0, v.size())) v.insert(edit, v.size(), "\n") - v.print_click(edit, v.size(), " Resume ", lambda: self.view.window().run_command('swi_debug_pause_resume')) + v.print_click(edit, v.size(), " Resume ", self.view.window().run_command, 'swi_debug_pause_resume') v.insert(edit, v.size(), " ") - v.print_click(edit, v.size(), " Step Over ", lambda: self.view.window().run_command('swi_debug_step_over')) + v.print_click(edit, v.size(), " Step Over ", self.view.window().run_command, 'swi_debug_step_over') v.insert(edit, v.size(), " ") - v.print_click(edit, v.size(), " Step Into ", lambda: self.view.window().run_command('swi_debug_step_into')) + v.print_click(edit, v.size(), " Step Into ", self.view.window().run_command, 'swi_debug_step_into') v.insert(edit, v.size(), " ") - v.print_click(edit, v.size(), " Step Out ", lambda: self.view.window().run_command('swi_debug_step_out')) + v.print_click(edit, v.size(), " Step Out ", self.view.window().run_command, 'swi_debug_step_out') v.insert(edit, v.size(), "\n\n") for callFrame in callFrames: @@ -993,7 +990,7 @@ def run(self, edit): file_name = '-' if file_name != '-': - v.print_click(edit, v.size(), "%s:%s" % (file_name, line), lambda: change_to_call_frame(callFrame)) + v.print_click(edit, v.size(), "%s:%s" % (file_name, line), change_to_call_frame, callFrame) else: v.insert(edit, v.size(), "%s:%s" % (file_name, line)) @@ -1002,8 +999,7 @@ def run(self, edit): for scope in callFrame.scopeChain: v.insert(edit, v.size(), "\t") if scope.object.type == 'object': - callback = lambda: channel.send(webkit.Runtime.getProperties(scope.object.objectId, True), console_add_properties, {'objectId': scope.object.objectId, 'name': "%s:%s (%s)" % (file_name, line, scope.type)}) - v.print_click(edit, v.size(), "%s\n" % (scope.type), callback) + v.print_click(edit, v.size(), "%s\n" % (scope.type), channel.send, webkit.Runtime.getProperties(scope.object.objectId, True), console_add_properties, {'objectId': scope.object.objectId, 'name': "%s:%s (%s)" % (file_name, line, scope.type)}) else: v.insert(edit, v.size(), "%s\n" % (scope.type)) diff --git a/views.py b/views.py index 34871c7..a5f2e05 100644 --- a/views.py +++ b/views.py @@ -91,7 +91,7 @@ def rows(self, lines): lines = [lines] return [self.view.rowcol(line.begin())[0] + 1 for line in lines] - def print_click(self, edit, position, text, callback): + def print_click(self, edit, position, text, callback, *args): """ Inserts the specified text and creates a clickable "button" around it. """ @@ -106,7 +106,7 @@ def print_click(self, edit, position, text, callback): break insert_before += 1 - self.callbacks.insert(insert_before, callback) + self.callbacks.insert(insert_before, { "callback": callback, "args": args }) regions.append(new_region) self.view.add_regions('swi_log_clicks', regions, scope=utils.get_setting('interactive_scope'), flags=sublime.DRAW_NO_FILL) @@ -137,7 +137,7 @@ def check_click(self): if index < len(self.callbacks): callback = self.callbacks[index] - callback() + callback["callback"](*callback["args"]) index += 1