💾 Archived View for gmi.noulin.net › markdown › boxen_README.md captured on 2023-07-10 at 18:17:41.

View Raw

More Information

-=-=-=-=-=-=-

# Sheepy
This is a sheepy package for [sheepy](https://spartatek.se/r/sheepy/file/README.md.html) and using [libsheepy](https://spartatek.se/r/libsheepy/file/README.md.html)

# boxen

Create boxes in the terminal.

This is the C implementation of [boxen javscript](https://github.com/sindresorhus/boxen), the API is similar.

The output looks like this:

(single)

┌─────────────┐

│ │

│ unicorn │

│ │

└─────────────┘

(double)

╔═════════════╗

║ ║

║ unicorn ║

║ ║

╚═════════════╝

(single-double)

╓───╖

║foo║

╙───╜

(double-single)

╒═══╕

│foo│

╘═══╛

(classic)

+---+

|foo|

+---+


# Usage

Install with spm: `spm install boxen`

Include header file:
- `#include "shpPackages/boxen/boxen.h"`

boxent *box = allocBoxen();

char *s = boxO(box, "foo", NULL);

puts(s);

free(s);

terminateO(box);


Usage examples are in `main.c`.

## API

## boxO(obj,input,opts)

### input

Type: `char *`

Text inside the box.

### Options

Type: `char *`

The string must represent a JSON.

OPTIONS: (the values are case insensitive)

"{borderColor: 'Yellow',"

"borderStyle: 'double',"

"dimBorder: true,"

"padding: {top: 1, left: 2, right: 2, bottom: 2},"

"margin: {top: 1, left: 1, right: 1, bottom: 1},"

"float: 'right',"

"backgroundColor: 'green',"

"align: 'center'}"

```

borderColor

- Type: `string`

Values: black red green yellow blue magenta cyan white gray, a hex value like #ff0000 or reset for default terminal color

Color of the box border.

borderStyle

- Type: `string` `object`

- Default: single

single, double, single-double, double-single, classic

dimBorder

- Type: `boolean`

- Default: false

Reduce opacity of the border.

padding

- Type: `number` `Object`

- Default: 0

Space between the text and box border.

Accepts a number or an object with any of the top, right, bottom, left properties. When a number is specified, the left/right padding is 3 times the top/bottom to make it look nice.

margin

- Type: `number` `Object`

- Default: 0

Space around the box.

Accepts a number or an object with any of the top, right, bottom, left properties. When a number is specified, the left/right margin is 3 times the top/bottom to make it look nice.

float

- Type: `string`

- Values: right center left

- Default: left

Float the box on the available terminal screen space.

backgroundColor

- Type: `string`

- Values: black red green yellow blue magenta cyan white gray, a hex value like #ff0000 or reset for default terminal color

Color of the background.

align

- Type: `string`

- Default: left

- Values: left center right

Align the text in the box based on the widest line.