sennenki/pretty_prompt/rendering does not have a README file

    AnsiColor

    pub(all) enum AnsiColor {
    Default
    Black
    Red
    Green
    Yellow
    Blue
    Magenta
    Cyan
    White
    BrightBlack
    BrightRed
    BrightGreen
    BrightYellow
    BrightBlue
    BrightMagenta
    BrightCyan
    BrightWhite
    Color256(Int)
    Rgb(Int, Int, Int)
    } derive(Eq)

    Cell

    pub struct Cell {
    char : Char
    format : ConsoleFormat
    } derive(Eq)

    屏幕上的一个单元格
    impl Default for Cell

    Cell::new

    fn Cell::new(char : Char, format : ConsoleFormat) -> Cell

    Cell::op_equal

    fn Cell::op_equal(self : Cell, other : Cell) -> Bool

    判断两个单元格是否完全一致(内容和样式)

    ConsoleFormat

    pub struct ConsoleFormat {
    foreground : AnsiColor
    background : AnsiColor
    bold : Bool
    italic : Bool
    underline : Bool
    } derive(Eq)

    ConsoleFormat::new

    fn ConsoleFormat::new(foreground? : AnsiColor, background? : AnsiColor, bold? : Bool, italic? : Bool, underline? : Bool) -> ConsoleFormat

    ConsoleFormat::with_background

    fn ConsoleFormat::with_background(self : ConsoleFormat, background : AnsiColor) -> ConsoleFormat

    FormatSpan

    pub struct FormatSpan {
    start : Int
    length : Int
    format : ConsoleFormat
    }

    FormatSpan::new

    fn FormatSpan::new(start : Int, length : Int, format : ConsoleFormat) -> FormatSpan

    FormattedString

    pub struct FormattedString {
    text : String
    spans : Array[FormatSpan]
    }

    带样式的字符串

    FormattedString::new

    fn FormattedString::new(text : String, spans? : Array[FormatSpan]) -> FormattedString

    FormattedString::width

    fn FormattedString::width(self : FormattedString) -> Int

    获取长度(处理 Unicode 宽度)

    Screen

    pub struct Screen {
    rows : Array[Array[Cell]]
    width : Int
    height : Int
    cursor_row : Int
    cursor_col : Int
    }

    虚拟屏幕缓冲区

    Screen::draw_string

    fn Screen::draw_string(self : Screen, row : Int, col : Int, text : String, format : ConsoleFormat) -> Unit

    在指定位置绘制带样式的字符串(处理 Unicode 宽度)

    Screen::new

    fn Screen::new(height : Int, width : Int) -> Screen

    创建指定大小的空屏幕

    Screen::set_cursor

    fn Screen::set_cursor(self : Screen, row : Int, col : Int) -> Unit

    WrappedText

    pub struct WrappedText {
    lines : Array[String]
    cursor_row : Int
    cursor_col : Int
    }

    自动换行结果

    apply_highlights

    fn apply_highlights(text : String, spans : Array[FormatSpan]) -> String

    get_string_width

    fn get_string_width(s : String) -> Int

    is_word_boundary

    fn is_word_boundary(c1 : Char?, c2 : Char?) -> Bool

    render_diff

    fn render_diff(console : &
    ConsolePort
    , new_screen : Screen, old_screen : Screen, base_row : Int, base_col : Int) -> Unit

    将新旧屏幕差异输出到控制台

    wrap_text

    fn wrap_text(text : String, caret : Int, width : Int) -> WrappedText

    根据宽度对文本进行折行处理