Compare commits
No commits in common. "49e2df75ca1f773eba8b5fd44bd11d59a17c7976" and "c93b0b493b8955fc631c8e4d2a828d64dc502c92" have entirely different histories.
49e2df75ca
...
c93b0b493b
14
console.js
14
console.js
|
@ -1,9 +1,8 @@
|
||||||
function main() {
|
function main() {
|
||||||
let socket = new WebSocket("ws://localhost:8764");
|
let socket = new WebSocket("ws://localhost:8765");
|
||||||
var ids = [];
|
var ids = [];
|
||||||
|
|
||||||
socket.onopen = function(e) {
|
socket.onopen = function(e) {
|
||||||
console.log("[LOG] sending client ping")
|
|
||||||
socket.send("client ping");
|
socket.send("client ping");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +11,8 @@ function main() {
|
||||||
|
|
||||||
console.log(message.message)
|
console.log(message.message)
|
||||||
if (message.message === "clear") {
|
if (message.message === "clear") {
|
||||||
console.log("[LOG] removing expressions from the graph");
|
|
||||||
for(i in ids) {
|
for(i in ids) {
|
||||||
console.log(`[LOG] removing expression ${ids[i]}`)
|
console.log("removing")
|
||||||
Calc.removeExpression({
|
Calc.removeExpression({
|
||||||
id: ids[i],
|
id: ids[i],
|
||||||
})
|
})
|
||||||
|
@ -22,13 +20,13 @@ function main() {
|
||||||
|
|
||||||
ids = [];
|
ids = [];
|
||||||
} else if (message.message === "expression") {
|
} else if (message.message === "expression") {
|
||||||
console.log(`[LOG] adding expression ${message.payload} as id ${message.id}`);
|
|
||||||
Calc.setExpression({
|
Calc.setExpression({
|
||||||
type: "expression",
|
type: "expression",
|
||||||
latex: message.payload,
|
latex: message.payload,
|
||||||
id: message.id,
|
id: message.id,
|
||||||
})
|
})
|
||||||
ids.push(message.id)
|
ids.push(message.id)
|
||||||
|
console.log(ids)
|
||||||
} else if (message.message === "ticker") {
|
} else if (message.message === "ticker") {
|
||||||
var state = Calc.getState();
|
var state = Calc.getState();
|
||||||
|
|
||||||
|
@ -40,7 +38,9 @@ function main() {
|
||||||
|
|
||||||
Calc.setState(JSON.stringify(state))
|
Calc.setState(JSON.stringify(state))
|
||||||
} else {
|
} else {
|
||||||
console.log(`[LOG] couldn't parse message ${e.data}`)
|
console.log("unknown message type.")
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} main();
|
|
||||||
|
|
|
@ -37,8 +37,6 @@ id testing : B = [1, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||||
: ibl(addr, b, c) = {less = 1 : ijmp(addr, 0, 0), jumped -> 1}
|
: ibl(addr, b, c) = {less = 1 : ijmp(addr, 0, 0), jumped -> 1}
|
||||||
|
|
||||||
: isto(v, addr) = setlistval(addr, v)
|
: isto(v, addr) = setlistval(addr, v)
|
||||||
: imov(from, target) = setlistval(target, B[from])
|
|
||||||
: ipsto(value, ptr) = setlistval(B[ptr], value)
|
|
||||||
|
|
||||||
# registers
|
# registers
|
||||||
# instruction pointer
|
# instruction pointer
|
||||||
|
@ -68,8 +66,6 @@ id testing : B = [1, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||||
paramthree -> B[addr + 3]
|
paramthree -> B[addr + 3]
|
||||||
: exec = { \
|
: exec = { \
|
||||||
inst = sto : isto(paramone, paramtwo), \
|
inst = sto : isto(paramone, paramtwo), \
|
||||||
inst = psto : ipsto(paramone, paramtwo), \
|
|
||||||
inst = mov : imov(paramone, paramtwo), \
|
|
||||||
inst = add : iadd(paramone, paramtwo, paramthree), \
|
inst = add : iadd(paramone, paramtwo, paramthree), \
|
||||||
inst = cmp : icmp(paramone, paramtwo, paramthree), \
|
inst = cmp : icmp(paramone, paramtwo, paramthree), \
|
||||||
inst = eld : ield(paramone, paramtwo), \
|
inst = eld : ield(paramone, paramtwo), \
|
||||||
|
@ -95,8 +91,6 @@ id testing : B = [1, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||||
: main = loopaction, loop
|
: main = loopaction, loop
|
||||||
|
|
||||||
: sto = 1
|
: sto = 1
|
||||||
: psto = 16
|
|
||||||
: mov = 17
|
|
||||||
: add = 2
|
: add = 2
|
||||||
: cmp = 3
|
: cmp = 3
|
||||||
: eld = 4
|
: eld = 4
|
||||||
|
@ -112,4 +106,4 @@ id testing : B = [1, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||||
: div = 14
|
: div = 14
|
||||||
: rst = 15
|
: rst = 15
|
||||||
|
|
||||||
: instwidth = [2,3,1,1,1,1,1,1,1,1,3,3,3,3,0,2,2]
|
: instwidth = [2,3,1,1,1,1,1,1,1,1,3,3,3,3,0]
|
||||||
|
|
|
@ -9,20 +9,15 @@ def get_overrides(file):
|
||||||
fd.close()
|
fd.close()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def define_args(parser):
|
|
||||||
parser.add_argument('--copy', action="store_true", help="copy the client side JS to clipboard")
|
|
||||||
parser.add_argument('--assemble', nargs=2, help="assemble the file INFILE and write the resultant overrides to OUTFILE")
|
|
||||||
parser.add_argument('--run', help="specify file to start the desmos server for")
|
|
||||||
parser.add_argument('--overrides', help="specify file that contains overrides for desmos expressions")
|
|
||||||
|
|
||||||
|
|
||||||
def entry():
|
def entry():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog="desmosisa",
|
prog="desmos-sync",
|
||||||
description="a smörgåsbord of utilities for desmos, including some implementations of an desmos-based isa",
|
description="Synchronize from local file to Desmos calculator",
|
||||||
)
|
)
|
||||||
|
|
||||||
define_args(parser)
|
parser.add_argument('--copy', action="store_true", help="copy the client side JS to clipboard")
|
||||||
|
parser.add_argument('--run', help="specify file to start the desmos server for")
|
||||||
|
parser.add_argument('--overrides', help="specify file that contains overrides for desmos expressions")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.overrides:
|
if args.overrides:
|
||||||
|
|
|
@ -96,10 +96,8 @@ async def serv(websocket, file, overrides={}):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def start_server(file, overrides):
|
async def start_server(file, overrides):
|
||||||
print("starting server")
|
|
||||||
wrapper = functools.partial(serv, file=file, overrides=overrides)
|
wrapper = functools.partial(serv, file=file, overrides=overrides)
|
||||||
async with serve(wrapper, "localhost", 8764):
|
async with serve(wrapper, "localhost", 8765):
|
||||||
print("starting server for realz")
|
|
||||||
await asyncio.Future()
|
await asyncio.Future()
|
||||||
|
|
||||||
def main(file, overrides):
|
def main(file, overrides):
|
||||||
|
|
16
setup.py
16
setup.py
|
@ -1,16 +0,0 @@
|
||||||
import setuptools
|
|
||||||
setuptools.setup(
|
|
||||||
name='desmos-sync',
|
|
||||||
version='0.1',
|
|
||||||
author='Ryan Marina',
|
|
||||||
description='synchronize Desmos expressions between the local filesystem and the web calculator',
|
|
||||||
packages=["desmossync"],
|
|
||||||
entry_points = {
|
|
||||||
"console-scripts": [ "desmos-sync=desmossync.cli.entry" ]
|
|
||||||
},
|
|
||||||
install_requires=[
|
|
||||||
'setuptools',
|
|
||||||
'websockets',
|
|
||||||
'watchdog'
|
|
||||||
]
|
|
||||||
)
|
|
12
shell.nix
12
shell.nix
|
@ -1,4 +1,10 @@
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
pkgs.mkShell {
|
let
|
||||||
nativeBuildInputs = with pkgs.python311Packages; [ websockets watchdog pyperclip ];
|
my-python-packages = ps: with ps; [
|
||||||
}
|
pip
|
||||||
|
pkgs.python311Packages.websockets
|
||||||
|
pkgs.python311Packages.watchdog
|
||||||
|
pkgs.python311Packages.pyperclip
|
||||||
|
];
|
||||||
|
my-python = pkgs.python3.withPackages my-python-packages;
|
||||||
|
in my-python.env
|
||||||
|
|
Loading…
Reference in New Issue