~smlavine/onclick

db7a7d776e8eaf108b2f697e1b764c0d810c2ee4 — Sebastian LaVine 8 months ago b986f0d
Accept Enter key as well
2 files changed, 4 insertions(+), 2 deletions(-)

M README.md
M states/states.ha
M README.md => README.md +1 -1
@@ 4,7 4,7 @@
usage: onclick command args...
```

Every time the terminal is clicked, the command runs.
Every time the terminal is clicked, or enter is pressed, the command runs.

## Installation


M states/states.ha => states/states.ha +3 -1
@@ 9,11 9,13 @@ use ascii::{isdigit};
// Given an input rune, transitions to another state (or itself).
export type state = fn(r: rune) *state;

// The initial state of the machine (state 1). Matches '\x1B' (ESC).
// The initial state of the machine (state 1). Matches '\x1B' (ESC) or Enter.
export fn start(r: rune) *state = {
	switch (r) {
	case '\x1B' =>
		return &bracket;
	case '\n' =>
		return &end;
	case =>
		return &start;
	};