Skip to content

Commit afb4fe5

Browse files
authored
Merge pull request #256 from JunoLab/sp/debugtweaks
debugger tweaks
2 parents 67bad57 + 605ba90 commit afb4fe5

File tree

4 files changed

+94
-5
lines changed

4 files changed

+94
-5
lines changed

lib/debugger/debugger-pane.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { CompositeDisposable, TextEditor } from 'atom'
88
import PaneItem from '../util/pane-item'
99
import { open } from '../util/opener'
1010
import views from '../util/views'
11-
import { DebuggerToolbar } from './toolbar'
11+
import { DebuggerToolbar, buttonView } from './toolbar'
1212

1313
// pane for side-to-side view of compiled code and source code
1414
export default class DebuggerPane extends PaneItem {
@@ -23,7 +23,7 @@ export default class DebuggerPane extends PaneItem {
2323
DebuggerPane.subs.dispose()
2424
}
2525

26-
constructor (stepper, breakpointManager, buttons=[]) {
26+
constructor (stepper, breakpointManager, buttons=[], startButtons=[]) {
2727
super()
2828

2929
this.subs = new CompositeDisposable()
@@ -32,6 +32,7 @@ export default class DebuggerPane extends PaneItem {
3232
this.breakpointManager = breakpointManager
3333

3434
this.toolbar = new DebuggerToolbar(buttons)
35+
this.startButtons = startButtons
3536

3637
this.stepper.onStep(arg => this.updateStepper(arg))
3738
this.breakpointManager.onUpdate(arg => this.updateBreakpoints(arg))
@@ -107,8 +108,28 @@ export default class DebuggerPane extends PaneItem {
107108
toolbarView () {
108109
const expressionHidden = !this.info.text
109110

111+
let run = () => {
112+
const ed = atom.workspace.getActiveTextEditor()
113+
if (ed) {
114+
atom.commands.dispatch(atom.views.getView(ed), this.refs.runnerSelector.value)
115+
}
116+
}
117+
110118
return <div className="item toolbar">
111119
<div className="inner-toolbar">
120+
<div className="debugger-runner">
121+
<button className="btn icon icon-triangle-right btn-color-success" onclick={run}>
122+
</button>
123+
<select className="input-select" ref="runnerSelector">
124+
{
125+
this.startButtons.map(btn => {
126+
return <option value={btn.command}>
127+
{ btn.text || ''}
128+
</option>
129+
})
130+
}
131+
</select>
132+
</div>
112133
{toView(this.toolbar.view)}
113134
<Tip alt={this.compileModeTip}>
114135
<div className="flex-table-container">

lib/debugger/toolbar.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ export class DebuggerToolbar {
88
this.subs = new CompositeDisposable()
99

1010
let group = document.createElement('div')
11-
group.classList.add('btn-group', 'btn-group-sm')
11+
group.classList.add('btn-group', 'btn-group-sm', 'ink-btn-group-variable-width')
1212
buttons.forEach((b) => group.appendChild(this.buttonView(b)))
1313

1414
this.view = document.createElement('div')
1515
this.view.className = 'ink-debug-toolbar'
1616
this.view.appendChild(group)
1717
}
1818

19-
buttonView ({icon, text, tooltip, command}) {
19+
buttonView ({icon, text, tooltip, command, color}) {
2020
let btn = document.createElement('button')
21-
btn.classList.add('btn', 'btn-primary')
21+
btn.classList.add('btn', 'ink-btn-variable-width')
2222
if (text) btn.innerText = text
2323
if (icon) btn.classList.add(`icon-${icon}`)
24+
if (color) btn.classList.add(`btn-color-${color}`)
2425
btn.onclick = () => atom.commands.dispatch(atom.views.getView(atom.workspace), command)
2526
this.subs.add(atom.tooltips.add(btn, {
2627
title: tooltip,

styles/debugger.less

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,62 @@
3131
.toolbar {
3232
padding: 0em 1em 0.5em 1em;
3333
line-height: 2.6em;
34+
.ink-debug-toolbar {
35+
width: 100%;
36+
37+
.ink-btn-group-variable-width {
38+
width: 100%;
39+
display: flex;
40+
flex-wrap: wrap;
41+
flex-direction: row;
42+
43+
.ink-btn-variable-width {
44+
flex: 1;
45+
min-width: 3em;
46+
}
47+
}
48+
}
3449

3550
.inner-toolbar {
3651
display: flex;
3752
flex-direction: row;
3853
flex-wrap: wrap;
3954

55+
.debugger-runner {
56+
width: ~"calc(100% + 2em + 10px)";
57+
margin: 0 -1em 0 -1em;
58+
padding: 0 ~"calc(1em + 5px)" 0 ~"calc(1em + 5px)";
59+
background-color: @button-background-color;
60+
border-bottom: 1px solid @pane-item-border-color;
61+
62+
display: flex;
63+
64+
.btn {
65+
background: @button-background-color;
66+
border: none;
67+
border-radius: 0;
68+
border-left: 1px solid @pane-item-border-color;
69+
&:focus {
70+
border: none;
71+
box-shadow: none;
72+
outline: none;
73+
}
74+
}
75+
select {
76+
background: @button-background-color;
77+
border: none;
78+
border-left: 1px solid @pane-item-border-color;
79+
padding-left: 1em;
80+
border-radius: 0;
81+
width: inherit;
82+
&:focus {
83+
border: none;
84+
box-shadow: none;
85+
border-left: 1px solid @pane-item-border-color;
86+
}
87+
}
88+
}
89+
4090
.flex-table-container {
4191
right: @component-padding;
4292
top: @component-padding;

styles/ink.less

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
@import "ui-variables";
88
@import "syntax-variables";
99

10+
11+
.btn {
12+
&.btn-color-primary {}
13+
&.btn-color-info {
14+
color: @background-color-info;
15+
}
16+
&.btn-color-success {
17+
color: @background-color-success;
18+
}
19+
&.btn-color-warning {
20+
color: @background-color-warning;
21+
}
22+
&.btn-color-error {
23+
color: @background-color-error;
24+
}
25+
}
26+
1027
.ink .markdown {
1128
font-family: 'BlinkMacSystemFont', 'Lucida Grande', 'Segoe UI', Ubuntu, Cantarell, sans-serif;
1229

0 commit comments

Comments
 (0)