#crossterm #raw #terminal #replace #println #macro #r-n

printrn

A macro to replace println!(), that will replace all \n with \r\n, e.g. for crossterm or other raw terminal work.

5 releases

0.1.5 Jan 11, 2023
0.1.4 Jan 11, 2023
0.1.3 Jan 11, 2023
0.1.1 Jan 10, 2023
0.1.0 Jan 10, 2023

#1734 in Rust patterns


Used in akasha

LGPL-3.0-or-later

5KB
58 lines

printrn

A macro to replace println!(), that will replace all \n with \r\n.

This is useful when working with raw terminals, such as via crossterm or tui. In raw terminal mode, \n will only move the current line one down, and keep printing from there, like so:

APPLE
     BOOK
         CHERRY

Which is where \r (short for carriage Return) comes in. By replacing all \n with \r\n, you can get the more expected behavior:

APPLE
BOOK
CHERRY

No runtime deps