-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
chain.ts
128 lines (127 loc) 路 3.26 KB
/
chain.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/** Chainable ansi escape sequence's. */
import type { ImageOptions } from "./ansi_escapes.ts";
/** Chainable ansi escape method declarations. */
export interface Chain<T extends Chain<T>> {
/** Add text. */
text: (text: string) => T;
/** Ring audio bell: `\u0007` */
bel: T;
/** Get cursor position. */
cursorPosition: T;
/**
* Move cursor to x, y, counting from the top left corner.
* @param x Position left.
* @param y Position top.
*/
cursorTo: (x: number, y?: number) => T;
/**
* Move cursor by offset.
* @param x Offset left.
* @param y Offset top.
*/
cursorMove: (x: number, y: number) => T;
/**
* Move cursor up by n lines.
* @param count Number of lines.
*/
cursorUp: T & ((count: number) => T);
/**
* Move cursor down by n lines.
* @param count Number of lines.
*/
cursorDown: T & ((count: number) => T);
/**
* Move cursor forward by n lines.
* @param count Number of lines.
*/
cursorForward: T & ((count: number) => T);
/**
* Move cursor backward by n lines.
* @param count Number of lines.
*/
cursorBackward: T & ((count: number) => T);
/**
* Move cursor to the beginning of the line n lines down.
* @param count Number of lines.
*/
cursorNextLine: T & ((count: number) => T);
/**
* Move cursor to the beginning of the line n lines up.
* @param count Number of lines.
*/
cursorPrevLine: T & ((count: number) => T);
/** Move cursor to first column of current row. */
cursorLeft: T;
/** Hide cursor. */
cursorHide: T;
/** Show cursor. */
cursorShow: T;
/** Save cursor. */
cursorSave: T;
/** Restore cursor. */
cursorRestore: T;
/**
* Scroll window up by n lines.
* @param count Number of lines.
*/
scrollUp: T & ((count: number) => T);
/**
* Scroll window down by n lines.
* @param count Number of lines.
*/
scrollDown: T & ((count: number) => T);
/** Clear screen. */
eraseScreen: T;
/**
* Clear screen up by n lines.
* @param count Number of lines.
*/
eraseUp: T & ((count: number) => T);
/**
* Clear screen down by n lines.
* @param count Number of lines.
*/
eraseDown: T & ((count: number) => T);
/** Clear current line. */
eraseLine: T;
/** Clear to line end. */
eraseLineEnd: T;
/** Clear to line start. */
eraseLineStart: T;
/**
* Clear screen and move cursor by n lines up and move cursor to first column.
* @param count Number of lines.
*/
eraseLines: (count: number) => T;
/** Clear the terminal screen. (Viewport) */
clearScreen: T;
/**
* Clear the whole terminal, including scrollback buffer.
* (Not just the visible part of it).
*/
clearTerminal: T;
/**
* Create link.
* @param text Link text.
* @param url Link url.
* ```
* console.log(
* ansi.link("Click me.", "https://deno.land"),
* );
* ```
*/
link: (text: string, url: string) => T;
/**
* Create image.
* @param buffer Image buffer.
* @param options Image options.
* ```
* const response = await fetch("https://deno.land/images/hashrock_simple.png");
* const imageBuffer: ArrayBuffer = await response.arrayBuffer();
* console.log(
* ansi.image(imageBuffer),
* );
* ```
*/
image: (buffer: string | ArrayBuffer, options?: ImageOptions) => T;
}