@noldova/code.editor.angular 0.0.0-stage → 0.0.1

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.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/api/index.d.ts +30 -0
  4. package/api/index.js +27 -0
  5. package/app/components/code-editor/code-editor.component.d.ts +332 -0
  6. package/app/components/code-editor/code-editor.component.js +648 -0
  7. package/app/components/code-text/code-text.component.d.ts +70 -0
  8. package/app/components/code-text/code-text.component.js +40 -0
  9. package/app/components/find-bar/find-bar.component.d.ts +40 -0
  10. package/app/components/find-bar/find-bar.component.js +95 -0
  11. package/app/enums/code-row-kind.d.ts +14 -0
  12. package/app/enums/code-row-kind.js +15 -0
  13. package/app/enums/fold-shortcut.d.ts +11 -0
  14. package/app/enums/fold-shortcut.js +12 -0
  15. package/app/exceptions/background-job-failed.exception.d.ts +33 -0
  16. package/app/exceptions/background-job-failed.exception.js +15 -0
  17. package/app/interfaces/i-code-decorations.d.ts +103 -0
  18. package/app/interfaces/i-code-decorations.js +7 -0
  19. package/app/interfaces/i-code-editor-view.d.ts +13 -0
  20. package/app/interfaces/i-code-editor-view.js +7 -0
  21. package/app/interfaces/i-code-numbering.d.ts +38 -0
  22. package/app/interfaces/i-code-numbering.js +7 -0
  23. package/app/models/code-editor-view.d.ts +18 -0
  24. package/app/models/code-editor-view.js +26 -0
  25. package/app/models/code-search.d.ts +18 -0
  26. package/app/models/code-search.js +52 -0
  27. package/app/models/code-text-line.d.ts +17 -0
  28. package/app/models/code-text-line.js +42 -0
  29. package/app/models/code-text-span.d.ts +15 -0
  30. package/app/models/code-text-span.js +19 -0
  31. package/app/models/decorations/code-bar-action-event.d.ts +39 -0
  32. package/app/models/decorations/code-bar-action-event.js +15 -0
  33. package/app/models/decorations/code-bar-action.d.ts +40 -0
  34. package/app/models/decorations/code-bar-action.js +17 -0
  35. package/app/models/decorations/code-bar.d.ts +78 -0
  36. package/app/models/decorations/code-bar.js +34 -0
  37. package/app/models/decorations/code-decorations.d.ts +121 -0
  38. package/app/models/decorations/code-decorations.js +42 -0
  39. package/app/models/decorations/code-gutter-marker.d.ts +46 -0
  40. package/app/models/decorations/code-gutter-marker.js +20 -0
  41. package/app/models/decorations/code-line-decoration.d.ts +48 -0
  42. package/app/models/decorations/code-line-decoration.js +21 -0
  43. package/app/models/decorations/code-range-decoration.d.ts +44 -0
  44. package/app/models/decorations/code-range-decoration.js +15 -0
  45. package/app/models/folding/code-block.d.ts +17 -0
  46. package/app/models/folding/code-block.js +21 -0
  47. package/app/models/folding/code-blocks.d.ts +17 -0
  48. package/app/models/folding/code-blocks.js +32 -0
  49. package/app/models/folding/code-fold.d.ts +53 -0
  50. package/app/models/folding/code-fold.js +23 -0
  51. package/app/models/folding/fold-shortcuts.d.ts +14 -0
  52. package/app/models/folding/fold-shortcuts.js +17 -0
  53. package/app/models/language-tokenizer.d.ts +39 -0
  54. package/app/models/language-tokenizer.js +22 -0
  55. package/app/models/rows/code-embedded-lines.d.ts +76 -0
  56. package/app/models/rows/code-embedded-lines.js +43 -0
  57. package/app/models/rows/code-inserted-rows.d.ts +19 -0
  58. package/app/models/rows/code-inserted-rows.js +7 -0
  59. package/app/models/rows/code-row.d.ts +27 -0
  60. package/app/models/rows/code-row.js +31 -0
  61. package/app/models/rows/code-spacer.d.ts +61 -0
  62. package/app/models/rows/code-spacer.js +30 -0
  63. package/app/models/rows/inserted-rows.d.ts +12 -0
  64. package/app/models/rows/inserted-rows.js +18 -0
  65. package/app/models/rows/layer-lines.d.ts +18 -0
  66. package/app/models/rows/layer-lines.js +17 -0
  67. package/app/models/rows/layout-row.d.ts +14 -0
  68. package/app/models/rows/layout-row.js +17 -0
  69. package/app/models/rows/line-index.d.ts +58 -0
  70. package/app/models/rows/line-index.js +50 -0
  71. package/app/models/rows/row-builder.d.ts +35 -0
  72. package/app/models/rows/row-builder.js +87 -0
  73. package/app/models/rows/row-layout.d.ts +22 -0
  74. package/app/models/rows/row-layout.js +58 -0
  75. package/app/models/rows/row-span.d.ts +13 -0
  76. package/app/models/rows/row-span.js +17 -0
  77. package/app/models/shapes/bar-shape.d.ts +13 -0
  78. package/app/models/shapes/bar-shape.js +15 -0
  79. package/app/models/shapes/change-shape.d.ts +14 -0
  80. package/app/models/shapes/change-shape.js +19 -0
  81. package/app/models/shapes/code-shape.d.ts +14 -0
  82. package/app/models/shapes/code-shape.js +19 -0
  83. package/app/models/shapes/match-shape.d.ts +14 -0
  84. package/app/models/shapes/match-shape.js +19 -0
  85. package/app/models/text-measure.d.ts +18 -0
  86. package/app/models/text-measure.js +50 -0
  87. package/app/models/view-command.d.ts +16 -0
  88. package/app/models/view-command.js +24 -0
  89. package/app/services/background-ticker.d.ts +47 -0
  90. package/app/services/background-ticker.js +34 -0
  91. package/app/services/code-editor-classes.d.ts +102 -0
  92. package/app/services/code-editor-classes.js +30 -0
  93. package/app/services/code-editor-contribution.d.ts +20 -0
  94. package/app/services/code-editor-contribution.js +41 -0
  95. package/app/services/code-editor-features.d.ts +13 -0
  96. package/app/services/code-editor-features.js +13 -0
  97. package/app/services/code-editor-registries.d.ts +43 -0
  98. package/app/services/code-editor-registries.js +23 -0
  99. package/app/services/key-scope.d.ts +79 -0
  100. package/app/services/key-scope.js +53 -0
  101. package/app/services/token-style-sheet.d.ts +11 -0
  102. package/app/services/token-style-sheet.js +44 -0
  103. package/app/services/worker-runner.d.ts +87 -0
  104. package/app/services/worker-runner.js +84 -0
  105. package/package.json +38 -4
  106. package/resources.d.ts +124 -0
  107. package/resources.js +137 -0
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import type { IReadOnlyList } from "@noldova/context.collections";
9
+ import type { ICodeDecorations } from "../../interfaces/i-code-decorations.js";
10
+ import type { CodeGutterMarker } from "../decorations/code-gutter-marker.js";
11
+ import type { CodeLineDecoration } from "../decorations/code-line-decoration.js";
12
+ import type { CodeRangeDecoration } from "../decorations/code-range-decoration.js";
13
+ export declare class LayerLines {
14
+ readonly lines: IReadOnlyList<CodeLineDecoration>;
15
+ readonly ranges: IReadOnlyList<CodeRangeDecoration>;
16
+ readonly markers: IReadOnlyList<CodeGutterMarker>;
17
+ constructor(decorations: ICodeDecorations, start: number, end: number);
18
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export class LayerLines {
9
+ lines;
10
+ ranges;
11
+ markers;
12
+ constructor(decorations, start, end) {
13
+ this.lines = decorations.linesIn(start, end);
14
+ this.ranges = decorations.rangesIn(start, end);
15
+ this.markers = decorations.markersIn(start, end);
16
+ }
17
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import type { CodeBlock } from "../folding/code-block.js";
9
+ export declare class LayoutRow {
10
+ readonly line: number;
11
+ readonly block: CodeBlock | null;
12
+ readonly index: number;
13
+ constructor(line: number, block: CodeBlock | null, index: number);
14
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export class LayoutRow {
9
+ line;
10
+ block;
11
+ index;
12
+ constructor(line, block, index) {
13
+ this.line = line;
14
+ this.block = block;
15
+ this.index = index;
16
+ }
17
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { type IReadOnlyList } from "@noldova/context.collections";
9
+ /**
10
+ * Finds the items whose line spans overlap a run of lines, such as the changes
11
+ * a view's visible rows show.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { List } from "@noldova/context.collections";
16
+ * import { CodeFold, LineIndex } from "@noldova/code.editor.angular";
17
+ *
18
+ * const index = new LineIndex<CodeFold>(new List([new CodeFold(0, 2, false), new CodeFold(5, 1, false)]), t => t.startLine, t => t.startLine + t.lineCount);
19
+ * index.overlapping(1, 3).count(); // 1
20
+ * ```
21
+ */
22
+ export declare class LineIndex<TItem extends {} | null> {
23
+ private readonly items;
24
+ private readonly order;
25
+ private readonly starts;
26
+ private readonly reach;
27
+ private readonly endOf;
28
+ /**
29
+ * Indexes the items.
30
+ *
31
+ * @param items The items, in any order, overlapping or not.
32
+ * @param startOf An item's first line.
33
+ * @param endOf The line after an item's last.
34
+ * @example
35
+ * ```ts
36
+ * import { List } from "@noldova/context.collections";
37
+ * import { LineIndex } from "@noldova/code.editor.angular";
38
+ *
39
+ * new LineIndex<number>(new List([1, 4]), t => t, t => t + 1);
40
+ * ```
41
+ */
42
+ constructor(items: IReadOnlyList<TItem>, startOf: (item: TItem) => number, endOf: (item: TItem) => number);
43
+ /**
44
+ * The items that overlap lines `[start, end)`, in the order given.
45
+ *
46
+ * @param start The first line.
47
+ * @param end The line after the last.
48
+ * @returns The overlapping items.
49
+ * @example
50
+ * ```ts
51
+ * import { List } from "@noldova/context.collections";
52
+ * import { LineIndex } from "@noldova/code.editor.angular";
53
+ *
54
+ * new LineIndex<number>(new List([1, 4]), t => t, t => t + 1).overlapping(0, 2).toArray(); // [1]
55
+ * ```
56
+ */
57
+ overlapping(start: number, end: number): IReadOnlyList<TItem>;
58
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { Required } from "@noldova/code.editor";
9
+ import { List } from "@noldova/context.collections";
10
+ export class LineIndex {
11
+ items;
12
+ order;
13
+ starts;
14
+ reach;
15
+ endOf;
16
+ constructor(items, startOf, endOf) {
17
+ this.items = items;
18
+ this.endOf = endOf;
19
+ this.order = Array.from({ length: items.count() }, (_, index) => index).sort((a, b) => startOf(items.get(a)) - startOf(items.get(b)) || a - b);
20
+ this.starts = this.order.map(t => startOf(items.get(t)));
21
+ const reach = [];
22
+ let furthest = Number.NEGATIVE_INFINITY;
23
+ for (const index of this.order) {
24
+ furthest = Math.max(furthest, endOf(items.get(index)));
25
+ reach.push(furthest);
26
+ }
27
+ this.reach = reach;
28
+ }
29
+ overlapping(start, end) {
30
+ let low = 0;
31
+ let high = this.starts.length;
32
+ while (low < high) {
33
+ const middle = Math.floor((low + high) / 2);
34
+ if (Required.at(this.starts, middle) < end)
35
+ low = middle + 1;
36
+ else
37
+ high = middle;
38
+ }
39
+ const found = [];
40
+ for (let at = low - 1; at >= 0 && Required.at(this.reach, at) > start; at--) {
41
+ const index = Required.at(this.order, at);
42
+ if (this.endOf(this.items.get(index)) > start)
43
+ found.push(index);
44
+ }
45
+ const overlapping = new List();
46
+ for (const index of found.sort((a, b) => a - b))
47
+ overlapping.add(this.items.get(index));
48
+ return overlapping;
49
+ }
50
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { type TextDocument, type TokenCache } from "@noldova/code.editor";
10
+ import { type IReadOnlyList } from "@noldova/context.collections";
11
+ import type { ICodeDecorations } from "../../interfaces/i-code-decorations.js";
12
+ import type { CodeBar } from "../decorations/code-bar.js";
13
+ import type { CodeEmbeddedLines } from "./code-embedded-lines.js";
14
+ import type { CodeFold } from "../folding/code-fold.js";
15
+ import { CodeRow } from "./code-row.js";
16
+ import type { CodeSpacer } from "./code-spacer.js";
17
+ import type { LayoutRow } from "./layout-row.js";
18
+ export declare class RowBuilder {
19
+ private static readonly NO_TOKENS;
20
+ private static readonly NO_SEGMENTS;
21
+ private readonly document;
22
+ private readonly cache;
23
+ private readonly layers;
24
+ private readonly openFolds;
25
+ private readonly numbering;
26
+ constructor(document: TextDocument, cache: TokenCache | null, layers: IReadOnlyList<ICodeDecorations>, openFolds: ReadonlyMap<number, CodeFold>);
27
+ rowsOf(items: readonly LayoutRow[]): readonly CodeRow[];
28
+ private lineRow;
29
+ private blockRow;
30
+ barRow(bar: CodeBar): CodeRow;
31
+ spacerRow(spacer: CodeSpacer, line: number): CodeRow;
32
+ embeddedRow(rows: CodeEmbeddedLines, line: number): CodeRow;
33
+ private static painted;
34
+ private static segmentsOf;
35
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { Required, TokenSegments } from "@noldova/code.editor";
10
+ import { List } from "@noldova/context.collections";
11
+ import { Resources } from "../../../resources.js";
12
+ import { CodeRowKind } from "../../enums/code-row-kind.js";
13
+ import { CodeGutterMarker } from "../decorations/code-gutter-marker.js";
14
+ import { CodeRow } from "./code-row.js";
15
+ import { LayerLines } from "./layer-lines.js";
16
+ import { RowSpan } from "./row-span.js";
17
+ export class RowBuilder {
18
+ static NO_TOKENS = new List();
19
+ static NO_SEGMENTS = new List();
20
+ document;
21
+ cache;
22
+ layers;
23
+ openFolds;
24
+ numbering;
25
+ constructor(document, cache, layers, openFolds) {
26
+ this.document = document;
27
+ this.cache = cache;
28
+ this.layers = layers;
29
+ this.openFolds = openFolds;
30
+ this.numbering = layers.lastOrDefault(t => !Object.isNull(t.numbering))?.numbering ?? null;
31
+ }
32
+ rowsOf(items) {
33
+ const lines = items.filter(t => Object.isNull(t.block)).map(t => t.line);
34
+ const start = Math.min(...lines);
35
+ const end = Math.max(...lines) + 1;
36
+ const found = Array.from(this.layers, t => new LayerLines(t, start, end));
37
+ return items.map(t => Object.isNull(t.block) ? this.lineRow(t.line, found) : this.blockRow(t.block, t.index));
38
+ }
39
+ lineRow(line, found) {
40
+ const text = this.document.lineText(line);
41
+ const segments = RowBuilder.segmentsOf(text, this.cache, line);
42
+ return RowBuilder.painted(line + 1, this.numbering?.numberOf(line) ?? null, text, segments, CodeRowKind.Line, line, found, this.openFolds.get(line) ?? null);
43
+ }
44
+ blockRow(block, index) {
45
+ const rows = block.rows;
46
+ if (!Object.isNull(rows))
47
+ return rows.rowAt(this, block.line, index);
48
+ const fold = Required.value(block.fold);
49
+ const label = fold.label ?? Resources.formatHidden(block.hidden);
50
+ return new CodeRow(null, null, label, TokenSegments.fill(label.length, RowBuilder.NO_TOKENS), CodeRowKind.Fold, [], null, [], null, fold);
51
+ }
52
+ barRow(bar) {
53
+ return new CodeRow(null, null, Resources.empty, RowBuilder.NO_SEGMENTS, CodeRowKind.Bar, [], null, [], bar, null);
54
+ }
55
+ spacerRow(spacer, line) {
56
+ const marker = Object.isNull(spacer.sign) ? null : new CodeGutterMarker(line, spacer.sign, spacer.signColor ?? Resources.inherit);
57
+ return Object.isNull(spacer.background)
58
+ ? new CodeRow(null, null, Resources.empty, RowBuilder.NO_SEGMENTS, CodeRowKind.Spacer, [], marker, [], null, null)
59
+ : new CodeRow(null, null, Resources.empty, RowBuilder.NO_SEGMENTS, CodeRowKind.Line, [spacer.background], marker, [], null, null);
60
+ }
61
+ embeddedRow(rows, line) {
62
+ const text = rows.document.lineText(line);
63
+ const found = Object.isNull(rows.decorations) ? [] : [new LayerLines(rows.decorations, line, line + 1)];
64
+ const paired = !Object.isNull(this.numbering);
65
+ return RowBuilder.painted(paired ? null : line + 1, paired ? line + 1 : null, text, RowBuilder.segmentsOf(text, rows.tokens, line), CodeRowKind.Embedded, line, found, null);
66
+ }
67
+ static painted(number, otherNumber, text, segments, kind, line, found, fold) {
68
+ const paints = [];
69
+ const spans = [];
70
+ let marker = null;
71
+ for (const layer of found) {
72
+ for (const decoration of layer.lines.where(t => line >= t.startLine && line < t.startLine + t.lineCount))
73
+ paints.push(decoration.background);
74
+ for (const decoration of layer.ranges.where(t => t.range.start.line <= line && t.range.end.line >= line)) {
75
+ const start = decoration.range.start.line === line ? decoration.range.start.column : 0;
76
+ const end = decoration.range.end.line === line ? decoration.range.end.column : text.length;
77
+ if (end > start)
78
+ spans.push(new RowSpan(start, end, decoration.background));
79
+ }
80
+ marker = layer.markers.lastOrDefault(t => t.line === line) ?? marker;
81
+ }
82
+ return new CodeRow(number, otherNumber, text, segments, kind, paints, marker, spans, null, fold);
83
+ }
84
+ static segmentsOf(text, cache, line) {
85
+ return TokenSegments.fill(text.length, Object.isNull(cache) ? RowBuilder.NO_TOKENS : cache.tokensOf(line).tokens);
86
+ }
87
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import type { CodeBlock } from "../folding/code-block.js";
10
+ import { LayoutRow } from "./layout-row.js";
11
+ export declare class RowLayout {
12
+ readonly rowCount: number;
13
+ private readonly blocks;
14
+ private readonly lines;
15
+ private readonly starts;
16
+ private readonly before;
17
+ constructor(lineCount: number, blocks: readonly CodeBlock[]);
18
+ rowOfLine(line: number): number;
19
+ rowAt(row: number): LayoutRow;
20
+ private hidingAt;
21
+ private static countUpTo;
22
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { Required } from "@noldova/code.editor";
10
+ import { LayoutRow } from "./layout-row.js";
11
+ export class RowLayout {
12
+ rowCount;
13
+ blocks;
14
+ lines;
15
+ starts;
16
+ before;
17
+ constructor(lineCount, blocks) {
18
+ const starts = [];
19
+ const before = [0];
20
+ for (const block of blocks) {
21
+ starts.push(block.line + Required.at(before, before.length - 1));
22
+ before.push(Required.at(before, before.length - 1) + block.length - block.hidden);
23
+ }
24
+ this.blocks = blocks;
25
+ this.lines = blocks.map(t => t.line);
26
+ this.starts = starts;
27
+ this.before = before;
28
+ this.rowCount = lineCount + Required.at(before, blocks.length);
29
+ }
30
+ rowOfLine(line) {
31
+ const count = RowLayout.countUpTo(this.lines, line);
32
+ return this.hidingAt(line, count) ? Required.at(this.starts, count - 1) : line + Required.at(this.before, count);
33
+ }
34
+ rowAt(row) {
35
+ const count = RowLayout.countUpTo(this.starts, row);
36
+ const block = this.blocks[count - 1];
37
+ const start = this.starts[count - 1] ?? 0;
38
+ if (!Object.isUndefined(block) && row < start + block.length)
39
+ return new LayoutRow(block.line, block, row - start);
40
+ return new LayoutRow(row - Required.at(this.before, count), null, 0);
41
+ }
42
+ hidingAt(line, count) {
43
+ const block = this.blocks[count - 1];
44
+ return !Object.isUndefined(block) && line < block.line + block.hidden;
45
+ }
46
+ static countUpTo(values, value) {
47
+ let low = 0;
48
+ let high = values.length;
49
+ while (low < high) {
50
+ const middle = Math.floor((low + high) / 2);
51
+ if (Required.at(values, middle) <= value)
52
+ low = middle + 1;
53
+ else
54
+ high = middle;
55
+ }
56
+ return low;
57
+ }
58
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export declare class RowSpan {
9
+ readonly start: number;
10
+ readonly end: number;
11
+ readonly background: string;
12
+ constructor(start: number, end: number, background: string);
13
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export class RowSpan {
9
+ start;
10
+ end;
11
+ background;
12
+ constructor(start, end, background) {
13
+ this.start = start;
14
+ this.end = end;
15
+ this.background = background;
16
+ }
17
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import type { CodeBar } from "../decorations/code-bar.js";
9
+ export declare class BarShape {
10
+ readonly top: number;
11
+ readonly bar: CodeBar;
12
+ constructor(top: number, bar: CodeBar);
13
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export class BarShape {
9
+ top;
10
+ bar;
11
+ constructor(top, bar) {
12
+ this.top = top;
13
+ this.bar = bar;
14
+ }
15
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export declare class ChangeShape {
9
+ readonly top: number;
10
+ readonly left: number;
11
+ readonly width: number;
12
+ readonly background: string;
13
+ constructor(top: number, left: number, width: number, background: string);
14
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export class ChangeShape {
9
+ top;
10
+ left;
11
+ width;
12
+ background;
13
+ constructor(top, left, width, background) {
14
+ this.top = top;
15
+ this.left = left;
16
+ this.width = width;
17
+ this.background = background;
18
+ }
19
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export declare class CodeShape {
9
+ readonly top: number;
10
+ readonly left: number;
11
+ readonly width: number;
12
+ readonly height: number;
13
+ constructor(top: number, left: number, width: number, height: number);
14
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export class CodeShape {
9
+ top;
10
+ left;
11
+ width;
12
+ height;
13
+ constructor(top, left, width, height) {
14
+ this.top = top;
15
+ this.left = left;
16
+ this.width = width;
17
+ this.height = height;
18
+ }
19
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export declare class MatchShape {
9
+ readonly top: number;
10
+ readonly left: number;
11
+ readonly width: number;
12
+ readonly current: boolean;
13
+ constructor(top: number, left: number, width: number, current: boolean);
14
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export class MatchShape {
9
+ top;
10
+ left;
11
+ width;
12
+ current;
13
+ constructor(top, left, width, current) {
14
+ this.top = top;
15
+ this.left = left;
16
+ this.width = width;
17
+ this.current = current;
18
+ }
19
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export declare class TextMeasure {
9
+ readonly lineHeight: number;
10
+ readonly spaceWidth: number;
11
+ readonly inset: number;
12
+ private readonly context;
13
+ private readonly tabSize;
14
+ constructor(probe: HTMLElement, content: HTMLElement);
15
+ x(text: string, column: number): number;
16
+ columnAt(text: string, x: number): number;
17
+ private expand;
18
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { Required } from "@noldova/code.editor";
9
+ import { Resources } from "../../resources.js";
10
+ export class TextMeasure {
11
+ lineHeight;
12
+ spaceWidth;
13
+ inset;
14
+ context;
15
+ tabSize;
16
+ constructor(probe, content) {
17
+ const style = getComputedStyle(probe);
18
+ this.context = Required.value(new OffscreenCanvas(1, 1).getContext(Resources.canvasContext));
19
+ this.context.font = style.font;
20
+ this.lineHeight = probe.getBoundingClientRect().height;
21
+ this.tabSize = Number.parseInt(style.tabSize, Resources.decimalRadix);
22
+ this.spaceWidth = this.context.measureText(Resources.space).width;
23
+ this.inset = Number.parseFloat(getComputedStyle(content).paddingInlineStart);
24
+ }
25
+ x(text, column) {
26
+ return this.context.measureText(this.expand(text.slice(0, column))).width;
27
+ }
28
+ columnAt(text, x) {
29
+ let low = 0;
30
+ let high = text.length;
31
+ while (low < high) {
32
+ const middle = Math.ceil((low + high) / 2);
33
+ if (this.x(text, middle) <= x)
34
+ low = middle;
35
+ else
36
+ high = middle - 1;
37
+ }
38
+ if (low < text.length && x - this.x(text, low) > this.x(text, low + 1) - x)
39
+ return low + 1;
40
+ return low;
41
+ }
42
+ expand(text) {
43
+ if (!text.includes(Resources.tab))
44
+ return text;
45
+ let expanded = Resources.empty;
46
+ for (const character of text)
47
+ expanded += character === Resources.tab ? Resources.space.repeat(this.tabSize - expanded.length % this.tabSize) : character;
48
+ return expanded;
49
+ }
50
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import type { CommandContext, ICommand } from "@noldova/code.editor";
10
+ import type { ICodeEditorView } from "../interfaces/i-code-editor-view.js";
11
+ export declare class ViewCommand implements ICommand {
12
+ readonly id: string;
13
+ private readonly action;
14
+ constructor(id: string, action: (view: ICodeEditorView) => void);
15
+ run(context: CommandContext): boolean;
16
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { CodeEditorFeatures } from "../services/code-editor-features.js";
10
+ export class ViewCommand {
11
+ id;
12
+ action;
13
+ constructor(id, action) {
14
+ this.id = id;
15
+ this.action = action;
16
+ }
17
+ run(context) {
18
+ const view = context.feature(CodeEditorFeatures.view);
19
+ if (Object.isNull(view))
20
+ return false;
21
+ this.action(view);
22
+ return true;
23
+ }
24
+ }