Skip to content

Commit 4c3ddbc

Browse files
committedNov 4, 2021
Update Documentation
1 parent 35bd1e2 commit 4c3ddbc

File tree

4 files changed

+111
-89
lines changed

4 files changed

+111
-89
lines changed
 

‎docs/index.html

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5-
<title>truwrap 3.0.0 | Documentation</title>
5+
<title>truwrap 4.0.0 | Documentation</title>
66
<meta name='description' content='Smarter terminal text wrapping (handles 24bit color)'>
77
<meta name="viewport" content="width=device-width,initial-scale=1">
88
<link href="assets/css/ace.min.css" rel="stylesheet">
@@ -15,7 +15,7 @@
1515
<div id='split-left' class='overflow-auto fs0 height-viewport-100 sidebar'>
1616
<div class='py1 px2'>
1717
<h3 class="m0 no-anchor">truwrap</h3>
18-
<div class="mb1"><code>3.0.0</code></div>
18+
<div class="mb1"><code>4.0.0</code></div>
1919
<input
2020
placeholder="Filter"
2121
id="filter-input"
@@ -247,7 +247,7 @@ <h3 class='left m0 panel-title' id='rendermode'>
247247
</h3>
248248

249249

250-
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/69968d44e1357706354f44fe2568d2e970e990f8/src/index.js#L16-L21'>
250+
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/35bd1e2ad55be3dd622b3be0879ad9ea19b50fcb/src/index.js#L16-L21'>
251251
<span>src/index.js</span>
252252
</a>
253253

@@ -304,7 +304,7 @@ <h3 class='left m0 panel-title' id='truwrap'>
304304
</h3>
305305

306306

307-
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/69968d44e1357706354f44fe2568d2e970e990f8/src/index.js#L28-L216'>
307+
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/35bd1e2ad55be3dd622b3be0879ad9ea19b50fcb/src/index.js#L28-L216'>
308308
<span>src/index.js</span>
309309
</a>
310310

@@ -457,7 +457,7 @@ <h3 class='left m0 panel-title' id='truwrap'>
457457
<div class='clearfix'>
458458

459459

460-
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/69968d44e1357706354f44fe2568d2e970e990f8/src/index.js#L97-L111'>
460+
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/35bd1e2ad55be3dd622b3be0879ad9ea19b50fcb/src/index.js#L97-L111'>
461461
<span>src/index.js</span>
462462
</a>
463463

@@ -520,7 +520,7 @@ <h3 class='left m0 panel-title' id='truwrap'>
520520
<div class='clearfix'>
521521

522522

523-
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/69968d44e1357706354f44fe2568d2e970e990f8/src/index.js#L118-L127'>
523+
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/35bd1e2ad55be3dd622b3be0879ad9ea19b50fcb/src/index.js#L118-L127'>
524524
<span>src/index.js</span>
525525
</a>
526526

@@ -583,7 +583,7 @@ <h3 class='left m0 panel-title' id='truwrap'>
583583
<div class='clearfix'>
584584

585585

586-
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/69968d44e1357706354f44fe2568d2e970e990f8/src/index.js#L136-L155'>
586+
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/35bd1e2ad55be3dd622b3be0879ad9ea19b50fcb/src/index.js#L136-L155'>
587587
<span>src/index.js</span>
588588
</a>
589589

@@ -669,7 +669,7 @@ <h3 class='left m0 panel-title' id='truwrap'>
669669
<div class='clearfix'>
670670

671671

672-
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/69968d44e1357706354f44fe2568d2e970e990f8/src/index.js#L163-L172'>
672+
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/35bd1e2ad55be3dd622b3be0879ad9ea19b50fcb/src/index.js#L163-L172'>
673673
<span>src/index.js</span>
674674
</a>
675675

@@ -747,7 +747,7 @@ <h3 class='left m0 panel-title' id='truwrap'>
747747
<div class='clearfix'>
748748

749749

750-
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/69968d44e1357706354f44fe2568d2e970e990f8/src/index.js#L179-L188'>
750+
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/35bd1e2ad55be3dd622b3be0879ad9ea19b50fcb/src/index.js#L179-L188'>
751751
<span>src/index.js</span>
752752
</a>
753753

@@ -810,7 +810,7 @@ <h3 class='left m0 panel-title' id='truwrap'>
810810
<div class='clearfix'>
811811

812812

813-
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/69968d44e1357706354f44fe2568d2e970e990f8/src/index.js#L196-L215'>
813+
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/35bd1e2ad55be3dd622b3be0879ad9ea19b50fcb/src/index.js#L196-L215'>
814814
<span>src/index.js</span>
815815
</a>
816816

@@ -896,7 +896,7 @@ <h3 class='left m0 panel-title' id='truwrap'>
896896
</h3>
897897

898898

899-
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/69968d44e1357706354f44fe2568d2e970e990f8/src/index.js#L232-L234'>
899+
<a class='pl3 pr1 right rounded github' href='https://github.com/thebespokepixel/truwrap/blob/35bd1e2ad55be3dd622b3be0879ad9ea19b50fcb/src/index.js#L232-L234'>
900900
<span>src/index.js</span>
901901
</a>
902902

‎index.d.ts

+97-75
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,122 @@
1-
export const console: any;
21
/**
3-
* Creates an image.
4-
* @private
5-
* @param {string} source The source
6-
* @return {Image} A configured (but not yet loaded) image.
7-
*/
8-
export function createImage(source: string): Image;
9-
export const locale: string;
10-
export const metadata: {
11-
readonly name: string;
12-
readonly description: string;
13-
readonly copyright: any;
14-
readonly license: string;
15-
readonly bugs: string;
16-
readonly bin: string;
17-
version: (style?: number) => string;
18-
};
19-
/**
20-
* Organise a block of delimited text into a panel
21-
* @private
22-
* @param {string} buffer_ Input plain text.
23-
* @param {string} delimiter_ Field delimiter.
24-
* @param {number} width_ Panel width.
25-
* @return {object} The columnify configuration.
26-
*/
27-
declare function panel(buffer_: string, delimiter_: string, width_: number): object;
28-
export const renderMode: import("@thebespokepixel/n-selector").NSelector;
29-
/**
30-
* Create a text wrapping instance.
2+
* Truwrap - take input from write() and composed a wrapped text block.
313
*
32-
* @param {object} options options object
33-
* @param {number} options.left Left margin.
34-
* @param {number} options.right Right margin.
35-
* @param {number} options.width Manually set view width.
36-
* @param {mode} options.mode [soft | hyphen | hard | keep | container]
37-
* @param {number} options.tabWidth Desired width of TAB character.
38-
* @param {Stream.writable} options.outStream Where to direct output.
39-
* @param {Regexp} options.tokenRegex Override the tokenisers regexp.
40-
* @return {api} A truwrap api instance.
4+
* @class Truwrap (name)
415
*/
42-
export function truwrap({ left, right, width, mode, tabWidth, outStream, tokenRegex }: {
43-
left: number;
44-
right: number;
45-
width: number;
46-
mode: any;
47-
tabWidth: number;
6+
export class Truwrap {
7+
/**
8+
* The base Truwrap instance/api
9+
*
10+
* @param {Object} options options object
11+
* @param {number} [options.left=2] Left margin.
12+
* @param {number} [options.right=2] Right margin.
13+
* @param {number} options.width Manually set view width.
14+
* @param {string} [options.mode='soft'] [soft | hyphen | hard | keep | container
15+
* @param {number} [options.tabWidth=4] Desired width of TAB character.
16+
* @param {Stream.writable} options.outStream Where to direct output.
17+
* @param {Regexp} options.tokenRegex Override the tokenisers regexp.
18+
*/
19+
constructor({ left, right, width, mode, tabWidth, outStream, tokenRegex }: {
20+
left?: number;
21+
right?: number;
22+
width: number;
23+
mode?: string;
24+
tabWidth?: number;
25+
outStream: any;
26+
tokenRegex: any;
27+
});
4828
outStream: any;
49-
tokenRegex: any;
50-
}): {
29+
buffer: string;
30+
mode: string;
31+
ttyActive: boolean;
32+
ttyWidth: any;
33+
viewWidth: number;
34+
viewHandler: {};
5135
/**
5236
* End a block, setting blocking mode and flushing buffers if needed.
53-
* @function
54-
* @return {undefined} has side effect of writing to stream
37+
*
38+
* @return {string} The wrapped output, has side effect of writing to stream if defined.
5539
*/
56-
end(): undefined;
40+
end(): string;
5741
/**
5842
* Fetch the width in characters of the wrapping view.
59-
* @function
60-
* @return {number} wrapping width
43+
*
44+
* @return {number} The width.
6145
*/
62-
getWidth: typeof unimplemented;
46+
getWidth(): number;
6347
/**
6448
* Create a multicolumn panel within this view
65-
* @function
66-
* @param {panelObject} content - Object for columnify
67-
* @param {object} configuration - Configuration for columnify
68-
* @return {string} - The rendered panel.
49+
*
50+
* @param {panelObject} content_ Object for columnify
51+
* @param {Object} configuration Configuration for columnify
52+
* @return {Object} this instance, to allow chaining
6953
*/
70-
panel(content: any, configuration: object): string;
54+
panel(content_: any, configuration: any): any;
7155
/**
7256
* Generate linebreaks within this view
73-
* @function
74-
* @param {number} newlines - number of new lines to add.
75-
* @return {api} has side effect of writing to stream.
57+
*
58+
* @param {number} newlines number of new lines to add.
59+
* @return {Object} this instance, to allow chaining
7660
*/
7761
break(newlines?: number): any;
7862
/**
7963
* Similar to css' clear. Write a clearing newline to the stream.
80-
* @function
81-
* @return {api} has side effect of writing to stream.
64+
*
65+
* @return {Object} this instance, to allow chaining
8266
*/
8367
clear(): any;
8468
/**
8569
* Write text via the wrapping logic
86-
* @function
87-
* @param {string} text - The raw, unwrapped test to wrap.
88-
* @return {api} has side effect of writing to stream.
70+
*
71+
* @param {string} content_ The content
72+
* @return {Object} this instance, to allow chaining
8973
*/
90-
write(text: string): any;
91-
};
74+
write(content_: string): any;
75+
}
76+
/**
77+
* Creates an image.
78+
* @private
79+
* @param {string} source The source
80+
* @return {Image} A configured (but not yet loaded) image.
81+
*/
82+
export function createImage(source: string): Image;
83+
/**
84+
* Organise a block of delimited text into a panel
85+
* @private
86+
* @param {string} buffer_ Input plain text.
87+
* @param {string} delimiter_ Field delimiter.
88+
* @param {number} width_ Panel width.
89+
* @return {Object} The columnify configuration.
90+
*/
91+
declare function panel(buffer_: string, delimiter_: string, width_: number): any;
92+
/**
93+
* Create an n-selector for module modes
94+
*
95+
* @type {Function}
96+
*/
97+
export const renderMode: Function;
98+
/**
99+
* Create a text wrapping instance.
100+
*
101+
* @param {Object} options options object
102+
* @param {number} [options.left=2] Left margin.
103+
* @param {number} [options.right=2] Right margin.
104+
* @param {number} options.width Manually set view width.
105+
* @param {string} [options.mode='soft'] [soft | hyphen | hard | keep | container
106+
* @param {number} [options.tabWidth=4] Desired width of TAB character.
107+
* @param {Stream.writable} options.outStream Where to direct output.
108+
* @param {Regexp} options.tokenRegex Override the tokenisers regexp.
109+
* @return {Truwrap} { description_of_the_return_value }
110+
*/
111+
export function truwrap(options: {
112+
left?: number;
113+
right?: number;
114+
width: number;
115+
mode?: string;
116+
tabWidth?: number;
117+
outStream: any;
118+
tokenRegex: any;
119+
}): Truwrap;
92120
/**
93121
* Provides an image formatted for inclusion in the TTY
94122
* @private
@@ -109,20 +137,14 @@ declare class Image {
109137
filePath: any;
110138
/**
111139
* Load and render the image into the CLI
112-
* @param {object} options - The options to set
140+
* @param {Object} options - The options to set
113141
* @property {number} align - The line count needed to realign the cursor.
114142
* @property {boolean} stretch - Do we stretch the image to match the width
115143
* and height.
116144
* @property {boolean} nobreak - Do we clear the image with a newline?
117145
* @return {string} The string to insert into the output buffer, with base64
118146
* encoded image.
119147
*/
120-
render(options: object): string;
148+
render(options: any): string;
121149
}
122-
/**
123-
* Throw a error if a method remains unimplemented
124-
* @private
125-
* @return {undefined}
126-
*/
127-
declare function unimplemented(): undefined;
128150
export { panel as parsePanel };

‎package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "truwrap",
3-
"version": "3.0.0",
3+
"version": "4.0.0",
44
"description": "Smarter terminal text wrapping (handles 24bit color)",
55
"author": "Mark Griffiths <mark@thebespokepixel.com> (http://thebespokepixel.com/)",
66
"main": "index.js",

0 commit comments

Comments
 (0)
Please sign in to comment.