PreviousUpNext

15.4.275  src/lib/compiler/back/low/library/line-break.pkg


# Compiled by:
#     src/lib/compiler/back/low/lib/lib.lib



###           "Good judgment comes from experience
###            and experience comes from bad judgment."
###
###                         -- Fred Brooks



api Line_Break {

     line_break:  Int -> String -> String;
};

package line_break

: (weak)  Line_Break            # Line_Break    is from   src/lib/compiler/back/low/library/line-break.pkg

{
    fun line_break max_chars text
        =
        loop (toks, 0, [])
        where
            fun loop ([], _, text)
                    =>
                    string::cat (reverse text);

                loop (s ! ss, n, text)
                    => 
                    {   m = string::length_in_bytes s + 1;
                        n' = m+n;

                        if   (n' > max_chars) 
                             loop (ss, m,  s ! " " ! "\n" ! text);
                        else loop (ss, n', s ! " " ! text);
                        fi;
                    };
            end;

            toks =  string::fields   (\\ c =  c == ' ')   text;
        end;
};


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext