@gjermundgaraba/clankermux 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/client/attachment.d.ts +8 -30
- package/dist/client/attachment.js +33 -32
- package/dist/client/client.d.ts +1 -7
- package/dist/client/client.js +20 -50
- package/dist/client/connection.d.ts +0 -18
- package/dist/client/connection.js +0 -17
- package/dist/client/copy.d.ts +3 -20
- package/dist/client/copy.js +22 -44
- package/dist/client/index.d.ts +1 -6
- package/dist/client/index.js +1 -3
- package/dist/client/keyboard.d.ts +1 -27
- package/dist/client/keyboard.js +18 -34
- package/dist/client/listeners.d.ts +10 -0
- package/dist/client/listeners.js +35 -0
- package/dist/client/mount.d.ts +10 -5
- package/dist/client/mount.js +71 -103
- package/dist/client/osc52.d.ts +1 -4
- package/dist/client/osc52.js +31 -23
- package/dist/client/profile.d.ts +0 -6
- package/dist/client/profile.js +0 -6
- package/dist/client/worker.d.ts +16 -10
- package/dist/client/worker.js +201 -301
- package/dist/engine/decoder.d.ts +0 -20
- package/dist/engine/decoder.js +12 -35
- package/dist/engine/index.d.ts +7 -49
- package/dist/engine/index.js +37 -67
- package/dist/engine/keys.d.ts +0 -7
- package/dist/engine/keys.js +9 -15
- package/dist/engine/render.d.ts +21 -17
- package/dist/engine/render.js +67 -37
- package/dist/engine/selection.d.ts +0 -17
- package/dist/engine/selection.js +9 -34
- package/dist/proto/messages.d.ts +800 -475
- package/dist/proto/messages.js +1 -0
- package/dist/renderer/index.d.ts +7 -6
- package/dist/renderer/index.js +73 -54
- package/package.json +1 -5
package/dist/proto/messages.js
CHANGED
package/dist/renderer/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type Frame } from "../engine/
|
|
1
|
+
import { type Cell, type Frame, type PackedCells } from "../engine/render.ts";
|
|
2
|
+
type Cells = Cell[] | PackedCells;
|
|
2
3
|
/** The cell grid in CSS pixels and the fonts to draw with. */
|
|
3
4
|
export interface Metrics {
|
|
4
5
|
cellWidth: number;
|
|
@@ -34,17 +35,17 @@ export declare class CanvasRenderer {
|
|
|
34
35
|
private readonly palette;
|
|
35
36
|
private rows;
|
|
36
37
|
private cursorRow;
|
|
37
|
-
|
|
38
|
-
private mark;
|
|
38
|
+
private lastScrollbackMark;
|
|
39
39
|
private cols;
|
|
40
40
|
private background;
|
|
41
41
|
private foreground;
|
|
42
42
|
constructor(ctx: Context2D, metrics: Metrics, palette: Palette);
|
|
43
|
-
draw(frame: Frame): void;
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
draw(frame: Frame<Cells>): void;
|
|
44
|
+
private eraseLastMark;
|
|
45
|
+
private redrawVacatedCursorRow;
|
|
46
46
|
private markOf;
|
|
47
47
|
private drawRow;
|
|
48
48
|
private font;
|
|
49
49
|
private drawCursor;
|
|
50
50
|
}
|
|
51
|
+
export {};
|
package/dist/renderer/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { FLAG, NO_COLOR } from "../engine/
|
|
1
|
+
import { FLAG, NO_COLOR, PACKED_BG, PACKED_FG, PACKED_FLAGS_MASK, PACKED_STRIDE, PACKED_STYLE, PACKED_UNDERLINE_SHIFT, packedText, } from "../engine/render.js";
|
|
2
2
|
const hex = (color) => `#${color.toString(16).padStart(6, "0")}`;
|
|
3
|
-
/** A cell or cursor colour, or `fallback` when it has none. */
|
|
4
3
|
const css = (color, fallback) => (color === NO_COLOR ? fallback : hex(color));
|
|
5
|
-
|
|
6
|
-
* scrolled back, and where it is in the history. */
|
|
7
|
-
const MARK_WIDTH = 3;
|
|
4
|
+
const SCROLLBACK_MARK_WIDTH_PX = 3;
|
|
8
5
|
/**
|
|
9
6
|
* Draws frames onto a 2D context: changed rows only, then the cursor, then
|
|
10
7
|
* the scrollback mark. Rows are cached so the rows the cursor or the mark
|
|
@@ -16,8 +13,7 @@ export class CanvasRenderer {
|
|
|
16
13
|
palette;
|
|
17
14
|
rows = new Map();
|
|
18
15
|
cursorRow;
|
|
19
|
-
|
|
20
|
-
mark;
|
|
16
|
+
lastScrollbackMark;
|
|
21
17
|
cols = 0;
|
|
22
18
|
background = "";
|
|
23
19
|
foreground = "";
|
|
@@ -27,13 +23,12 @@ export class CanvasRenderer {
|
|
|
27
23
|
this.palette = palette;
|
|
28
24
|
}
|
|
29
25
|
draw(frame) {
|
|
30
|
-
// The frame always carries the default colours.
|
|
31
26
|
this.background = hex(frame.background);
|
|
32
27
|
this.foreground = hex(frame.foreground);
|
|
33
28
|
if (frame.full || frame.cols !== this.cols) {
|
|
34
29
|
this.cols = frame.cols;
|
|
35
30
|
this.rows.clear();
|
|
36
|
-
this.
|
|
31
|
+
this.lastScrollbackMark = undefined;
|
|
37
32
|
this.ctx.globalAlpha = 1;
|
|
38
33
|
this.ctx.fillStyle = this.background;
|
|
39
34
|
this.ctx.fillRect(0, 0, frame.cols * this.metrics.cellWidth, frame.rows * this.metrics.cellHeight);
|
|
@@ -44,28 +39,10 @@ export class CanvasRenderer {
|
|
|
44
39
|
this.drawRow(row);
|
|
45
40
|
drawn.add(row.y);
|
|
46
41
|
}
|
|
47
|
-
// The last mark is erased with the rows under it, every frame: it is
|
|
48
|
-
// translucent, so one drawn over itself would darken.
|
|
49
42
|
const mark = this.markOf(frame);
|
|
50
|
-
|
|
51
|
-
const { cellHeight } = this.metrics;
|
|
52
|
-
const last = Math.ceil((this.mark.top + this.mark.height) / cellHeight);
|
|
53
|
-
for (let y = Math.floor(this.mark.top / cellHeight); y < last; y++) {
|
|
54
|
-
const row = this.rows.get(y);
|
|
55
|
-
if (row && !drawn.has(y)) {
|
|
56
|
-
this.drawRow(row);
|
|
57
|
-
drawn.add(y);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// The cursor's old row is redrawn from the cache when the cursor
|
|
62
|
-
// moved or went away; the engine marks no row dirty for either.
|
|
43
|
+
this.eraseLastMark(drawn);
|
|
63
44
|
const cursor = frame.cursor?.visible ? frame.cursor : undefined;
|
|
64
|
-
|
|
65
|
-
const row = this.rows.get(this.cursorRow);
|
|
66
|
-
if (row)
|
|
67
|
-
this.drawRow(row);
|
|
68
|
-
}
|
|
45
|
+
this.redrawVacatedCursorRow(cursor, drawn);
|
|
69
46
|
this.cursorRow = undefined;
|
|
70
47
|
if (cursor) {
|
|
71
48
|
if (!drawn.has(cursor.y)) {
|
|
@@ -76,17 +53,36 @@ export class CanvasRenderer {
|
|
|
76
53
|
this.drawCursor(cursor);
|
|
77
54
|
this.cursorRow = cursor.y;
|
|
78
55
|
}
|
|
79
|
-
|
|
80
|
-
this.mark = mark;
|
|
56
|
+
this.lastScrollbackMark = mark;
|
|
81
57
|
if (mark) {
|
|
82
58
|
this.ctx.globalAlpha = 0.5;
|
|
83
59
|
this.ctx.fillStyle = this.foreground;
|
|
84
|
-
this.ctx.fillRect(this.cols * this.metrics.cellWidth -
|
|
60
|
+
this.ctx.fillRect(this.cols * this.metrics.cellWidth - SCROLLBACK_MARK_WIDTH_PX, mark.top, SCROLLBACK_MARK_WIDTH_PX, mark.height);
|
|
85
61
|
this.ctx.globalAlpha = 1;
|
|
86
62
|
}
|
|
87
63
|
}
|
|
88
|
-
|
|
89
|
-
|
|
64
|
+
eraseLastMark(drawn) {
|
|
65
|
+
const last = this.lastScrollbackMark;
|
|
66
|
+
if (!last)
|
|
67
|
+
return;
|
|
68
|
+
const { cellHeight } = this.metrics;
|
|
69
|
+
const end = Math.ceil((last.top + last.height) / cellHeight);
|
|
70
|
+
for (let y = Math.floor(last.top / cellHeight); y < end; y++) {
|
|
71
|
+
const row = this.rows.get(y);
|
|
72
|
+
if (row && !drawn.has(y)) {
|
|
73
|
+
this.drawRow(row);
|
|
74
|
+
drawn.add(y);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
redrawVacatedCursorRow(cursor, drawn) {
|
|
79
|
+
const vacated = this.cursorRow;
|
|
80
|
+
if (vacated === undefined || vacated === cursor?.y || drawn.has(vacated))
|
|
81
|
+
return;
|
|
82
|
+
const row = this.rows.get(vacated);
|
|
83
|
+
if (row)
|
|
84
|
+
this.drawRow(row);
|
|
85
|
+
}
|
|
90
86
|
markOf(frame) {
|
|
91
87
|
const { total, offset, len } = frame.scrollbar;
|
|
92
88
|
if (offset + len >= total)
|
|
@@ -101,33 +97,47 @@ export class CanvasRenderer {
|
|
|
101
97
|
this.ctx.globalAlpha = 1;
|
|
102
98
|
this.ctx.fillStyle = this.background;
|
|
103
99
|
this.ctx.fillRect(0, y, this.cols * cellWidth, cellHeight);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
const cells = row.cells;
|
|
101
|
+
const count = Array.isArray(cells) ? cells.length : cells.data.length / PACKED_STRIDE;
|
|
102
|
+
for (let x = 0; x < count; x++) {
|
|
103
|
+
let text, foreground, background, flags, underline;
|
|
104
|
+
if (Array.isArray(cells)) {
|
|
105
|
+
({ text, fg: foreground, bg: background, flags, underline } = cells[x]);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const at = x * PACKED_STRIDE;
|
|
109
|
+
text = packedText(cells, x);
|
|
110
|
+
const style = cells.data[at + PACKED_STYLE];
|
|
111
|
+
foreground = cells.data[at + PACKED_FG];
|
|
112
|
+
background = cells.data[at + PACKED_BG];
|
|
113
|
+
flags = style & PACKED_FLAGS_MASK;
|
|
114
|
+
underline = style >>> PACKED_UNDERLINE_SHIFT;
|
|
115
|
+
}
|
|
116
|
+
if (flags & FLAG.SPACER)
|
|
107
117
|
continue;
|
|
108
|
-
const width =
|
|
109
|
-
let fg = css(
|
|
110
|
-
let bg = css(
|
|
111
|
-
// A selected cell is drawn inverted, an inverse one the other way.
|
|
118
|
+
const width = flags & FLAG.WIDE ? 2 : 1;
|
|
119
|
+
let fg = css(foreground, this.foreground);
|
|
120
|
+
let bg = css(background, this.background);
|
|
112
121
|
const selected = row.selection !== undefined && x >= row.selection[0] && x <= row.selection[1];
|
|
113
|
-
|
|
122
|
+
const inverted = ((flags & FLAG.INVERSE) !== 0) !== selected;
|
|
123
|
+
if (inverted)
|
|
114
124
|
[fg, bg] = [bg, fg];
|
|
115
125
|
if (bg !== this.background) {
|
|
116
126
|
this.ctx.fillStyle = bg;
|
|
117
127
|
this.ctx.fillRect(x * cellWidth, y, width * cellWidth, cellHeight);
|
|
118
128
|
}
|
|
119
|
-
if (
|
|
129
|
+
if (flags & FLAG.INVISIBLE)
|
|
120
130
|
continue;
|
|
121
|
-
this.ctx.globalAlpha =
|
|
131
|
+
this.ctx.globalAlpha = flags & FLAG.FAINT ? 0.6 : 1;
|
|
122
132
|
this.ctx.fillStyle = fg;
|
|
123
|
-
if (
|
|
124
|
-
this.ctx.font = this.font(
|
|
125
|
-
this.ctx.fillText(
|
|
133
|
+
if (text !== "" && text !== " ") {
|
|
134
|
+
this.ctx.font = this.font(flags);
|
|
135
|
+
this.ctx.fillText(text, x * cellWidth, y + baseline);
|
|
126
136
|
}
|
|
127
|
-
if (
|
|
137
|
+
if (underline !== 0) {
|
|
128
138
|
this.ctx.fillRect(x * cellWidth, y + cellHeight - 2, width * cellWidth, 1);
|
|
129
139
|
}
|
|
130
|
-
if (
|
|
140
|
+
if (flags & FLAG.STRIKETHROUGH) {
|
|
131
141
|
this.ctx.fillRect(x * cellWidth, y + Math.floor(cellHeight / 2), width * cellWidth, 1);
|
|
132
142
|
}
|
|
133
143
|
}
|
|
@@ -166,12 +176,21 @@ export class CanvasRenderer {
|
|
|
166
176
|
return;
|
|
167
177
|
default: {
|
|
168
178
|
this.ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (
|
|
179
|
+
const cells = this.rows.get(cursor.y)?.cells;
|
|
180
|
+
let text = "", flags = 0;
|
|
181
|
+
if (Array.isArray(cells)) {
|
|
182
|
+
const cell = cells[cursor.x];
|
|
183
|
+
if (cell)
|
|
184
|
+
({ text, flags } = cell);
|
|
185
|
+
}
|
|
186
|
+
else if (cells && cursor.x < cells.data.length / PACKED_STRIDE) {
|
|
187
|
+
text = packedText(cells, cursor.x);
|
|
188
|
+
flags = cells.data[cursor.x * PACKED_STRIDE + PACKED_STYLE] & PACKED_FLAGS_MASK;
|
|
189
|
+
}
|
|
190
|
+
if (text !== "" && text !== " ") {
|
|
172
191
|
this.ctx.fillStyle = this.background;
|
|
173
|
-
this.ctx.font = this.font(
|
|
174
|
-
this.ctx.fillText(
|
|
192
|
+
this.ctx.font = this.font(flags);
|
|
193
|
+
this.ctx.fillText(text, x, y + baseline);
|
|
175
194
|
}
|
|
176
195
|
}
|
|
177
196
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjermundgaraba/clankermux",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,10 +22,6 @@
|
|
|
22
22
|
"types": "./dist/proto/index.d.ts",
|
|
23
23
|
"default": "./dist/proto/index.js"
|
|
24
24
|
},
|
|
25
|
-
"./engine": {
|
|
26
|
-
"types": "./dist/engine/index.d.ts",
|
|
27
|
-
"default": "./dist/engine/index.js"
|
|
28
|
-
},
|
|
29
25
|
"./renderer": {
|
|
30
26
|
"types": "./dist/renderer/index.d.ts",
|
|
31
27
|
"default": "./dist/renderer/index.js"
|