@gjermundgaraba/clankermux 0.5.0 → 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.
@@ -1,5 +1,4 @@
1
1
  import { type Engine, type Scrollbar, type Terminal } from "./index.ts";
2
- /** Style flag bits of a [`Cell`]. */
3
2
  export declare const FLAG: {
4
3
  readonly BOLD: 1;
5
4
  readonly ITALIC: 2;
@@ -9,12 +8,9 @@ export declare const FLAG: {
9
8
  readonly INVISIBLE: 32;
10
9
  readonly STRIKETHROUGH: 64;
11
10
  readonly OVERLINE: 128;
12
- /** The cell is the left half of a wide character. */
13
11
  readonly WIDE: 256;
14
- /** The cell is the right half of a wide character; draw nothing. */
15
12
  readonly SPACER: 512;
16
13
  };
17
- /** No explicit colour; the renderer uses the default. */
18
14
  export declare const NO_COLOR = -1;
19
15
  export interface Cell {
20
16
  /** The grapheme, empty for a blank cell. */
@@ -26,7 +22,6 @@ export interface Cell {
26
22
  /** `GhosttySgrUnderline`: 0 none, 1 single, 2 double, 3 curly, 4 dotted, 5 dashed. */
27
23
  underline: number;
28
24
  }
29
- /** `GhosttyRenderStateCursorVisualStyle` by name. */
30
25
  declare const CURSOR_STYLES: readonly ["bar", "block", "underline", "block_hollow"];
31
26
  type CursorStyle = (typeof CURSOR_STYLES)[number];
32
27
  export interface FrameRow<Cells = Cell[]> {
@@ -56,10 +51,13 @@ export interface Frame<Cells = Cell[]> {
56
51
  * above the last row (`offset + len < total`). */
57
52
  scrollbar: Scrollbar;
58
53
  }
59
- /** Four signed words per cell: text code, foreground, background, style.
60
- * Text is a Unicode scalar (0 for blank), or -(grapheme index + 1).
61
- * Style holds flags in its low 16 bits and underline in its high 16. */
62
54
  export declare const PACKED_STRIDE = 4;
55
+ export declare const PACKED_TEXT = 0;
56
+ export declare const PACKED_FG = 1;
57
+ export declare const PACKED_BG = 2;
58
+ export declare const PACKED_STYLE = 3;
59
+ export declare const PACKED_FLAGS_MASK = 65535;
60
+ export declare const PACKED_UNDERLINE_SHIFT = 16;
63
61
  export interface PackedCells {
64
62
  data: Int32Array<ArrayBuffer>;
65
63
  /** Only multi-codepoint cells need strings; these are cloned on transfer. */
@@ -67,10 +65,6 @@ export interface PackedCells {
67
65
  }
68
66
  export type PackedFrame = Frame<PackedCells>;
69
67
  export declare function packedText(cells: PackedCells, x: number): string;
70
- /**
71
- * The engine's render state: updated from a terminal, read into a
72
- * [`Frame`] of the rows that changed, then cleaned.
73
- */
74
68
  export declare class RenderState {
75
69
  readonly engine: Engine;
76
70
  private readonly state;
@@ -79,22 +73,17 @@ export declare class RenderState {
79
73
  private readonly keys;
80
74
  private readonly tags;
81
75
  private readonly wide;
82
- /** `GhosttyCell` bit fields, from the manifest. */
83
76
  private readonly cell;
84
77
  private readonly cursorStyles;
85
78
  constructor(engine: Engine);
86
- /** Captures the terminal and returns the rows that changed since the last `clean`. */
87
79
  update(term: Terminal): Frame;
88
- /** Captures transferable cell buffers without allocating Cell objects.
89
- * Each row owns its buffer so the renderer can retain rows independently. */
90
80
  updatePacked(term: Terminal): PackedFrame;
81
+ takePackedFrame(term: Terminal): PackedFrame;
91
82
  private frame;
92
- /** The row's selected cells, or undefined when the selection misses it. */
93
83
  private rowSelection;
94
84
  private readRow;
95
85
  private color;
96
86
  private graphemes;
97
- /** Clears the captured dirty rows; later terminal writes remain dirty. */
98
87
  clean(): void;
99
88
  free(): void;
100
89
  }
@@ -1,5 +1,4 @@
1
1
  import { EngineError } from "./index.js";
2
- /** Style flag bits of a [`Cell`]. */
3
2
  export const FLAG = {
4
3
  BOLD: 1,
5
4
  ITALIC: 2,
@@ -9,27 +8,33 @@ export const FLAG = {
9
8
  INVISIBLE: 32,
10
9
  STRIKETHROUGH: 64,
11
10
  OVERLINE: 128,
12
- /** The cell is the left half of a wide character. */
13
11
  WIDE: 256,
14
- /** The cell is the right half of a wide character; draw nothing. */
15
12
  SPACER: 512,
16
13
  };
17
- /** No explicit colour; the renderer uses the default. */
18
14
  export const NO_COLOR = -1;
19
- /** `GhosttyRenderStateCursorVisualStyle` by name. */
20
15
  const CURSOR_STYLES = ["bar", "block", "underline", "block_hollow"];
21
- /** Four signed words per cell: text code, foreground, background, style.
22
- * Text is a Unicode scalar (0 for blank), or -(grapheme index + 1).
23
- * Style holds flags in its low 16 bits and underline in its high 16. */
24
16
  export const PACKED_STRIDE = 4;
17
+ export const PACKED_TEXT = 0;
18
+ export const PACKED_FG = 1;
19
+ export const PACKED_BG = 2;
20
+ export const PACKED_STYLE = 3;
21
+ export const PACKED_FLAGS_MASK = 0xffff;
22
+ export const PACKED_UNDERLINE_SHIFT = 16;
23
+ function scratchLayout(e, types) {
24
+ const offsets = [];
25
+ let size = 0;
26
+ for (const name of types) {
27
+ const align = e.alignOf(name);
28
+ size = Math.ceil(size / align) * align;
29
+ offsets.push(size);
30
+ size += e.sizeOf(name);
31
+ }
32
+ return { offsets, size };
33
+ }
25
34
  export function packedText(cells, x) {
26
- const code = cells.data[x * PACKED_STRIDE];
35
+ const code = cells.data[x * PACKED_STRIDE + PACKED_TEXT];
27
36
  return code < 0 ? cells.graphemes[-code - 1] : code === 0 ? "" : String.fromCodePoint(code);
28
37
  }
29
- /**
30
- * The engine's render state: updated from a terminal, read into a
31
- * [`Frame`] of the rows that changed, then cleaned.
32
- */
33
38
  export class RenderState {
34
39
  engine;
35
40
  state;
@@ -38,7 +43,6 @@ export class RenderState {
38
43
  keys;
39
44
  tags;
40
45
  wide;
41
- /** `GhosttyCell` bit fields, from the manifest. */
42
46
  cell;
43
47
  cursorStyles;
44
48
  constructor(engine) {
@@ -74,7 +78,6 @@ export class RenderState {
74
78
  };
75
79
  this.cursorStyles = new Map(CURSOR_STYLES.map((style) => [engine.enumValue("GhosttyRenderStateCursorVisualStyle", style.toUpperCase()), style]));
76
80
  }
77
- /** Captures the terminal and returns the rows that changed since the last `clean`. */
78
81
  update(term) {
79
82
  return this.frame(term, (cols) => {
80
83
  const cells = [];
@@ -84,22 +87,26 @@ export class RenderState {
84
87
  return cells;
85
88
  });
86
89
  }
87
- /** Captures transferable cell buffers without allocating Cell objects.
88
- * Each row owns its buffer so the renderer can retain rows independently. */
89
90
  updatePacked(term) {
90
91
  return this.frame(term, (cols) => {
91
92
  const data = new Int32Array(cols * PACKED_STRIDE);
92
93
  const graphemes = [];
93
94
  let at = 0;
94
95
  this.readRow(cols, (codepoint, text, fg, bg, flags, underline) => {
95
- data[at++] = text === "" ? codepoint : -graphemes.push(text);
96
- data[at++] = fg;
97
- data[at++] = bg;
98
- data[at++] = flags | (underline << 16);
96
+ data[at + PACKED_TEXT] = text === "" ? codepoint : -graphemes.push(text);
97
+ data[at + PACKED_FG] = fg;
98
+ data[at + PACKED_BG] = bg;
99
+ data[at + PACKED_STYLE] = flags | (underline << PACKED_UNDERLINE_SHIFT);
100
+ at += PACKED_STRIDE;
99
101
  });
100
102
  return { data: data.subarray(0, at), graphemes };
101
103
  });
102
104
  }
105
+ takePackedFrame(term) {
106
+ const frame = this.updatePacked(term);
107
+ this.clean();
108
+ return frame;
109
+ }
103
110
  frame(term, readRow) {
104
111
  const e = this.engine;
105
112
  e.check("ghostty_render_state_update", this.state, term.handle);
@@ -155,7 +162,6 @@ export class RenderState {
155
162
  });
156
163
  return { cols, rows, full, background, foreground, cursor, lines, scrollbar };
157
164
  }
158
- /** The row's selected cells, or undefined when the selection misses it. */
159
165
  rowSelection() {
160
166
  const e = this.engine;
161
167
  const size = e.sizeOf("GhosttyRenderStateRowSelection");
@@ -175,15 +181,11 @@ export class RenderState {
175
181
  });
176
182
  const styleSize = e.sizeOf("GhosttyStyle");
177
183
  let count = 0;
178
- // Scratch: raw cell (8), colour (3, padded to 8), the 8-aligned style,
179
- // a UTF-8 buffer struct and its bytes.
180
184
  const utf8Cap = 64;
181
- e.scratch(16 + styleSize + e.sizeOf("GhosttyBuffer") + utf8Cap, (scratch) => {
182
- const raw = scratch;
183
- const color = scratch + 8;
184
- const style = scratch + 16;
185
- const buffer = style + styleSize;
186
- const utf8 = buffer + e.sizeOf("GhosttyBuffer");
185
+ const layout = scratchLayout(e, ["GhosttyCell", "GhosttyColorRgb", "GhosttyStyle", "GhosttyBuffer"]);
186
+ e.scratch(layout.size + utf8Cap, (scratch) => {
187
+ const [raw, color, style, buffer] = layout.offsets.map((offset) => scratch + offset);
188
+ const utf8 = scratch + layout.size;
187
189
  while (e.call("ghostty_render_state_row_cells_next", this.cells) && count < cols) {
188
190
  e.check("ghostty_render_state_row_cells_get", this.cells, this.keys.cell["RAW"], raw);
189
191
  const tag = e.readBits(raw, this.cell.tag);
@@ -253,7 +255,6 @@ export class RenderState {
253
255
  }
254
256
  if (code !== e.result.OUT_OF_SPACE)
255
257
  throw new EngineError("ghostty_render_state_row_cells_get", code);
256
- // The buffer struct reports the needed length; retry through it.
257
258
  const needed = e.field("GhosttyBuffer", buffer, "len");
258
259
  return new TextDecoder().decode(e.growing("ghostty_render_state_row_cells_get", needed, (big, bigCap, len) => {
259
260
  e.view.setUint32(buffer + e.offsetOf("GhosttyBuffer", "ptr"), big, true);
@@ -263,7 +264,6 @@ export class RenderState {
263
264
  return again;
264
265
  }));
265
266
  }
266
- /** Clears the captured dirty rows; later terminal writes remain dirty. */
267
267
  clean() {
268
268
  this.engine.check("ghostty_render_state_clean", this.state);
269
269
  }
@@ -5,33 +5,16 @@ export interface CellPoint {
5
5
  x: number;
6
6
  y: number;
7
7
  }
8
- /**
9
- * Mouse selection through the engine's gesture: a press, then drags, then
10
- * a release. A single press selects nothing; a drag selects from it by
11
- * cells, a double press a word and a triple press a line, dragging by
12
- * words or lines. The gesture tracks its anchor in the terminal, so
13
- * output between press and drag does not move it.
14
- */
15
8
  export declare class SelectionGesture {
16
9
  readonly engine: Engine;
17
10
  private gesture;
18
11
  private readonly events;
19
- /** The terminal the gesture tracks its anchor in. */
20
12
  private term;
21
13
  constructor(engine: Engine);
22
- /** Presses at `at` (`time` in ms); the selection to install, or
23
- * undefined for none (a single press). */
24
14
  press(term: Terminal, at: CellPoint, time: number): Uint8Array | undefined;
25
- /** Drags to `at`; the selection from the press, or undefined when the
26
- * pointer has not left the pressed cell. */
27
15
  drag(term: Terminal, at: CellPoint): Uint8Array | undefined;
28
16
  release(term: Terminal, at: CellPoint): void;
29
- /** Starts afresh, for a terminal freed or about to be: `term` when it
30
- * is still alive, to release the tracked anchor in it, else none. The
31
- * caller says so, since a new terminal may have the handle of a freed
32
- * one. */
33
17
  forget(term?: Terminal): void;
34
- /** A gesture is in one terminal. */
35
18
  private follow;
36
19
  private set;
37
20
  private apply;
@@ -1,21 +1,9 @@
1
- /** Pixels per cell in the gesture's geometry: positions are in cells,
2
- * scaled to whole numbers. */
3
- const SCALE = 1000;
4
- /** Clicks closer together than this, and within a cell of each other,
5
- * count up to a word (two) and a line (three). */
6
- const REPEAT_MS = 500;
7
- /**
8
- * Mouse selection through the engine's gesture: a press, then drags, then
9
- * a release. A single press selects nothing; a drag selects from it by
10
- * cells, a double press a word and a triple press a line, dragging by
11
- * words or lines. The gesture tracks its anchor in the terminal, so
12
- * output between press and drag does not move it.
13
- */
1
+ const PIXELS_PER_CELL = 1000;
2
+ const MULTI_CLICK_INTERVAL_MS = 500;
14
3
  export class SelectionGesture {
15
4
  engine;
16
5
  gesture;
17
6
  events;
18
- /** The terminal the gesture tracks its anchor in. */
19
7
  term;
20
8
  constructor(engine) {
21
9
  this.engine = engine;
@@ -23,12 +11,10 @@ export class SelectionGesture {
23
11
  const event = (type) => engine.construct("ghostty_selection_gesture_event_new", engine.enumValue("GhosttySelectionGestureEventType", type));
24
12
  this.events = { press: event("PRESS"), drag: event("DRAG"), release: event("RELEASE") };
25
13
  const f64 = new Uint8Array(8);
26
- new DataView(f64.buffer).setFloat64(0, SCALE, true);
14
+ new DataView(f64.buffer).setFloat64(0, PIXELS_PER_CELL, true);
27
15
  this.set(this.events.press, "REPEAT_DISTANCE", f64);
28
- this.set(this.events.press, "REPEAT_INTERVAL_NS", u64(REPEAT_MS * 1e6));
16
+ this.set(this.events.press, "REPEAT_INTERVAL_NS", u64(MULTI_CLICK_INTERVAL_MS * 1e6));
29
17
  }
30
- /** Presses at `at` (`time` in ms); the selection to install, or
31
- * undefined for none (a single press). */
32
18
  press(term, at, time) {
33
19
  this.follow(term);
34
20
  this.set(this.events.press, "REF", term.gridRef(at));
@@ -36,17 +22,15 @@ export class SelectionGesture {
36
22
  this.set(this.events.press, "TIME_NS", u64(time * 1e6));
37
23
  return this.apply(term, this.events.press);
38
24
  }
39
- /** Drags to `at`; the selection from the press, or undefined when the
40
- * pointer has not left the pressed cell. */
41
25
  drag(term, at) {
42
26
  if (this.term !== term.handle)
43
27
  return undefined;
44
28
  const geometry = new Uint8Array(16);
45
29
  const view = new DataView(geometry.buffer);
46
30
  view.setUint32(0, term.cols, true);
47
- view.setUint32(4, SCALE, true);
31
+ view.setUint32(4, PIXELS_PER_CELL, true);
48
32
  view.setUint32(8, 0, true);
49
- view.setUint32(12, term.rows * SCALE, true);
33
+ view.setUint32(12, term.rows * PIXELS_PER_CELL, true);
50
34
  this.set(this.events.drag, "REF", term.gridRef(at));
51
35
  this.set(this.events.drag, "POSITION", position(at));
52
36
  this.set(this.events.drag, "GEOMETRY", geometry);
@@ -58,10 +42,6 @@ export class SelectionGesture {
58
42
  this.set(this.events.release, "REF", term.gridRef(at));
59
43
  this.apply(term, this.events.release);
60
44
  }
61
- /** Starts afresh, for a terminal freed or about to be: `term` when it
62
- * is still alive, to release the tracked anchor in it, else none. The
63
- * caller says so, since a new terminal may have the handle of a freed
64
- * one. */
65
45
  forget(term) {
66
46
  if (this.term === undefined)
67
47
  return;
@@ -69,7 +49,6 @@ export class SelectionGesture {
69
49
  this.gesture = this.engine.construct("ghostty_selection_gesture_new");
70
50
  this.term = undefined;
71
51
  }
72
- /** A gesture is in one terminal. */
73
52
  follow(term) {
74
53
  if (this.term !== term.handle)
75
54
  this.forget();
@@ -101,11 +80,10 @@ function u64(value) {
101
80
  new DataView(bytes.buffer).setBigUint64(0, BigInt(Math.round(value)), true);
102
81
  return bytes;
103
82
  }
104
- /** A `GhosttySurfacePosition` for `at`, in the gesture's scaled pixels. */
105
83
  function position(at) {
106
84
  const bytes = new Uint8Array(16);
107
85
  const view = new DataView(bytes.buffer);
108
- view.setFloat64(0, at.x * SCALE, true);
109
- view.setFloat64(8, at.y * SCALE, true);
86
+ view.setFloat64(0, at.x * PIXELS_PER_CELL, true);
87
+ view.setFloat64(8, at.y * PIXELS_PER_CELL, true);
110
88
  return bytes;
111
89
  }
@@ -35,15 +35,14 @@ export declare class CanvasRenderer {
35
35
  private readonly palette;
36
36
  private rows;
37
37
  private cursorRow;
38
- /** The scrollback mark drawn last, in pixels from the top. */
39
- private mark;
38
+ private lastScrollbackMark;
40
39
  private cols;
41
40
  private background;
42
41
  private foreground;
43
42
  constructor(ctx: Context2D, metrics: Metrics, palette: Palette);
44
43
  draw(frame: Frame<Cells>): void;
45
- /** The scrollback mark for `frame`: the viewport's share of the history
46
- * at the right edge, while the view is scrolled back. */
44
+ private eraseLastMark;
45
+ private redrawVacatedCursorRow;
47
46
  private markOf;
48
47
  private drawRow;
49
48
  private font;
@@ -1,10 +1,7 @@
1
- import { FLAG, NO_COLOR, PACKED_STRIDE, packedText } from "../engine/render.js";
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
- /** Width in CSS pixels of the mark at the right edge that shows the view
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
- /** The scrollback mark drawn last, in pixels from the top. */
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.mark = undefined;
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
- if (this.mark) {
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
- if (this.cursorRow !== undefined && this.cursorRow !== cursor?.y && !drawn.has(this.cursorRow)) {
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
- // Over everything, on rows just drawn.
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 - MARK_WIDTH, mark.top, MARK_WIDTH, mark.height);
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
- /** The scrollback mark for `frame`: the viewport's share of the history
89
- * at the right edge, while the view is scrolled back. */
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)
@@ -111,19 +107,20 @@ export class CanvasRenderer {
111
107
  else {
112
108
  const at = x * PACKED_STRIDE;
113
109
  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;
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;
118
115
  }
119
116
  if (flags & FLAG.SPACER)
120
117
  continue;
121
118
  const width = flags & FLAG.WIDE ? 2 : 1;
122
119
  let fg = css(foreground, this.foreground);
123
120
  let bg = css(background, this.background);
124
- // A selected cell is drawn inverted, an inverse one the other way.
125
121
  const selected = row.selection !== undefined && x >= row.selection[0] && x <= row.selection[1];
126
- if (((flags & FLAG.INVERSE) !== 0) !== selected)
122
+ const inverted = ((flags & FLAG.INVERSE) !== 0) !== selected;
123
+ if (inverted)
127
124
  [fg, bg] = [bg, fg];
128
125
  if (bg !== this.background) {
129
126
  this.ctx.fillStyle = bg;
@@ -179,7 +176,6 @@ export class CanvasRenderer {
179
176
  return;
180
177
  default: {
181
178
  this.ctx.fillRect(x, y, cellWidth, cellHeight);
182
- // The cell's text in the background colour, over the block.
183
179
  const cells = this.rows.get(cursor.y)?.cells;
184
180
  let text = "", flags = 0;
185
181
  if (Array.isArray(cells)) {
@@ -189,7 +185,7 @@ export class CanvasRenderer {
189
185
  }
190
186
  else if (cells && cursor.x < cells.data.length / PACKED_STRIDE) {
191
187
  text = packedText(cells, cursor.x);
192
- flags = cells.data[cursor.x * PACKED_STRIDE + 3] & 0xffff;
188
+ flags = cells.data[cursor.x * PACKED_STRIDE + PACKED_STYLE] & PACKED_FLAGS_MASK;
193
189
  }
194
190
  if (text !== "" && text !== " ") {
195
191
  this.ctx.fillStyle = this.background;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjermundgaraba/clankermux",
3
- "version": "0.5.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"