diff --git a/README.md b/README.md index 64533444f3e077f8581c5b72a80d54324ebd0aef..c37eeab174d6f42a4909cb4c6d2e79ddbe65fc30 100644 --- a/README.md +++ b/README.md @@ -357,7 +357,8 @@ At the moment, the UI really hobbles along. There are a few big bugs and problem ## Known Bugs - - of 2019 July 10: reloading a native hunk with document events attached: or deleting in general: document event handles are not removed, and are reachable by document, so will hang out. + - of 2019 July 10: reloading a native hunk with document events attached: or deleting in general: document event handles are not removed, and are reachable by document, so will hang out. + - reload doesn't put the hunk back in place, wyd ## Bug Foreshadowing diff --git a/hunks/control/saturn.js b/hunks/control/saturn.js new file mode 100644 index 0000000000000000000000000000000000000000..63539d29d6a422e920532d9bf838c1b375cbda37 --- /dev/null +++ b/hunks/control/saturn.js @@ -0,0 +1,56 @@ +/* + +hunk template + +*/ + +// these are ES6 modules +import { + Hunkify, + Input, + Output, + State +} from '../hunks.js' + +// a space-time planner for networked machines, +function Saturn() { + // this fn attaches handles to our function-object, + Hunkify(this) + + // ui, + let pxn = new Input('boolean', 'xNegPressure', this) + let pxp = new Input('boolean', 'xPosPressure', this) + this.inputs.push(pxn, pxp) + // handling (can we go num -> uint32 reliably at link?) + let oxs = new Output('number', 'xStepsNextIncrement', this) + let oxi = new Input('number', 'xStepsMade', this) + this.inputs.push(oxi) + this.outputs.push(oxs) + + let intervalMicroseconds = new State('number', 'usPerIncrement', 1000) + let accelState = new State('number', 'accel (s/s^2)', 1000) + this.states.push(intervalMicroseconds, accelState) + + // State items also have change handlers, + intervalMicroseconds.change = (value) => { + // at this point, something external (probably a human) + // has requested that we change this state variable, + // we can reject that, by doing nothing here, or we can + intervalMicroseconds.set(value) + } + + // hunks can choose to- or not- have init code. + // at init, the module has been loaded and state variables have been + // recalled from any program save - so this is a good point + // to check any of those, and setup accordingly ... + this.init = () => { + this.log('first return') + } + + this.loop = () => { + // hmm... + } +} + +// the hunk is also an ES6 module, this is how we export those: +export default Saturn diff --git a/hunks/input/string.js b/hunks/input/string.js deleted file mode 100644 index 92238a3dd2ac1f01267ad0bcb5850ae84891832b..0000000000000000000000000000000000000000 --- a/hunks/input/string.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - -line input - -*/ - -import { Hunkify, Input, Output, State } from '../hunks.js' - -function Strang() { - Hunkify(this) - - this.description = 'click pow pow' - - let thruput = new Input('string', 'thru', this) - this.inputs.push(thruput) - - let stringOutput = new Output('string', 'string', this) - this.outputs.push(stringOutput) - - // this.states.prefix = new State('string', 'prefix', 'LOG:') - // this.states.onchange = new State('boolean', 'onchange', true) - - this.dom = {} - - this.init = () => { - // manager calls this once - // it is loaded and state is updated (from program) - this.log('hello String') - this.dom = $('<div>').get(0) - // au manuel - this.dom.style.marginTop = '40px' - let strContainer = $('<div>').addClass('cfcont').appendTo($(this.dom)) - let strinput = $('<input/>').attr({type: 'text', id: 'txtin'}).addClass('txtinput').appendTo($(strContainer)).get(0) - strinput.value = 'type input here' - let contact = $('<div>').addClass('btn').append('! push !').get(0) - $(this.dom).append(contact) - contact.addEventListener('click', (evt) => { - console.log('str click') - stringOutput.put(strinput.value) - }) - } - - this.loop = () => { - /* - if (thruput.io && stringOutput.ie) { - // TODO decide about primitives and conversions - stringOutput.put(JSON.stringify(thruput.get())) - } - */ - } -} - -export default Strang diff --git a/hunks/interface/arrowpad.js b/hunks/interface/arrowpad.js index d2a9b0ff33feb6df34a29967915854509bda16fa..3a53997604fde9b02930191e02f1ba083c64878e 100644 --- a/hunks/interface/arrowpad.js +++ b/hunks/interface/arrowpad.js @@ -67,8 +67,8 @@ function Arrowpad() { let idleColor = '#82aef5' let removeKeyBindings = () => { - document.removeEventListener('keydown', keyListen) - document.removeEventListener('keyup', keyListen) + document.removeEventListener('keydown', keyDownListen) + document.removeEventListener('keyup', keyUpListen) // no sticky keys! clearAllKeys() } @@ -131,6 +131,7 @@ function Arrowpad() { this.loop = () => { for(let key of pairs){ if(!(key.output.io) && key.down){ + console.log('put', key.name) key.output.put(true) } } diff --git a/hunks/interface/string.js b/hunks/interface/string.js new file mode 100644 index 0000000000000000000000000000000000000000..a1a04a6ab8515846e1107073b3a4d8170983a261 --- /dev/null +++ b/hunks/interface/string.js @@ -0,0 +1,45 @@ +/* + +line input + +*/ + +import { Hunkify, Input, Output, State } from '../hunks.js' + +function Strang() { + Hunkify(this) + + let stringOutput = new Output('string', 'string', this) + this.outputs.push(stringOutput) + + // this.states.prefix = new State('string', 'prefix', 'LOG:') + // this.states.onchange = new State('boolean', 'onchange', true) + + this.dom = {} + + this.init = () => { + // manager calls this once + // it is loaded and state is updated (from program) + this.log('hello String') + this.dom = $('<div>').get(0) + } + + this.onload = () => { + let strContainer = $('<div>').addClass('cfcont').appendTo($(this.dom)) + let strinput = $('<input/>').attr({type: 'text', id: 'txtin'}).appendTo($(strContainer)).get(0) + $(strinput).css('padding', '10px').css('width', '377px').css('border', 'none') + strinput.value = 'type input here' + let contact = $('<div>').addClass('btn').append('! push !').get(0) + $(this.dom).append(contact) + contact.addEventListener('click', (evt) => { + console.log('str click') + stringOutput.put(strinput.value) + }) + } + + this.loop = () => { + + } +} + +export default Strang diff --git a/style.css b/style.css index b963eaf0d5ac6bfc000523d33a6d3e7cfe1b9475..65d67a98f99c07ac74aaad8c0a6156ddb9517e00 100644 --- a/style.css +++ b/style.css @@ -377,9 +377,3 @@ li:active{ font-size: 15px; padding: 10px; } - -.txtinput { - padding: 10px; - width: 100%; - border: none; -} diff --git a/view/vdef.js b/view/vdef.js index 8f49ccb71c1e1527265b45bc2465d769e7f0fac7..c73d93590ad4bf80faa5518a5addceff8123eab0 100644 --- a/view/vdef.js +++ b/view/vdef.js @@ -108,7 +108,7 @@ function HunkDefinition(spec, view, dt, debug) { let mp = { s: 1, x: ct.x, - y: ct.y - 31*3 - 5 + y: ct.y - 31*3 - 10 } if(this.containsButtons()) mp.y -= 25 if(view.isTopLevel){