3 Commits

Author SHA1 Message Date
Himadri Bhattacharjee
3def1f28ab UI/UX: Fixes logging pane scrolling. Adds auto scroll on output. 2023-03-24 14:58:24 +05:30
Himadri Bhattacharjee
38b371caa2 Use warn and info functions for appending to log queue. 2023-03-24 14:57:32 +05:30
Himadri Bhattacharjee
1364a38c9e Build script removes old artifacts for rebuilds. 2023-03-24 14:56:59 +05:30
5 changed files with 16 additions and 7 deletions

View File

@@ -2,7 +2,7 @@ import glob
from subprocess import PIPE, Popen
from os import listdir, makedirs
from os.path import join, splitext
from shutil import copytree, copy
from shutil import copytree, copy, rmtree
from errno import ENOTDIR
SRC = 'src'
DST = 'build'
@@ -25,6 +25,7 @@ def to_compile(s: str):
return None
rmtree(DST, ignore_errors=True)
makedirs(DST, exist_ok=True)
mpy_cross_bin = join(".", glob.glob("mpy-cross.static*")[0])

View File

@@ -12,7 +12,7 @@ from adafruit_hid.keycode import Keycode
import time
from board import LED
from logs import log
from logs import info, warn
kbd = Keyboard(usb_hid.devices)
layout = KeyboardLayout(kbd)
@@ -40,7 +40,7 @@ def press_keys(line: str):
kbd.press(command_keycode)
continue
# If it's not a known key name, log it for diagnosis
log(f"warning: unknown key: <{key}>")
warn(f"unknown key: <{key}>")
kbd.release_all()
@@ -66,7 +66,7 @@ def run_script(contents):
millis = default_delay
delay(millis)
elif message := after("PRINT"):
log(message)
info(message)
elif path := after("IMPORT"):
run_script_file(path)
elif millis := after("DEFAULT_DELAY", "DEFAULTDELAY"):
@@ -87,4 +87,4 @@ def run_script_file(path: str):
with open(path, "r", encoding="utf-8") as handle:
run_script(handle.read())
except OSError as e:
log(f"warning: unable to open file {path}: {e}")
warn(f"unable to open file {path}: {e}")

View File

@@ -8,5 +8,9 @@ def consume() -> str:
return dump
def log(message: str):
def info(message: str):
logs.append("info: " + message)
def warn(message: str):
logs.append("warning: " + message)

View File

@@ -36,6 +36,8 @@ body {
height: calc(30vh - 2rem);
background: #000;
padding: 1rem;
overflow: scroll;
scroll-behavior: smooth;
}
.files {
@@ -93,6 +95,7 @@ body {
.editor {
background: #222;
border: none;
resize: none;
min-width: max-content;
height: calc(70vh - 3rem);
padding: 0.5rem;

View File

@@ -34,7 +34,8 @@ editor.addEventListener('keyup', (_) => {
function reload_logs() {
doApi({'action':'logs'}).then(r => r.json()).then(body => {
body.map(entry => {
logs.innerHTML += entry + '<br />'
logs.innerText += entry + '\n'
logs.scrollTo(0, logs.scrollHeight)
})
})
}