Create sections in the terminal.
-Scen---------------------------------
| |
| |
| The quick brown fox |
| jumps over the lazy dog. |
| |
| |
--------------------------------------
npm install scen
const scen = require('scen')
const text = 'The quick brown fox \njumps over the lazy dog.'
console.log(
scen(text, {
title: 'Scen', padding: '2 6', textAlign: 'center', style: 'classic'
})
)
scen(text, [options])
The text which you want to show in section.
How to show text in section, possible values are as follows:
{
[title], [width], [height], [style], [padding],
[textAlign], [titleAlign], [marginTop], [marginLeft], [marginBottom]
}
Title of section. Default is empty string.
console.log(scen("Hello, world!", { title: "Hi there!"}));
/*
┌─Hi there!─────┐
│Hello, world! │
└───────────────┘
*/
Width of section. Default is 0
.
console.log(scen("Hello, world!", { width: 20}));
/*
┌────────────────────┐
│Hello, world! │
└────────────────────┘
*/
Height of section. Default is 0
.
console.log(scen("Hello, world!", { height: 3 }));
/*
┌─────────────┐
│Hello, world!│
│ │
│ │
└─────────────┘
*/
Style of section border. Default is single
.
You can use single
, double
, round
, single-double
, double-single
, classic
, stars
or fenced
. If you want to customize the characters, please modify the code.
console.log(scen("Hello, world!", { style: "stars", padding: "1" }));
/*
*****************
* *
* Hello, world! *
* *
*****************
*/
Text padding in section. Default is '0'
. Use this option like CSS padding.
console.log(scen("Hello, world!", { padding: "3 1 3 1"}));
/*
┌───────────────┐
│ │
│ │
│ │
│ Hello, world! │
│ │
│ │
│ │
└───────────────┘
*/
Specifies the horizontal alignment of text. Default is left
. You can use left
, center
, or right
.
console.log(scen("Hello, world!", textAlign: "right", width: 20));
/*
┌────────────────────┐
│ Hello, world!│
└────────────────────┘
*/
Specifies the horizontal alignment of section title. Default is left
. You can use left
, center
, or right
.
console.log(scen("Hello, world!", { title: "Hi there!", titleAlign: "right", width: 20 }));
/*
┌────────────Hi there!─┐
│Hello, world! │
└──────────────────────┘
*/
Specifies the left offset for the section.
console.log(scen("Hello, world!", { marginLeft: 3 }));
/*
┌─────────────┐
│Hello, world!|
└─────────────┘
*/
Specifies the top offset for the section.
console.log(scen("Hello, world!", { marginTop: 2 }));
/*
┌─────────────┐
│Hello, world!|
└─────────────┘
*/
Specifies the bottom offset for the section.
console.log(scen("Hello, world!", { marginBottom: 2 }));
/*
┌─────────────┐
│Hello, world!|
└─────────────┘
*/
MIT