Sign in

    ShiChengxu/moonlayout/wrap does not have a README file

    BreakKind

    pub(all) enum BreakKind {
    Soft
    Hyphenated
    Hard
    Forced
    End
    } derive(Eq,
    Debug
    )

    Reason a line ended. Forced is an emergency grapheme boundary; End is EOF.

    BreakKind::equal

    fn BreakKind::equal(BreakKind, BreakKind) -> Bool

    BreakKind::not_equal

    fn BreakKind::not_equal(x : BreakKind, y : BreakKind) -> Bool

    BreakPolicy

    pub(all) enum BreakPolicy {
    Unicode
    Word
    Sentence
    Grapheme
    } derive(Eq,
    Debug
    )

    Preferred boundaries. Word/Sentence intersect UAX #14; Grapheme allows every grapheme boundary. Emergency splitting still applies when a unit is too long.

    BreakPolicy::equal

    fn BreakPolicy::equal(BreakPolicy, BreakPolicy) -> Bool

    BreakPolicy::not_equal

    fn BreakPolicy::not_equal(x : BreakPolicy, y : BreakPolicy) -> Bool

    Line

    pub(all) struct Line {
    start : Int
    end : Int
    source : String
    text : String
    width : Int
    break_kind : BreakKind
    aligned_text : String
    ambiguous_wide : Bool
    } derive(Eq,
    Debug
    )

    Exact source range [start,end) in UTF-8 bytes, with a lossless source copy. text is trimmed/expanded content; aligned_text is the final display string. width measures aligned_text. Wrapping initially sets aligned_text = text.

    Line::equal

    fn Line::equal(Line, Line) -> Bool

    Line::not_equal

    fn Line::not_equal(x : Line, y : Line) -> Bool

    Line::to_repr

    OptimalOptions

    pub(all) struct OptimalOptions {
    stretch : Int
    shrink : Int
    line_penalty : Int
    hyphen_penalty : Int
    } derive(Eq,
    Debug
    )

    Per internal ASCII space: maximum added cells (stretch) and removed cells (shrink, capped at one). Negative settings become zero. Penalties are capped to keep costs finite. This is a simplified paragraph optimizer, not TeX.

    OptimalOptions::equal

    OptimalOptions::new

    fn OptimalOptions::new(stretch? : Int, shrink? : Int, line_penalty? : Int, hyphen_penalty? : Int) -> OptimalOptions

    Defaults minimize squared nonfinal slack without changing space widths.

    OptimalOptions::not_equal

    fn OptimalOptions::not_equal(x : OptimalOptions, y : OptimalOptions) -> Bool

    WrapAlgorithm

    pub(all) enum WrapAlgorithm {
    Greedy
    Optimal
    } derive(Eq,
    Debug
    )

    Greedy fills each line; Optimal minimizes paragraph badness.

    WrapAlgorithm::equal

    WrapAlgorithm::not_equal

    fn WrapAlgorithm::not_equal(x : WrapAlgorithm, y : WrapAlgorithm) -> Bool

    WrapOptions

    pub(all) struct WrapOptions {
    ambiguous_wide : Bool
    break_policy : BreakPolicy
    tab_width : Int
    } derive(Eq,
    Debug
    )

    WrapOptions::equal

    fn WrapOptions::equal(WrapOptions, WrapOptions) -> Bool

    WrapOptions::new

    fn WrapOptions::new(ambiguous_wide? : Bool, break_policy? : BreakPolicy, tab_width? : Int) -> WrapOptions

    Nonpositive tab widths normalize to one column.

    WrapOptions::not_equal

    fn WrapOptions::not_equal(x : WrapOptions, y : WrapOptions) -> Bool

    display_width

    fn display_width(s : String, ambiguous_wide? : Bool, tab_width? : Int) -> Int

    Monospace cell width: sum the dependency's width per extended grapheme. Tabs advance to tab stops; hard-break clusters have zero width. This function does not perform font shaping or cross-grapheme ligature measurements.

    optimal_wrap

    fn optimal_wrap(s : String, max_width : Int, opts? : WrapOptions, optimal? : OptimalOptions) -> Array[Line]

    Minimize paragraph cost over grapheme boundaries with dynamic programming. Natural breaks dominate emergency splits. Hard breaks are mandatory. Costs combine squared slack, cubic glue adjustment and configurable line penalties; the final line is ragged. Source spans always refer to the unchanged input.

    wrap

    fn wrap(s : String, max_width : Int, opts? : WrapOptions) -> Array[Line]

    Greedy wrapping with lossless source spans. Trailing ASCII spaces/tabs and hard-break characters are absent from display text but remain in source. Empty input returns []; nonpositive widths normalize to 1. An indivisible grapheme wider than the limit occupies its own line without being split.

    wrap_hyphenated

    fn[H :
    Hyphenator
    ] wrap_hyphenated(s : String, max_width : Int, hyphenator : H, algorithm? : WrapAlgorithm, opts? : WrapOptions, optimal? : OptimalOptions) -> Array[Line]

    Wrap using discretionary word-internal hyphens. Providers receive UAX #29 word segments; offsets must be interior UTF-8 bytes on grapheme boundaries. Invalid/duplicate offsets are ignored. A visible ASCII hyphen is inserted only at a selected break and never changes source or start/end offsets.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io