webterm: clean up

This commit is contained in:
fang 2020-11-06 22:32:13 +01:00
parent f62129d095
commit acd9176d76
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
4 changed files with 3 additions and 167 deletions

View File

@ -1,16 +1,13 @@
:: belt: runtime belt structure
::
~% %mar-belt ..is ~
|_ =belt:dill
++ grad %noun
:: +grab: convert from
::
++ grab
~% %belt-grab ..grab ~
|%
++ noun belt:dill
++ json
~/ %mar-belt-json
^- $-(^json belt:dill)
=, dejs:format
%- of

View File

@ -10,6 +10,7 @@ export class Input extends Component {
type: 'Sending to Dojo'
};
this.keyPress = this.keyPress.bind(this);
this.paste = this.paste.bind(this);
this.click = this.click.bind(this);
this.inputRef = React.createRef();
}
@ -26,9 +27,9 @@ export class Input extends Component {
keyPress(e) {
let key = e.key;
// let paste event pass
// let paste and leap events pass
if ((e.getModifierState('Control') || event.getModifierState('Meta'))
&& e.key === 'v') {
&& (e.key === 'v' || e.key === '/')) {
return;
}
@ -56,10 +57,7 @@ export class Input extends Component {
this.props.api.belt(belt);
}
//TODO handle paste
e.preventDefault();
}
paste(e) {

View File

@ -1,157 +0,0 @@
// See /lib/sole/hoon
const str = JSON.stringify;
export class Share {
constructor(buf, ven, leg) {
if (buf == null) {
buf = '';
}
this.buf = buf;
if (ven == null) {
ven = [0, 0];
}
this.ven = ven;
if (leg == null) {
leg = [];
}
this.leg = leg;
}
abet() {
return {
buf: this.buf,
leg: this.leg.slice(),
ven: this.ven.slice()
};
}
apply(ted) {
switch (false) {
case 'nop' !== ted: return;
case !ted.map: return ted.map(this.apply, this);
default: switch (Object.keys(ted)[0]) {
case 'set': return this.buf = ted.set;
case 'del': return this.buf = this.buf.slice(0, ted.del) + this.buf.slice(ted.del + 1);
case 'ins':
var { at, cha } = ted.ins;
return this.buf = this.buf.slice(0, at) + cha + this.buf.slice(at);
default: throw `%sole-edit -lost.${str(ted)}`;
}
}
}
transmute(sin, dex) {
switch (false) {
case (sin !== 'nop') && (dex !== 'nop'): return dex;
case !sin.reduce:
return sin.reduce(((dex, syn) => this.transmute(syn, dex)), dex);
case !dex.map: return dex.map(dax => this.transmute(sin, dax));
case dex.set === undefined: return dex;
default: switch (Object.keys(sin)[0]) {
case 'set': return 'nop';
case 'del':
if (sin.del === dex.del) {
return 'nop';
}
dex = { ...dex };
switch (Object.keys(dex)[0]) {
case 'del': if (sin.del < dex.del) {
dex.del--;
}
break;
case 'ins': if (sin.del < dex.ins.at) {
dex.ins.at--;
}
break;
}
return dex;
case 'ins':
dex = { ...dex };
var { at, cha } = sin.ins;
switch (Object.keys(dex)[0]) {
case 'del': if (at < dex.del) {
dex.del++;
}
break;
case 'ins': if ((at < dex.ins.at) ||
((at === dex.ins.at) && !(cha <= dex.ins.cha))) {
dex.ins.at++;
} else if (at >= dex.ins.at) {
dex.ins.at = at; // NOTE possibly unpredictable behaviour
dex.ins.at++; // for sole inserts that aren't tabs
}
break;
}
return dex;
default: throw `%sole-edit -lost.${str(sin)}`;
}
}
}
commit(ted) {
this.ven[0]++;
this.leg.push(ted);
return this.apply(ted);
}
inverse(ted) {
switch (false) {
case 'nop' !== ted: return ted;
case !ted.map:
return ted.map((tad) => {
const res = this.inverse(tad);
this.apply(tad);
return res;
}).reverse();
default: switch (Object.keys(ted)[0]) {
case 'set': return { set: this.buf };
case 'ins': return { del: ted.ins };
case 'del': return { ins: { at: ted.del, cha: this.buf[ted.del] } };
default: throw `%sole-edit -lost.${str(ted)}`;
}
}
}
receive({ ler, ted }) {
if (!(ler[1] === this.ven[1])) {
throw `-out-of-sync.[${str(ler)} ${str(this.ven)}]`;
}
this.leg = this.leg.slice((this.leg.length + ler[0]) - this.ven[0]);
const dat = this.transmute(this.leg, ted);
this.ven[1]++;
this.apply(dat);
return dat;
}
remit() {
throw 'stub';
}
transmit(ted) {
const act = { ted, ler: [this.ven[1], this.ven[0]] };
this.commit(ted);
return act;
}
transceive({ ler, ted }) {
const old = new Share(this.buf);
const dat = this.receive({ ler, ted });
return old.inverse(dat);
}
transpose(ted, pos) {
if (pos === undefined) {
return this.transpose(this.leg, ted);
} else {
let left;
return ((left =
(this.transmute(
ted, { ins: { at: pos } })).ins) != null ?
left : { at: 0 }
).at;
}
}
};
export default Share;

View File

@ -17,9 +17,7 @@ export default class Store {
}
handleEvent(data) {
// recursive handler
const blit = data.data;
switch (Object.keys(blit)[0]) {
case 'bel':
let beep = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVKOhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1fhzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACiDgAAAAAAABCqEEQRLCgwpBGMlJkIz8jKhGvj4k6jzRnqasNKIeoh5gI7BJaC1A1AoNBjJgbyApVS4IDlZgDU5WUAxEKDNmmALHzZp0Fkz1FMTmGFl1FMEyodIavcCAUHDWrKAIA4aa2oCgILEBupZgHvAhEBcZ6joQBxS76AgccrFlczBvKLC0QI2cBoCFvfTDAo7eoOQInqDPBtvrDEZBNYN5xwNwxQRfw8ZQ5wQVLvO8OYU+mHvFLlDh05Mdg7BT6YrRPpC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DroqArFkMEsAS+eWmrUzrO0oEmE40RlMZ5+ODIkAyKAGUwZ3mVKmcamcJnMW26MRPgUw6j+LkhyHGVGYjSUUKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU=");