truwrap
Smarter terminal text wrapping (handles 24bit color)
Last updated 3 months ago by thebespokepixel .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install truwrap 
SYNC missed versions from official npm registry.

truwrap

A node module and CLI for text wrapping, panels & tables that supports 24bit color SGR codes.

Publishing Status

npm David
Travis Rollup

Development Status

Greenkeeper Travis
David David-developer
Snyk Code-climate Coverage

Documentation/Help

Inch Twitter

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.

Screengrab

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 thebespokepixel/trucolor and npm trucolor.

Documentation

Full documentation can be found at https://thebespokepixel.github.io/truwrap/

Current Tags

  • 0.7.0-beta.8                                ...           beta (4 years ago)
  • 2.0.2                                ...           latest (3 months ago)

83 Versions

  • 2.0.2                                ...           3 months ago
  • 2.0.1                                ...           3 months ago
  • 2.0.0                                ...           3 months ago
  • 1.0.5                                ...           10 months ago
  • 1.0.4                                ...           10 months ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.8.4                                ...           a year ago
  • 0.8.3                                ...           a year ago
  • 0.8.2                                ...           a year ago
  • 0.8.1                                ...           2 years ago
  • 0.8.0                                ...           2 years ago
  • 0.7.6                                ...           2 years ago
  • 0.7.5                                ...           2 years ago
  • 0.7.4                                ...           3 years ago
  • 0.7.3                                ...           4 years ago
  • 0.7.2                                ...           4 years ago
  • 0.7.1                                ...           4 years ago
  • 0.7.0                                ...           4 years ago
  • 0.7.0-beta.8                                ...           4 years ago
  • 0.7.0-beta.7                                ...           4 years ago
  • 0.7.0-beta.6                                ...           4 years ago
  • 0.7.0-beta.5                                ...           4 years ago
  • 0.7.0-beta.4                                ...           4 years ago
  • 0.7.0-beta.3                                ...           4 years ago
  • 0.7.0-beta.2                                ...           4 years ago
  • 0.7.0-beta.1                                ...           4 years ago
  • 0.7.0-beta.0                                ...           4 years ago
  • 0.6.3                                ...           4 years ago
  • 0.6.2                                ...           4 years ago
  • 0.6.1                                ...           4 years ago
  • 0.6.0                                ...           4 years ago
  • 0.5.7                                ...           4 years ago
  • 0.5.6                                ...           4 years ago
  • 0.5.5                                ...           4 years ago
  • 0.5.4                                ...           4 years ago
  • 0.5.3                                ...           4 years ago
  • 0.5.2                                ...           4 years ago
  • 0.5.1                                ...           4 years ago
  • 0.5.0                                ...           4 years ago
  • 0.4.1                                ...           4 years ago
  • 0.4.0                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.8                                ...           4 years ago
  • 0.2.7                                ...           4 years ago
  • 0.2.6                                ...           4 years ago
  • 0.2.5                                ...           4 years ago
  • 0.2.4                                ...           4 years ago
  • 0.2.3                                ...           4 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.25                                ...           4 years ago
  • 0.1.24                                ...           5 years ago
  • 0.1.23                                ...           5 years ago
  • 0.1.22                                ...           5 years ago
  • 0.1.21                                ...           5 years ago
  • 0.1.20                                ...           5 years ago
  • 0.1.19                                ...           5 years ago
  • 0.1.18                                ...           5 years ago
  • 0.1.17                                ...           5 years ago
  • 0.1.16                                ...           5 years ago
  • 0.1.15                                ...           5 years ago
  • 0.1.14                                ...           5 years ago
  • 0.1.13                                ...           5 years ago
  • 0.1.12                                ...           5 years ago
  • 0.1.11                                ...           5 years ago
  • 0.1.10                                ...           5 years ago
  • 0.1.9                                ...           5 years ago
  • 0.1.8                                ...           5 years ago
  • 0.1.7                                ...           5 years ago
  • 0.1.6                                ...           5 years ago
  • 0.1.5                                ...           5 years ago
  • 0.1.4                                ...           5 years ago
  • 0.1.3                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.1-alpha.0                                ...           5 years ago
  • 0.0.9                                ...           5 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.5-41                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 4
This Month 23
Last Day 1
Last Week 0
Last Month 85
Dependencies (17)
Dev Dependencies (18)

Copyright 2014 - 2016 © taobao.org |