ndreynolds / ratatouille

A TUI (terminal UI) kit for Elixir
MIT License
752 stars 39 forks source link

Support text wrapping / multiline content #8

Closed ndreynolds closed 5 years ago

ndreynolds commented 5 years ago

To display multiline content like a man page, markdown document, function documentation or a web page, it needs to be possible to provide a large string of text that may or may not contain line breaks, and have this text rendered such that it is wrapped to fit within the bounding rendering box (and not cut off).

Ratatouille should render multiline text in this way when directed. It should respect explicit line breaks and add additional breaks as necessary to prevent content from being cut off.

To showcase this, it would be interesting to build a small application to display Elixir documentation. Maybe a searchable version of IEx.Helpers.h/1.

Examples

man (via less) performs this sort of text reflowing:


DESCRIPTION
       grep  searches for PATTERN in each FILE.  A FILE of “-”
       stands for  standard  input.   If  no  FILE  is  given,
       recursive  searches  examine the working directory, and
       nonrecursive searches read standard input.  By default,
       grep prints the matching lines.

       In  addition,  the variant programs egrep and fgrep are
       the same as grep -E and grep -F,  respectively.   These
       variants  are deprecated, but are provided for backward
       compatibility.

64 columns


DESCRIPTION
       grep  searches  for PATTERN in
       each  FILE.   A  FILE  of  “-”
       stands for standard input.  If
       no FILE  is  given,  recursive
       searches  examine  the working
       directory,  and   nonrecursive
       searches  read standard input.
       By default,  grep  prints  the
       matching lines.

       In   addition,   the   variant
       programs egrep and  fgrep  are
       the   same   as   grep -E  and
       grep -F, respectively.   These
       variants  are  deprecated, but
       are  provided   for   backward
       compatibility.

39 columns