Skip to main content

Crate rotulus_mirc

Crate rotulus_mirc 

Source
Expand description

IRC formatting codes, as Rotulus styled text.

IRC carries its styling in-band: a byte like 0x02 toggles bold, and 0x03 followed by digits sets a color. Rotulus never interprets bytes like these itself — a view that did would let anyone who can send it text restyle its transcript — so an IRC client decides which messages may carry formatting and converts those here, into ordinary styled runs, before appending.

The vocabulary is the one documented at https://modern.ircdocs.horse/formatting: bold, italic, underline, strikethrough, monospace, reverse, reset, and colors by number (0x03) or by hex (0x04). Colors 0–15 address the view’s palette, whose first sixteen slots are the mIRC colors, so a theme can adjust them; the extended colors 16–98 and hex colors are fixed RGB. 99 means “the default color”.

Nothing here fails: an incomplete code is dropped, and anything that is not a code is text.

Structs§

Segment
A run of the input’s text, with the codes before it resolved.

Constants§

STANDARD
The sixteen standard colors as 0xRRGGBB, for a view’s default palette.

Functions§

color
The color an mIRC number names.
parse
text as styled text, with the codes removed.
segments
Split text into styled segments, with the codes removed.
strip
text with every formatting code removed and nothing else changed: what to put on a clipboard, or in a notification.