34 lines
637 B
Hare
34 lines
637 B
Hare
|
use fmt;
|
||
|
use os;
|
||
|
use unicode;
|
||
|
|
||
|
export fn main() void = {
|
||
|
const input = os::args[1];
|
||
|
|
||
|
fmt::println(input)!;
|
||
|
|
||
|
let ix = 0u;
|
||
|
const lb = unicode::new_line_breaker(input);
|
||
|
for (const (pos, mand) => unicode::next_line_break(&lb)) {
|
||
|
for (ix < pos; ix += 1) {
|
||
|
fmt::print(' ')!;
|
||
|
};
|
||
|
ix += 1;
|
||
|
|
||
|
if (mand) {
|
||
|
fmt::println('|')!;
|
||
|
} else {
|
||
|
fmt::print('^')!;
|
||
|
};
|
||
|
};
|
||
|
|
||
|
fmt::println()!;
|
||
|
fmt::println()!;
|
||
|
|
||
|
fmt::println("Line break opportunities:")!;
|
||
|
const lb = unicode::new_line_breaker(input);
|
||
|
for (const (pos, mand) => unicode::next_line_break(&lb)) {
|
||
|
fmt::printfln("- {} {}", pos, if (mand) "(mandatory)" else "")!;
|
||
|
};
|
||
|
};
|