Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename refactor #236

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/debugger/breakpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** @jsx etch.dom */

import {CompositeDisposable, Emitter} from 'atom'
import { showBasicModal } from '../util/basic-modal'
import showBasicModal from '../util/basic-modal'
import {Etch} from '../util/etch'

import etch from 'etch'
Expand Down Expand Up @@ -266,20 +266,25 @@ export default class BreakpointManager {
if (bp.file !== file || bp.line !== line) return
showBasicModal([{
name: 'Condition',
value: bp.condition
defaultText: bp.condition,
message: `Enter the condition when this breakpoint applies (previous: \`${bp.condition}\`).`,
}]).then(items => {
const condition = items['Condition']
this.addCondition(bp, condition)
this.emitter.emit('update')
activePane.activate() // Re-activate previously active pane
}).catch((err) => {
if (err) console.error(err);
return
})
found = true
})

if (!found) {
showBasicModal([{
name: 'Condition',
value: '',
defaultText: '',
message: `Enter the condition when this breakpoint applies.`,
}]).then(items => {
const condition = items['Condition']
this.add({
Expand All @@ -291,6 +296,8 @@ export default class BreakpointManager {
})
this.emitter.emit('update')
activePane.activate() // Re-activate previously active pane
}).catch((err) => {
if (err) console.error(err);
})
}
}
Expand Down
7 changes: 4 additions & 3 deletions lib/debugger/debugger-pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import etch from 'etch'
import { toView, Toolbar, Tip, Button, Icon, makeicon, Etch, Raw } from '../util/etch'
import { showBasicModal } from '../util/basic-modal'
import showBasicModal from '../util/basic-modal'
import { CompositeDisposable, TextEditor } from 'atom'
import PaneItem from '../util/pane-item'
import { open } from '../util/opener'
Expand Down Expand Up @@ -360,12 +360,13 @@ export default class DebuggerPane extends PaneItem {
addCondition (bp) {
showBasicModal([{
name: "Condition",
value: bp.condition
defaultText: bp.condition,
message: `Enter the condition when this breakpoint applies (previous: \`${bp.condition}\`).`,
}]).then(items => {
const cond = items["Condition"]
this.breakpointManager.addCondition(bp, cond)
}).catch((err) => {
console.error(err);
if (err) console.error(err);
})
}

Expand Down
1 change: 1 addition & 0 deletions lib/ink.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ exportables =
Opener: once(=> require('./util/opener'))
matchHighlighter: once(=> require './util/matchHighlighter')
ansiToHTML: once(=> require './util/ansitohtml')
showBasicModal: once(=> require './util/basic-modal')

module.exports = Ink =
activate: ->
Expand Down
8 changes: 4 additions & 4 deletions lib/plots/canopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import etch from 'etch';
import { prewalk, postwalk, prefor } from './tree.js';
import { Etch, Tip, Button, toView } from '../util/etch.js';
import { Etch, Button, toView } from '../util/etch.js';

function clamp (x, min, max) {
return Math.min(Math.max(x, min), max)
Expand All @@ -26,12 +26,12 @@ function dims(tree) {
left += ch.width;
});
// Centre align children
chwidth = parent.children.map(({width})=>width).reduce((a,b)=>a+b, 0);
const chwidth = parent.children.map(({width})=>width).reduce((a,b)=>a+b, 0);
parent.children.forEach(ch => ch.left += (parent.width-chwidth)/2);
return parent;
});
// Scale total height to 100%
let max = postwalk(tree, ({height, children}) =>
const max = postwalk(tree, ({height, children}) =>
Math.max(height, ...children.map(x=>x+height)));
prewalk(tree, (node) => {
node.top /= max;
Expand Down Expand Up @@ -172,7 +172,7 @@ export class Pannable extends Etch {
this.toolbar = this.toolbar.concat(this.item.toolbar)
}

let style = {position:'relative', height:'inherit', width:'inherit', transformOrigin: '0px 0px'}
const style = { position:'relative', height:'inherit', width:'inherit', transformOrigin: '0px 0px' }

if (this.zoomstrategy == 'width') {
style.transform = 'translate('+this.left+'px,'+this.top+'px)'
Expand Down
65 changes: 33 additions & 32 deletions lib/util/basic-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ import etch from 'etch'
import { toView, Toolbar, Button, Icon, makeicon, Etch, Raw } from './etch'
import { TextEditor, CompositeDisposable } from 'atom'

export function showBasicModal(queries) {
export default function showBasicModal(queries) {
return new Promise((resolve, reject) => {
subs = new CompositeDisposable()
const subs = new CompositeDisposable()

_resolve = (...args) => {
const _resolve = (...args) => {
panel.destroy()
subs.dispose()
resolve(...args)
}
_reject = (...args) => {
const _reject = (...args) => {
panel.destroy()
subs.dispose()
reject(...args)
}
let view = new BasicModalView(queries, _resolve, _reject)
const view = new BasicModalView(queries, _resolve, _reject)

subs.add(atom.commands.add('.basic-modal .editor', {
'basic-modal:confirm': () => view.confirm()
}))
subs.add(atom.commands.add('.basic-modal .editor', {
'basic-modal:cancel': () => view.cancel()
}))
let panel = atom.workspace.addModalPanel({
const panel = atom.workspace.addModalPanel({
item: view,
autoFocus: true
})
Expand All @@ -44,24 +44,24 @@ class BasicModalView {
this.reject = reject
this.models = {}
this.queries = queries
for (let query of this.queries) {
this.queries.forEach(query => {
this.models[query.name] = new TextEditor({
mini: true,
placeholderText: query.placeholder || ''
})
if (query.value) {
this.models[query.name].setText(query.value)
if (query.defaultText) {
this.models[query.name].setText(query.defaultText)
}
}
})

etch.initialize(this)
}

confirm () {
let ret = {}
for (let query of this.queries) {
const ret = {}
this.queries.forEach(query => {
ret[query.name] = this.models[query.name].getText()
}
})
this.resolve(ret)
}

Expand All @@ -72,34 +72,35 @@ class BasicModalView {
update () {}

render () {
let queryViews = this.queries.map(query => {
const queryViews = this.queries.map(query => {
return <div className="flex-table row">
<div className="flex-row">
{query.name || ''}
</div>
<div className="flex-row second">
{toView(this.models[query.name].element)}
{query.message || ''}
</div>
</div>
})
return <div className="basic-modal flex-table-container">
{queryViews}
<div className="confirm-cancel flex-table">
<div className="flex-row">
<Button
className="btn-success"
onclick={() => this.confirm()}>
Confirm
</Button>
</div>
<div className="flex-row">
<Button
className="btn-error"
onclick={() => this.cancel()}>
Cancel
</Button>
</div>
</div>
</div>
{queryViews}
<div className="confirm-cancel flex-table">
<div className="flex-row">
<Button
className="btn-success"
onclick={() => this.confirm()}>
Confirm
</Button>
</div>
<div className="flex-row">
<Button
className="btn-error"
onclick={() => this.cancel()}>
Cancel
</Button>
</div>
</div>
</div>
}
}
1 change: 0 additions & 1 deletion lib/util/etch.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export class Tip {
this.tooltip = atom.tooltips.add(this.element, {title: () => this.text});
}


this.text = alt;
this.child = child;
etch.update(this, false);
Expand Down