Package Exports
- truwrap
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (truwrap) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
truwrap
A node module and CLI for text wrapping, panels & tables that supports 24bit color SGR codes.
Status
Developer
Help
Many current tty text wrapping solutions have issues with the 'long' and currently 'non-standard' RGB SGR codes (i.e ^[[38;2;204;51;66m
). This meant that, while it's possible to have wonderful, rich, full gamut colours and the aesthetic data visualisations it entails, it comes at the price of painful typography and corrupted console displays as text is broken up, unnaturally wrapped and becoming unreadable as the SGR codes are dashed against the rocks of 1980's shortsightedness, confusing your terminal and ever so slightly breaking the heart of design aware coders and administrators everywhere.
Clearly this is unnacceptable!
Previously, the only solution was to take a last, long whistful look at how great console colour could be, before going back to the, at best, 256 colours of the xterm pallette, with it's lack of useful greens and overly dark purples, or, for some, the even more cruelly devastating 16 colours of the ansi pallette, before heading to the stationary cupboard for a bit of a cry.
But weep no more!
Developed as part of our internal data visualisation system, where having the fidelity of 24 bit colour and embedded images (currently OS X iTerm 3 only) was a huge advantage.
Usable within your own node.js cli projects and an npm module or directly from the command line as a shell scripting command.
Usage
Installation
npm install --save @thebespokepixel/truwrap
CLI
truwrap
Smarter terminal text wrapping (handles 24bit color)
Synopsis:
cat inputFile | truwrap [options]
Options:
-h, --help Display this help.
-v, --version Return the current version on stdout. -vv Return name & version.
-V, --verbose Be verbose. -VV Be loquacious.
-o, --stderr Use stderr rather than stdout
-l, --left Left margin
-r, --right Right margin
-w, --width Set total width. Overrides terminal window’s width.
-t, --truncate Truncate panel cells.
-m, --mode Wrapping mode
-s, --stamp Print arguments rather than stdin. printf-style options supported.
-p, --panel Render a tabular panel into the available console width.
-d, --delimiter The column delimiter when reading data for a panel.
-x, --regex Character run selection regex.
--color Force color depth --color=256|16m. Disable with --no-color
Usage:
Reads unformatted text from stdin and typographically applies paragraph wrapping it for the currently active tty.
To use, simply pipe in a body of text to wrap according to the supplied options.
cat readme.md | truwrap --left 6 --right 6 --mode soft
Programmatic usage
var truwrap = require('truwrap')
var writer = truwrap({
left: 2,
right: 2,
mode: 'soft',
outStream: process.stderr
})
var contentWidth = writer.getWidth()
writer.write("Some text to write...", "...and some more.")
writer.write("A new paragraph, if not implicitly present.")
writer.end()
Advanced use
To add. Containers, Tables, Panels and Images.
Related
For advanced 24bit colour handling see MarkGriffiths/trucolor and npm trucolor.
Documentation
Full documentation can be found at https://markgriffiths.github.io/truwrap/