A library to generate ASCII boxes via NodeJS
# Using npm
npm install --save cli-box
# Using yarn
yarn add cli-box
// Dependencies
var Box = require("cli-box");
// Create a simple box
var b1 = Box("20x10");
console.log(b1.toString());
// Set custom marks
var b2 = new Box({
w: 10
, h: 10
, stringify: false
, marks: {
nw: "β"
, n: "ββ"
, ne: "β"
, e: "β"
, se: "β"
, s: "ββ"
, sw: "β"
, w: "β"
, b: "ββ"
}
});
console.log(b2.stringify());
// Box with text and use the stringify
var b3 = Box("20x10", "I will be \u001b[31mdis\u001b[0mplayed inside! \n A\u001b[34mnd I'm in a\u001b[0m new line!");
console.log(b3);
// Box with aligned text to top-right
var b4 = Box("30x20", {
text: "Box content"
, stretch: true
, autoEOL: true
, vAlign: "top"
, hAlign: "right"
});
console.log(b4);
// Full screen box
var b5 = Box({fullscreen: true, marks: {}}, "Hello World!");
console.log(b5.toString());
There are few ways to get help:
- Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
- For bug reports and feature requests, open issues. π
- For direct and quick help, you can use Codementor. π
Creates a new ASCII box.
-
Object|String
options
: A string representing the size:WIDTHxHEIGHT
(e.g.10x20
) or an object: -
width
orw
(Number): The box width. -
height
orh
(Number): The box height. -
fullscreen
(Boolean): Iftrue
, the box will have full size (default:false
). -
stringify
(Boolean): Iffalse
the box will not be stringified (theCliBox
object will be returned instead). -
marks
(Object): An object containing mark characters. Default:nw
:"β"
n
:"β"
ne
:"β"
e
:"β"
se
:"β"
s
:"β"
sw
:"β"
w
:"|"
b
:" "
-
Object|String
text
: A string to be displayed or an object: -
text
(String): The text to be displayed. -
stretch
(Boolean): Stretch box to fix text (default:false
). -
autoEOL
(Boolean): Break lines automatically (default:false
). -
hAlign
(String): Horizontal alignement (default:"middle"
). It can take one of the values:"left"
,"middle"
,"right"
. -
vAlign
(String): Vertical alignement (default:"center"
). It can take one of the values:"top"
,"center"
,"bottom"
.
- Object|Stringify The
CliBox
object (ifoptions.stringify
isfalse
) or the stringified box.
Returns the stringified box.
- String Stringified box string.
Have an idea? Found a bug? See how to contribute.
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
-
Starring and sharing the projects you like π
-
βI love books! I will remember you after years if you buy me one. π π
-
βYou can make one-time donations via PayPal. I'll probably buy a
coffeetea. π΅ -
βSet up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
-
BitcoinβYou can send me bitcoins at this address (or scanning the code below):
1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6
Thanks! β€οΈ
If you are using this library in one of your projects, add it in this list. β¨
3abn
@cord-sdk/cli
@dhiwise/cli
@execution-machine/sdk
@gem-mine/sapphire
@publishkit/cli
@squidcloud/core
@vennet/gitcook
@yoshiboi18303/apex-bp-calculator
any-app
artstack-downloader
ascii-github
bhedge
biscord
blessnet
burawi
christmas-cli
cli-cal
cli-gh-cal
cli-github
componensea
csk-cli
daisweb3.ts
devgrill
dwh-mixpanel
ex-template
expo-library
fluxmockserverapi
gafas
gem-mine
generate-express-typescript-api
ghcal
hibercli
holesail
iamhamidreza
image-oversize-finder
le-table
maxen
mem-cli-js
naveen-express
naveen-react
newyear-cli
nextjs-starter-templates
openai-electron-cli
overlap
oversize-images-finder
pigcolor
prophecysend
short-fire
sinha-rn-web
survivio
text-animation
undiorm
wollok-ts-cli