gitoria
All repositories: gitoria
806 B
// hl:proc — THE TERMINAL'S OWN INPUT as instance events, the Process pattern// applied to fd 0://// input = stdin()// on input.line(text) { … } \\ one typed line, without its newline// on input.eof() { … } \\ the terminal closed (Ctrl-D)//// A joined terminal realm (SPEC "Joining a realm") is what this exists for: the// peer's entry reads lines here and `emit`s across the edge.Number #srcId = 0start() {#srcId = __native("eventloop.register", __native("proc.stdin"), "__stdinEvent")return this}on __stdinEvent(ev) {if (ev.eof == true) {// the closed terminal retires its source, so a program whose only// source was the keyboard simply ends__native("eventloop.unregister", #srcId)emit eof()return null}emit line(ev.line)return null}
Branches
- mainmain branch