forked from dpo/atom-python-debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreakpoint-store.coffee
More file actions
43 lines (36 loc) · 1.38 KB
/
breakpoint-store.coffee
File metadata and controls
43 lines (36 loc) · 1.38 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
{CompositeDisposable} = require "atom"
module.exports =
class BreakpointStore
constructor: (gutter) ->
@breakpoints = []
toggle: (breakpoint) ->
breakpointSearched = @containsBreakpoint(breakpoint)
addDecoration = true
if breakpointSearched
@breakpoints.splice(@breakpoints.indexOf(breakpointSearched), 1)
addDecoration = false
else
@breakpoints.push(breakpoint)
editor = atom.workspace.getActiveTextEditor()
if addDecoration
marker = editor.markBufferPosition([breakpoint.lineNumber-1, 0])
d = editor.decorateMarker(marker, type: "line-number", class: "line-number-red")
d.setProperties(type: "line-number", class: "line-number-red")
breakpoint.decoration = d
return "b"
else
editor = atom.workspace.getActiveTextEditor()
ds = editor.getLineNumberDecorations(type: "line-number", class: "line-number-red")
for d in ds
marker = d.getMarker()
marker.destroy() if marker.getBufferRange().start.row == breakpoint.lineNumber-1
return "cl"
containsBreakpoint: (bp) ->
for breakpoint in @breakpoints
if breakpoint.filename == bp.filename && breakpoint.lineNumber == bp.lineNumber
return breakpoint
return null
currentBreakpoints: ->
console.log breakpoint for breakpoint in @breakpoints
clear: () ->
@toggle breakpoint for breakpoint in @breakpoints