Extensions
A neutral kernel, and what plugs into it
The kernel simulates, and that is all: it decides neither how you learn nor what you see. The guided path, the workshop and the command line are built on top of it, and anyone can add their own.
tk notebookAvailable today
tkernel-parcours
The guided path, as an extension of the kernel: the manual, the levels, and tools that unlock when your components pass their specs. free on opens everything.
tkernel-egui
The graphical workshop: an infinite plane, parts to place, boxes to dive into, the manual next to your circuit.
tkernel-cli
tk, the notebook: interactive, .tk scripts, or one JSON command per line for another program.
Coming next
tkernel-wui soon
Small pieces of web page that run the kernel: a live component, a manual example you can execute. This site will use them.
tkernel-tui later
The workshop in a terminal.
tkernel-reseau later
Find, install and share components from the workshop, through the library of this site.
Your own
Write an extension
An extension adds its commands, refuses the ones it wants, completes the kernel's answers and saves its state with the project. Another guided path, a game, a school tool: the kernel doesn't need to know it.
use tkernel_core::{Extension, Kernel};
struct Counter(u32);
impl Extension for Counter {
fn commande(&mut self, _k: &Kernel, cmd: &str, _args: &[&str]) -> Option<Result<String, String>> {
(cmd == "count").then(|| {
self.0 += 1;
Ok(format!("{} times", self.0))
})
}
fn neuve(&self) -> Box<dyn Extension> {
Box::new(Counter(0))
}
}
let mut k = Kernel::new();
k.add_extension(Box::new(Counter(0)));
k.exec("count").unwrap();
assert_eq!(k.exec("count").unwrap(), "2 times");
The code of tkernel is written in French: commande is the command hook, neuve returns a fresh extension when a project is reloaded. The other hooks (apres, query, complete, projet, aide) are optional.