forked from kiddkai/atom-node-debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStepButton.coffee
More file actions
55 lines (46 loc) · 1.12 KB
/
Copy pathStepButton.coffee
File metadata and controls
55 lines (46 loc) · 1.12 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
hg = require 'mercury'
{h} = hg
BTN_ICON_MAP = {
'continue': 'icon-playback-play btn btn-primary'
'next': 'icon-chevron-right btn btn-primary'
'out': 'icon-chevron-up btn btn-primary'
'in': 'icon-chevron-down btn btn-primary'
}
BTN_TOOLTIP_MAP = {
'continue': 'resume'
'next': 'step-next'
'in': 'step-in'
'out': 'step-out'
}
exports.StepButton = (_debugger) ->
onNext = (state) ->
type = state.type()
state.waiting(true)
promise = null
if type is 'continue'
promise = _debugger.reqContinue()
else
promise = _debugger.step(type, 1)
promise.then ->
state.waiting(false)
.catch (e) ->
state.waiting(false)
StepButton = (name, type) ->
hg.state({
title: hg.value(name)
type: hg.value(type)
waiting: hg.value(false)
channels: {
next: onNext
}
})
StepButton.render = (state) ->
channels = state.channels()
h 'div', {
'ev-click': hg.send channels.next
'className': BTN_ICON_MAP[state.type()]
'disabled': !state.waiting
'title': BTN_TOOLTIP_MAP[state.type()]
}, [
]
return StepButton