Skip to content

Commit

Permalink
Merge bb38401 into 76e0c8d
Browse files Browse the repository at this point in the history
  • Loading branch information
joeskeen committed Aug 5, 2020
2 parents 76e0c8d + bb38401 commit 29e57e9
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .npmignore
@@ -1,4 +1,4 @@
*.sublime-project
*.sublime-workspace
img/
*.d.ts
lib/*.d.ts
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -369,7 +369,7 @@ $ cfonts "text" --line-height 2

#### -s, --spaceless
Type: `<boolean>`
Default value: `true`
Default value: `false`

Set this option to false if you don't want the plugin to insert two empty lines on top and on the bottom of the output.

Expand Down
119 changes: 119 additions & 0 deletions cfonts.d.ts
@@ -0,0 +1,119 @@
/**
* Main method to get the ANSI output for a string
*
* @param {string} input - The string you want to write out; use '|' character for line break
* @param {object} settings - Settings object
* @param {boolean} debug - A flag to enable debug mode
* @param {number} debugLevel - The debug level we want to show
* @param {object} size - The size of the terminal as an object, default: Size
* @param {number} size.width - The width of the terminal
* @param {number} size.height - The height of the terminal
*
* @typedef {(object|boolean)} RenderOutput
* @property {string} string - The pure string for output with all line breaks
* @property {array} array - Each line of output in an array
* @property {number} lines - The number of lines
* @property {object} options - All options used
*
* @return {RenderOutput} - CLI output of INPUT to be consoled out
*/
export const render: (input: string, settings?: Partial<Options>, debug?: boolean, debugLevel?: number, size?: Partial<Size>) => RenderOutput;
/**
* Print to console
*
* @param {string} input - The string you want to write out; use '|' character for line break
* @param {object} settings - Settings object
* @param {boolean} debug - A flag to enable debug mode
* @param {number} debuglevel - The debug level we want to show
* @param {object} size - The size of the terminal as an object, default: Size
* @param {number} size.width - The width of the terminal
* @param {number} size.height - The height of the terminal
*/
export const say: (input: string, settings?: Partial<Options>, debug?: boolean, debugLevel?: number, size?: Partial<Size>) => void;

export interface Size {
/** the width of the terminal */
width: number;
/** the height of the terminal */
height: number;
}

export type Font = "3d" | "block" | "chrome" | "console" | "grid" | "huge" | "pallet" | "shade" | "simple" | "simpleBlock" | "simple3d" | "slick" | "tiny";
export type Alignment = "left" | "center" | "right";
export type Environment = "node" | "browser";

export interface Options {
/**
* the font face
* @default 'block'
*/
font: Font;
/**
* the text alignment
* @default 'left'
*/
align: Alignment;
/**
* all colors to use
* @default ['system']
*/
colors: string[];
/**
* the background color
* you can also use `backgroundColor` here as key
* @default 'transparent'
*/
background: string;
/**
* letter spacing
* @default 1
*/
letterSpacing: number;
/**
* the line height
* @default 1
*/
lineHeight: number;
/**
* if the output text should have empty lines on top and on the bottom
* @default true
*/
space: boolean;
/**
* how many character can be on one line
* 0 means no max width and the text will break at the edge of the terminal window
* @default 0
*/
maxLength: number;
/**
* your two gradient colors
* @default false (disabled)
*/
gradient: string[] | false;
/**
* if you want to recalculate the gradient for each new line
* @default false
*/
independentGradient: boolean;
/**
* if this is a transition between colors directly
* @default false
*/
transitionGradient: boolean;
/**
* the environment CFonts is being executed in
* @default 'node'
*/
env: Environment;
}

export interface RenderOutput {
/** The pure string for output with all line breaks */
string: string;
/** Each line of output in an array */
array: string[];
/** The number of lines */
lines: number;
/** All options used */
options: Options;
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -130,5 +130,6 @@
"bin": {
"cfonts": "./bin/index.js"
},
"typings": "./cfonts.d.ts",
"license": "GPL-2.0"
}

0 comments on commit 29e57e9

Please sign in to comment.