Skip to content

Commit

Permalink
Add \c support
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Jan 11, 2025
1 parent 8ee014b commit 4f1a3d7
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions solutions/rakudo/Configurable-REPL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,39 @@ Each which supports the following interpolations:
| Sequence | Prompt Expansion |
|--|--|
| `\a` | alert / bell character |
| `\c` | color - see below for options |
| `\e` | escape character |
| `\i` | index - the current iteration of the REPL, which can be referred to later as, e.g. `$*1` |
| `\l` | `$*RAKU.version` |
| `\L` | `$*RAKU.gist` |
| `\n` | newline |
| `\t` | time - see below for more options |
| `\t` | time - see below for options |
| `\v` | `$*RAKU.compiler.version` |
| `\V` | `$*RAKU.gist` |

The escape character allows us to generate ANSI colors, e.g.
## \c formatting

Provide some common ANSI codes with short names. Defaults to `reset` if a bare `\c` is used,
and multiple arguments can be separated with a `;`, e.g.

```
RAKUDO_REPL_PROMPT='[\e[0;31m\i\e[0m] >'
\c{bold;red}
```

Would generate a prompt similar to the default except the index would appear in red.
### formatting

> reset, normal, bold, dim, italic, underline, blink, inverse, hiddne, strikethrough
### foreground colors

> black, red, green, yellow, blue, magenta, cyan, white, default
### background colors

> bg:black, bg:red, bg:green, bg:yellow, bg:blue, bg:magenta, bg:cyan, bg:white, bg:default
Not all escape sequences have aliases - you can always use
`\e` to manually generate codes.

## \t formatting

Expand All @@ -55,7 +72,6 @@ Would generate a prompt containing, e.g. `06:18 > `

# Future Development

* Support for colors directly - needs a list of ANSI codes/colors in core.
* More strftime support - perhaps even invoking it directly instead of manually mapping.
* Support `RAKUDO_REPL_COMMAND` to support arbitrary code invocation

Expand Down

0 comments on commit 4f1a3d7

Please sign in to comment.