rocketsplash-rt 0.2.2

Runtime library for loading and rendering Rocketsplash assets (.rst, .rsf)
Documentation
// <FILE>crates/rocketsplash-rt/src/scroll.rs</FILE>
// <DESC>Scrolling helpers for runtime-rendered text</DESC>
// <VERS>VERSION: 1.0.0</VERS>
// <WCTX>Runtime library implementation</WCTX>
// <CLOG>Add horizontal window and vertical offset helpers</CLOG>

pub fn scroll_window(text: &str, width: usize, frame: usize) -> String {
    let width = width.max(1);
    let pad = " ".repeat(width);
    let scroll = format!("{}{}{}", pad, text, pad);
    let total = scroll.chars().count();
    if width >= total {
        return scroll;
    }
    let max_start = total - width;
    let start = frame % (max_start + 1);
    scroll.chars().skip(start).take(width).collect()
}

pub fn vertical_offset(output: &str, offset: usize) -> String {
    let mut result = String::new();
    for _ in 0..offset {
        result.push('\n');
    }
    result.push_str(output);
    result
}

// <FILE>crates/rocketsplash-rt/src/scroll.rs</FILE>
// <VERS>END OF VERSION: 1.0.0</VERS>