forked from vim-vdebug/vdebug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugger_interface.py
More file actions
135 lines (104 loc) · 4.04 KB
/
Copy pathdebugger_interface.py
File metadata and controls
135 lines (104 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import vim
from . import breakpoint
from . import event
from . import opts
from . import session
from . import util
from .ui import vimui
class DebuggerInterface:
"""Provides all methods used to control the debugger."""
def __init__(self):
self.breakpoints = breakpoint.Store()
self.ui = vimui.Ui()
self.session_handler = session.SessionHandler(self.ui,
self.breakpoints)
self.event_dispatcher = event.Dispatcher(self.session_handler)
def __del__(self):
self.session_handler.close()
self.session_handler = None
@staticmethod
def reload_options():
util.Environment.reload()
def reload_keymappings(self):
self.session_handler.dispatch_event("reload_keymappings")
def status(self):
return self.session_handler.status()
def status_for_statusline(self):
return self.session_handler.status_for_statusline()
def start_if_ready(self):
self.session_handler.start_if_ready()
def listen(self):
self.session_handler.listen()
def run(self):
"""Tell the debugger to run, until the next breakpoint or end of script.
"""
self.session_handler.run()
def run_to_cursor(self):
"""Run to the current VIM cursor position.
"""
self.session_handler.dispatch_event("run_to_cursor")
def step_over(self):
"""Step over to the next statement.
"""
self.session_handler.dispatch_event("step_over")
def step_into(self):
"""Step into a statement on the current line.
"""
self.session_handler.dispatch_event("step_into")
def step_out(self):
"""Step out of the current statement.
"""
self.session_handler.dispatch_event("step_out")
def handle_return_keypress(self):
"""React to a <enter> keypress event.
"""
return self.event_dispatcher.by_position(self.session_handler)
def handle_double_click(self):
"""React to a mouse double click event.
"""
return self.event_dispatcher.by_position(self.session_handler)
def handle_visual_eval(self):
"""React to eval during visual selection.
"""
return self.event_dispatcher.visual_eval(self.session_handler)
def handle_eval(self, bang, args):
"""Evaluate a code snippet specified by args.
"""
return self.session_handler.dispatch_event("set_eval_expression",
len(bang) > 0, args)
def handle_trace(self, args=None):
"""Trace a code snippet specified by args.
"""
return self.session_handler.dispatch_event("trace", args)
def eval_under_cursor(self):
"""Evaluate the property under the cursor.
"""
return self.event_dispatcher.eval_under_cursor(self.session_handler)
def mark_window_as_closed(self, window):
self.session_handler.ui().mark_window_as_closed(window)
def toggle_window(self, name):
self.session_handler.ui().toggle_window(name)
def toggle_breakpoint_window(self):
self.session_handler.ui().toggle_window("DebuggerBreakpoints")
def get_last_error(self):
return self.session_handler.ui().get_last_error()
def set_breakpoint(self, args=None):
"""Set a breakpoint, specified by args.
"""
self.session_handler.dispatch_event("set_breakpoint", args)
def remove_breakpoint(self, args=None):
"""Remove one or more breakpoints, specified by args.
"""
self.session_handler.dispatch_event("remove_breakpoint", args)
def get_context(self):
"""Get all the variables in the default context
"""
self.session_handler.dispatch_event("get_context")
def detach(self):
"""Detach the debugger, so the script runs to the end.
"""
self.session_handler.dispatch_event("detach")
def close(self):
"""Close the connection, or the UI if already closed.
"""
self.session_handler.stop()