Skip to content

Commit

Permalink
API rework to support vscode plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
drom committed Jan 22, 2024
1 parent 84c5fa5 commit 35bff47
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 24 deletions.
18 changes: 9 additions & 9 deletions lib/dom-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ const domContainer = (obj) => {
return {
elo,
pstate,
start: (content, deso /* , opt */) => {
start: (deso /* , opt */) => {

content.appendChild(container);
// content.appendChild(container);
// content.appendChild(elo.rightPanel);
getFullView(deso);

Expand Down Expand Up @@ -140,26 +140,26 @@ const domContainer = (obj) => {
let render2 = genRenderWavesGL(elo);
let render1 = render2(deso);
let render = render1(pstate, obj.renderPlugins);
deso.render = render;

const resizeHandler = genResizeHandler(pstate);

const resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) {
const {width, height} = entry.contentRect;
let {width, height} = entry.contentRect;
// height = height || 888;
// console.log('resizeObserver', width, height);
resizeHandler(width, height);
}
render();
deso.render();
});

resizeObserver.observe(elo.container);

// pinchAndZoom(els.container, content, pstate, render);
resizeHandler(elo.container.clientWidth, elo.container.clientHeight);
mouseMoveHandler(elo.cursor, elo.container, pstate, render);
render();
return {
render
};
mouseMoveHandler(elo.cursor, elo.container, pstate, deso.render);
deso.render();
}
};
};
Expand Down
4 changes: 2 additions & 2 deletions lib/gen-key-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const executeKeyHandler = (key, keyBindo, pstate, cm) => {
return (keyBindo[key] || keyBindo.nop).fn(pstate, cm);
};

const genKeyHandler = (div, pstate, render, cm, keyBindo, plugins) => {
const genKeyHandler = (div, pstate, deso, cm, keyBindo, plugins) => {
return event => {

const modifier = (
Expand All @@ -22,7 +22,7 @@ const genKeyHandler = (div, pstate, render, cm, keyBindo, plugins) => {
if (plugins != undefined) {
plugins.map(fn => fn(key, event));
}
render();
deso.render();
}
};
};
Expand Down
6 changes: 3 additions & 3 deletions lib/gen-on-wheel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const genOnWheel = (element, pstate, render, cm, keyBindo, plugins) =>
const genOnWheel = (element, pstate, deso, cm, keyBindo, plugins) =>
event => {
const {deltaY} = event;
if (event.ctrlKey) {
Expand All @@ -11,7 +11,7 @@ const genOnWheel = (element, pstate, render, cm, keyBindo, plugins) =>
if (plugins != undefined) {
plugins.map(fn => fn(key, event));
}
render();
deso.render();
}
event.preventDefault();
} else
Expand All @@ -21,7 +21,7 @@ const genOnWheel = (element, pstate, render, cm, keyBindo, plugins) =>
if (plugins != undefined) {

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8

Check warning on line 21 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 10 spaces but found 8
plugins.map(fn => fn(key, event));

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 12 spaces but found 10

Check warning on line 22 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 12 spaces but found 10
}

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8

Check warning on line 23 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 10 spaces but found 8
render();
deso.render();

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8

Check warning on line 24 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 10 spaces but found 8
}

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (16)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (12)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 8 spaces but found 6

Check warning on line 25 in lib/gen-on-wheel.js

View workflow job for this annotation

GitHub Actions / build (14)

Expected indentation of 8 spaces but found 6
event.preventDefault();
}
Expand Down
16 changes: 16 additions & 0 deletions lib/get-element.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

const getElement = divName => {
if (typeof divName === 'string') {
const c = document.getElementById(divName);
if (c === null) {
throw new Error('<div> element width Id: "' + divName + '" not found');
}
return c;
}
return divName;
};

module.exports = getElement;

/* eslint-env browser */
26 changes: 26 additions & 0 deletions lib/get-listing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const lister = require('./lister.js');

const getListing = async (readers) => {
let listing = [];
const r = readers.find(reader => reader.ext === 'lst');
if (r) {
const utf8Decoder = new TextDecoder('utf-8');
const list = lister();
for (let i = 0; i < 10000; i++) {
let { done, value } = await r.reader.read();
if (typeof value !== 'string') {
value = utf8Decoder.decode(value, {stream: true});
}
list.onChunk(value);
if (done) {
listing = list.getTrace();
break;
}
}
}
return listing;
};

module.exports = getListing;
4 changes: 4 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const getElement = require('./get-element.js');
const getListing = require('./get-listing.js');
const domContainer = require('./dom-container.js');
const pluginRenderValues = require('./plugin-render-values.js');
const pluginRenderTimeGrid = require('./plugin-render-time-grid.js');
Expand All @@ -13,6 +15,8 @@ const getT = require('./get-t.js');
const themeAll = require('./theme-all.js');
const helpPanel = require('./help-panel.js');

exports.getListing = getListing;
exports.getElement = getElement;
exports.domContainer = domContainer;
exports.pluginRenderValues = pluginRenderValues;
exports.pluginRenderTimeGrid = pluginRenderTimeGrid;
Expand Down
23 changes: 23 additions & 0 deletions lib/lister.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

module.exports = () => {
const trace = {};
let tail = '';
return {
onChunk: (chunk) => {
const rows = (tail + chunk).split('\n');
// console.log('chunk:', chunk.length, 'tail:', tail.length, 'rows:', rows.length);
tail = rows.pop();
rows.map(row => {
const m = row.match(/\s*([0-9a-f]+):\s*([0-9a-f]+)\s+(.+)/);
if (m) {
const pc = parseInt(m[1], 16);
const op = m[2];
const asm = m[3].replace(/\t/, ' ');
trace[pc] = {op, asm};
}
});
},
getTrace: () => trace
};
};
18 changes: 8 additions & 10 deletions lib/theme-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
const helpPanel = require('./help-panel.js');

const body = {
// html: {
// height: '100%'
// },
'@font-face': {
'font-family': 'Iosevka',
src: 'url(./iosevka-term-light.woff2) format(woff2)'
},
'*': {
// width: '90%',
'scrollbar-width': 'auto',
Expand All @@ -36,7 +29,7 @@ const body = {
border: '0px',
background: '#111',
color: '#fff',
'font-family': 'Iosevka',
'font-family': 'Iosevka Drom Web',
/* font-size: 16px; */
height: '100%'
}
Expand All @@ -51,9 +44,14 @@ const wd = {
/* overflow: auto; */
'--right-panel-width': '0px',
width: 'calc(100% - var(--right-panel-width))',
height: '100%',
// height: '100%',
cursor: 'col-resize',
transition: 'width .3s'
transition: 'width .3s',
position: 'absolute',
top: '0px',
bottom: '0px',
left: '0px',
right: '0px'
},
'.wd-grid': {
position: 'absolute'
Expand Down
Binary file added src/IosevkaDrom-Italic.woff2
Binary file not shown.
Binary file added src/IosevkaDrom-Oblique.woff2
Binary file not shown.
Binary file added src/IosevkaDrom-Regular.woff2
Binary file not shown.

0 comments on commit 35bff47

Please sign in to comment.