Compare commits

5 Commits

Author SHA1 Message Date
Alexander Heldt
89a6f09a90 wip 2025-11-19 17:59:21 +01:00
Alexander Heldt
7c03656dfe Add ability to listen (tap) the input
By doing something like
```
fn input_output_loop(input_output: Subject(List(String))) -> Nil {
  let output = process.receive_forever(input_output)

  echo output

  input_output_loop(input_output)
}
```
2025-11-19 17:59:21 +01:00
Alexander Heldt
6681cc3c69 Add ability to inject characters into the input 2025-11-19 17:57:49 +01:00
Alexander Heldt
6518fd4b30 Add ability to create character sequences as Input 2025-11-19 17:48:51 +01:00
Alexander Heldt
78cc3647c7 Correct io_get_chars comment/documentation 2025-11-19 17:46:58 +01:00

View File

@@ -102,7 +102,7 @@ fn handle_message(
/// This is useful to ultimately create a `Control` without the user having to
/// input all of the character(s) needed.
fn read_input(
agent: Subject(Control),
subject: Subject(Control),
inject_input: Subject(Key),
tap_input: Subject(List(String)),
) -> Nil {
@@ -111,13 +111,10 @@ fn read_input(
Ok(_) | Error(_) -> []
}
case
let _ =
key.read_input_until_key(buffer, tap_input)
|> control.from_key
{
Error(_) -> Nil
Ok(control) -> process.send(agent, control)
}
|> result.map(process.send(subject, _))
read_input(agent, inject_input, tap_input)
read_input(subject, inject_input, tap_input)
}