Skip to main content

add_wrapped_text

Function add_wrapped_text 

Source
pub fn add_wrapped_text(
    text: &str,
    indent1: i64,
    indent2: i64,
    width: i64,
) -> String
Expand description

Word-wrap text to width columns with the same wrapping behavior as Git’s strbuf_add_wrapped_text, used by the %w(width,indent1,indent2) pretty directive.

indent1 is the indent for the first output line, indent2 for the rest. A negative indent1 means that -indent1 columns have already been consumed on the first line (no extra indent emitted there). With width <= 0 the text is only indented, not wrapped. Column widths are measured with display width (East-Asian wide characters count as 2).