diff --git a/hunks/view.js b/hunks/view.js index 1db9357bfb6c1af0b73b78e124ab33d721e03b44..ce440e889d75d31ec4a90f59e76422e70857de09 100644 --- a/hunks/view.js +++ b/hunks/view.js @@ -520,19 +520,19 @@ function View() { */ // we need to recurse here, let recursor = (scope, order) => { - if(debug) console.log(`Global Organize: recurses ${scope.name} at ${order}`) + if (debug) console.log(`Global Organize: recurses ${scope.name} at ${order}`) // scope is a view (hunk) // order is nth- level down tree, with us (toplevel) at root 0 - if(debug) console.log(`GO: scope defs, tl defs`) + if (debug) console.log(`GO: scope defs, tl defs`) for (let df of scope.defs) { - if(debug) console.log(`GO: df over ${df.name} in ${scope.name}`) + if (debug) console.log(`GO: df over ${df.name} in ${scope.name}`) // edgecased is a block to not walk back-up heirarchy, if (df.type === 'link' && df.grouptype !== 'edgecased') { // find recirprocal view relationship via trace, which returns an input, thru links, // given some output - if(debug) console.log(`GO: TRACELOG FROM ${df.name}`) + if (debug) console.log(`GO: TRACELOG FROM ${df.name}`) let rvi = trace(df.outputs[1]) - if(debug) console.log(`GO: TRACELOG RETURNS`, rvi) + if (debug) console.log(`GO: TRACELOG RETURNS`, rvi) if (rvi) { // we have ah link definition, and ah view definition, connected by routing, // so we are safe to do @@ -546,7 +546,7 @@ function View() { $(rvd.hunk.dom).css('background-color', '#e5e5e5') } // and, - if(debug) console.log(`GO: wrap ${df.name} around ${rvd.name}`) + if (debug) console.log(`GO: wrap ${df.name} around ${rvd.name}`) df.wrapon(rvd) rvd.unwrap() // now, if we have ll data, @@ -569,7 +569,7 @@ function View() { // and do, internalLink.edgecase() // still logging these, bc it's nice 2 kno - if(debug) console.log(`GO cn link ${df.name} to ${internalLink.name}`) + if (debug) console.log(`GO cn link ${df.name} to ${internalLink.name}`) // done w/ internal, now we can recursor(rvd.hunk, ++order) } else { @@ -767,22 +767,45 @@ function View() { $(evt.target).text('requesting a list of hunks...') vw.requestListAvail().then((stringlist) => { this.changeContextTitle('available hunks:') + // sort the list... + let treelike = [] for (let item of stringlist) { - this.addContextOption(item, (evt) => { - $(evt.target).append(' > requested ... ') - //vw.msgbox.write(`requested one new ${item}`) - vw.requestAddHunk(item).then((def) => { - $('.contextmenu').remove() - //console.log('one hunk as promised', def) - }).catch((err) => { - this.changeContextTitle('error, see consoles') - setTimeout(() => { - $(this.dom).find('.contextmenu').fadeOut(400, function() { - $(this).remove() - }) - }, 1000) + let slash = item.indexOf('/') + if(slash > 0){ + let head = item.substring(0, slash) + // add to or make, + let parent = treelike.find((cand) => { + return cand.parentname === head }) - }) + if(parent){ + parent.list.push(item) + } else { + treelike.push({ + parentname: head, + list: [item] + }) + } + } + } + for(let branch of treelike){ + this.addContextTitle(branch.parentname) + for(let item of branch.list){ + this.addContextOption(item, (evt) => { + $(evt.target).append(' > requested ... ') + //vw.msgbox.write(`requested one new ${item}`) + vw.requestAddHunk(item).then((def) => { + $('.contextmenu').remove() + //console.log('one hunk as promised', def) + }).catch((err) => { + this.changeContextTitle('error, see consoles') + setTimeout(() => { + $(this.dom).find('.contextmenu').fadeOut(400, function() { + $(this).remove() + }) + }, 1000) + }) + }) + } } }) }) @@ -925,6 +948,10 @@ function View() { } }) // end contextmenu + this.addContextTitle = (text) => { + $(this.dom).find('.contextmenu').get(0).append($('<ul>' + text + '/</li>').get(0)) + } + // takes 'under' argument this.addContextOption = (text, click) => { $(this.dom).find('.contextmenu').get(0).append($('<li>' + text + '</li>').click((click)).get(0)) @@ -1600,25 +1627,25 @@ function View() { this.requestAddHunk(od.type).then((def) => { // let's compare these ? for matching inputs, outputs, reconnect: let matching = (odp, ndp, ind) => { - if(odp[ind]){ - if(odp[ind].name === ndp[ind].name && odp[ind].type === ndp[ind].type) return true + if (odp[ind]) { + if (odp[ind].name === ndp[ind].name && odp[ind].type === ndp[ind].type) return true } else { return false } } // these links are all added on a promise, meaning we aren't sure (by the time this runs to completion) // whether or not they are successful... - // with better view -> manager integration, this would be mucho easier - for(let ip in def.inputs){ - if(matching(od.inputs, def.inputs, ip)){ - for(let cn of od.inputs[ip].connections){ + // with better view -> manager integration, this would be mucho easier + for (let ip in def.inputs) { + if (matching(od.inputs, def.inputs, ip)) { + for (let cn of od.inputs[ip].connections) { this.requestAddLink(cn, def.inputs[ip]) } } } - for(let op in def.outputs){ - if(matching(od.outputs, def.outputs, op)){ - for(let cn of od.outputs[op].connections){ + for (let op in def.outputs) { + if (matching(od.outputs, def.outputs, op)) { + for (let cn of od.outputs[op].connections) { this.requestAddLink(def.outputs[op], cn) } } diff --git a/style.css b/style.css index 5dcc90a8a9c56622a1189a633f00de7c104cc309..b963eaf0d5ac6bfc000523d33a6d3e7cfe1b9475 100644 --- a/style.css +++ b/style.css @@ -291,11 +291,11 @@ textarea { ul { list-style-type: none; - font-size: 15px; + font-size: 13px; font-weight: bold; - font-style: italic; color: #eee; - padding: 2px 0 2px 0; + padding: 11px 0 0 5px; + margin: 0px; } li { @@ -303,7 +303,7 @@ li { font-weight: normal; font-style: none; color: #eee; - font-size: 12px; + font-size: 13px; padding: 7px 5px 6px 5px; } diff --git a/typeset.js b/typeset.js index 2ef82f25b9715a80c8cb179dac469c84771ce599..4533e9607c924842290047fe25c4fcfbdada23a0 100644 --- a/typeset.js +++ b/typeset.js @@ -233,6 +233,41 @@ const TSET = [{ int8 46, int8array 47, int16 48, int16array 49, int32 50, int32array 50, + */ + { + name: 'int32', + key: 50, + write: function(value) { + if (typeof value !== 'number') throw new Error('cannot cast non-number into physical world') + let tparr = new Int32Array(1) + tparr[0] = value + let btarr = new Uint8Array(tparr.buffer) + //place + let rtarr = Array.from(btarr) + rtarr.unshift(this.key) + console.warning('not sure about int -> uint8 byte casts yet') + console.log("INT32 WRITES ARR: ", rtarr, "FOR: ", value) + return rtarr + }, + read: function(arr, start) { + // assume we're reading out of an array + // start[] should === key + if (arr[start] !== this.key) throw new Error(`mismatched key on phy read: ${arr[start]}, ${this.key}`) + let rdarr = arr.slice(start + 1, start + 5) + let btarr = Uint8Array.from(rdarr) + if (tsdebug) console.log('bts on read of uint32', btarr) + // now make uint32 view on this ... + let vlarr = new Int32Array(btarr.buffer) + console.warning('not sure about int -> uint8 byte casts yet') + console.log("UINT32 READ ARR: ", vlarr[0], "FROM: ", btarr) + if (tsdebug) console.log('vlarr', vlarr) + return { + item: vlarr[0], + increment: 5 + } + } + }, + /* int64 52, int64array 53, float32 54, float32array 55, float64 56, float64array 57 (these are === javascript 'numbers') ... how to alias ?