@gjermundgaraba/clankermux 0.4.1 → 0.5.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/dist/client/attachment.d.ts +1 -2
- package/dist/client/attachment.js +13 -5
- package/dist/client/client.d.ts +1 -5
- package/dist/client/client.js +14 -39
- package/dist/client/copy.d.ts +4 -7
- package/dist/client/copy.js +21 -22
- package/dist/client/index.d.ts +1 -6
- package/dist/client/index.js +1 -3
- package/dist/client/listeners.d.ts +8 -0
- package/dist/client/listeners.js +19 -0
- package/dist/client/mount.d.ts +15 -5
- package/dist/client/mount.js +64 -44
- package/dist/client/osc52.js +11 -6
- package/dist/client/worker.d.ts +16 -3
- package/dist/client/worker.js +137 -117
- package/dist/engine/decoder.js +4 -8
- package/dist/engine/index.d.ts +7 -2
- package/dist/engine/index.js +32 -21
- package/dist/engine/render.d.ts +20 -5
- package/dist/engine/render.js +46 -16
- package/dist/engine/selection.js +1 -4
- package/dist/proto/messages.d.ts +800 -475
- package/dist/proto/messages.js +1 -0
- package/dist/renderer/index.d.ts +4 -2
- package/dist/renderer/index.js +42 -19
- package/package.json +1 -1
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;
|
|
@@ -40,7 +41,7 @@ export declare class CanvasRenderer {
|
|
|
40
41
|
private background;
|
|
41
42
|
private foreground;
|
|
42
43
|
constructor(ctx: Context2D, metrics: Metrics, palette: Palette);
|
|
43
|
-
draw(frame: Frame): void;
|
|
44
|
+
draw(frame: Frame<Cells>): void;
|
|
44
45
|
/** The scrollback mark for `frame`: the viewport's share of the history
|
|
45
46
|
* at the right edge, while the view is scrolled back. */
|
|
46
47
|
private markOf;
|
|
@@ -48,3 +49,4 @@ export declare class CanvasRenderer {
|
|
|
48
49
|
private font;
|
|
49
50
|
private drawCursor;
|
|
50
51
|
}
|
|
52
|
+
export {};
|
package/dist/renderer/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FLAG, NO_COLOR } from "../engine/
|
|
1
|
+
import { FLAG, NO_COLOR, PACKED_STRIDE, packedText } from "../engine/render.js";
|
|
2
2
|
const hex = (color) => `#${color.toString(16).padStart(6, "0")}`;
|
|
3
3
|
/** A cell or cursor colour, or `fallback` when it has none. */
|
|
4
4
|
const css = (color, fallback) => (color === NO_COLOR ? fallback : hex(color));
|
|
@@ -101,33 +101,46 @@ export class CanvasRenderer {
|
|
|
101
101
|
this.ctx.globalAlpha = 1;
|
|
102
102
|
this.ctx.fillStyle = this.background;
|
|
103
103
|
this.ctx.fillRect(0, y, this.cols * cellWidth, cellHeight);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
const cells = row.cells;
|
|
105
|
+
const count = Array.isArray(cells) ? cells.length : cells.data.length / PACKED_STRIDE;
|
|
106
|
+
for (let x = 0; x < count; x++) {
|
|
107
|
+
let text, foreground, background, flags, underline;
|
|
108
|
+
if (Array.isArray(cells)) {
|
|
109
|
+
({ text, fg: foreground, bg: background, flags, underline } = cells[x]);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const at = x * PACKED_STRIDE;
|
|
113
|
+
text = packedText(cells, x);
|
|
114
|
+
foreground = cells.data[at + 1];
|
|
115
|
+
background = cells.data[at + 2];
|
|
116
|
+
flags = cells.data[at + 3] & 0xffff;
|
|
117
|
+
underline = cells.data[at + 3] >>> 16;
|
|
118
|
+
}
|
|
119
|
+
if (flags & FLAG.SPACER)
|
|
107
120
|
continue;
|
|
108
|
-
const width =
|
|
109
|
-
let fg = css(
|
|
110
|
-
let bg = css(
|
|
121
|
+
const width = flags & FLAG.WIDE ? 2 : 1;
|
|
122
|
+
let fg = css(foreground, this.foreground);
|
|
123
|
+
let bg = css(background, this.background);
|
|
111
124
|
// A selected cell is drawn inverted, an inverse one the other way.
|
|
112
125
|
const selected = row.selection !== undefined && x >= row.selection[0] && x <= row.selection[1];
|
|
113
|
-
if (((
|
|
126
|
+
if (((flags & FLAG.INVERSE) !== 0) !== selected)
|
|
114
127
|
[fg, bg] = [bg, fg];
|
|
115
128
|
if (bg !== this.background) {
|
|
116
129
|
this.ctx.fillStyle = bg;
|
|
117
130
|
this.ctx.fillRect(x * cellWidth, y, width * cellWidth, cellHeight);
|
|
118
131
|
}
|
|
119
|
-
if (
|
|
132
|
+
if (flags & FLAG.INVISIBLE)
|
|
120
133
|
continue;
|
|
121
|
-
this.ctx.globalAlpha =
|
|
134
|
+
this.ctx.globalAlpha = flags & FLAG.FAINT ? 0.6 : 1;
|
|
122
135
|
this.ctx.fillStyle = fg;
|
|
123
|
-
if (
|
|
124
|
-
this.ctx.font = this.font(
|
|
125
|
-
this.ctx.fillText(
|
|
136
|
+
if (text !== "" && text !== " ") {
|
|
137
|
+
this.ctx.font = this.font(flags);
|
|
138
|
+
this.ctx.fillText(text, x * cellWidth, y + baseline);
|
|
126
139
|
}
|
|
127
|
-
if (
|
|
140
|
+
if (underline !== 0) {
|
|
128
141
|
this.ctx.fillRect(x * cellWidth, y + cellHeight - 2, width * cellWidth, 1);
|
|
129
142
|
}
|
|
130
|
-
if (
|
|
143
|
+
if (flags & FLAG.STRIKETHROUGH) {
|
|
131
144
|
this.ctx.fillRect(x * cellWidth, y + Math.floor(cellHeight / 2), width * cellWidth, 1);
|
|
132
145
|
}
|
|
133
146
|
}
|
|
@@ -167,11 +180,21 @@ export class CanvasRenderer {
|
|
|
167
180
|
default: {
|
|
168
181
|
this.ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
169
182
|
// The cell's text in the background colour, over the block.
|
|
170
|
-
const
|
|
171
|
-
|
|
183
|
+
const cells = this.rows.get(cursor.y)?.cells;
|
|
184
|
+
let text = "", flags = 0;
|
|
185
|
+
if (Array.isArray(cells)) {
|
|
186
|
+
const cell = cells[cursor.x];
|
|
187
|
+
if (cell)
|
|
188
|
+
({ text, flags } = cell);
|
|
189
|
+
}
|
|
190
|
+
else if (cells && cursor.x < cells.data.length / PACKED_STRIDE) {
|
|
191
|
+
text = packedText(cells, cursor.x);
|
|
192
|
+
flags = cells.data[cursor.x * PACKED_STRIDE + 3] & 0xffff;
|
|
193
|
+
}
|
|
194
|
+
if (text !== "" && text !== " ") {
|
|
172
195
|
this.ctx.fillStyle = this.background;
|
|
173
|
-
this.ctx.font = this.font(
|
|
174
|
-
this.ctx.fillText(
|
|
196
|
+
this.ctx.font = this.font(flags);
|
|
197
|
+
this.ctx.fillText(text, x, y + baseline);
|
|
175
198
|
}
|
|
176
199
|
}
|
|
177
200
|
}
|