@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,52 @@
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 { TextRange, TextSearch } from "@noldova/code.editor";
10
+ import { Resources } from "../../resources.js";
11
+ import { MatchShape } from "./shapes/match-shape.js";
12
+ export class CodeSearch {
13
+ static rangeOf(selection) {
14
+ return selection.anchor.compareTo(selection.head) > 0 ? new TextRange(selection.head, selection.anchor) : new TextRange(selection.anchor, selection.head);
15
+ }
16
+ static searchOf(query) {
17
+ if (Object.isNull(query) || String.isNullOrEmpty(query.text))
18
+ return null;
19
+ try {
20
+ return new TextSearch(query);
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
26
+ static statusOf(query, results, current) {
27
+ if (Object.isNull(query) || String.isNullOrEmpty(query.text))
28
+ return Resources.empty;
29
+ if (Object.isNull(results))
30
+ return Resources.invalidPattern;
31
+ const deadline = performance.now() + Resources.statusSliceMilliseconds;
32
+ if (results.advance(() => performance.now() < deadline))
33
+ return Resources.formatMatches(0, results.count, false);
34
+ if (results.count === 0)
35
+ return Resources.noResults;
36
+ return Resources.formatMatches(results.indexOf(current) + 1, results.count, true);
37
+ }
38
+ static shapesOf(results, document, layout, rows, measure, current) {
39
+ const shapes = [];
40
+ for (const row of rows) {
41
+ const item = layout.rowAt(row);
42
+ if (!Object.isNull(item.block))
43
+ continue;
44
+ const text = document.lineText(item.line);
45
+ for (const match of results.matchesIn(item.line, item.line + 1)) {
46
+ const left = measure.x(text, match.start.column);
47
+ shapes.push(new MatchShape(row * measure.lineHeight, left, measure.x(text, match.end.column) - left, match.equals(current)));
48
+ }
49
+ }
50
+ return shapes;
51
+ }
52
+ }
@@ -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
+ import "@noldova/context.core";
9
+ import { type ILineTokenizer } from "@noldova/code.editor";
10
+ import type { IReadOnlyList } from "@noldova/context.collections";
11
+ import { CodeTextSpan } from "./code-text-span.js";
12
+ export declare class CodeTextLine {
13
+ readonly spans: readonly CodeTextSpan[];
14
+ constructor(spans: readonly CodeTextSpan[]);
15
+ static linesOf(text: string, tokenizer: ILineTokenizer | null): IReadOnlyList<CodeTextLine>;
16
+ private static spansOf;
17
+ }
@@ -0,0 +1,42 @@
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 { LineSplit } from "@noldova/code.editor";
10
+ import { CodeTextSpan } from "./code-text-span.js";
11
+ export class CodeTextLine {
12
+ spans;
13
+ constructor(spans) {
14
+ this.spans = spans;
15
+ }
16
+ static linesOf(text, tokenizer) {
17
+ const texts = LineSplit.of(text).texts;
18
+ const count = texts.count();
19
+ const shown = count > 1 && String.isNullOrEmpty(texts.get(count - 1)) ? count - 1 : count;
20
+ let state = tokenizer?.initialState ?? null;
21
+ return texts.take(shown).select(line => {
22
+ if (Object.isNull(tokenizer) || Object.isNull(state))
23
+ return new CodeTextLine([new CodeTextSpan(line, null)]);
24
+ const tokens = tokenizer.tokenizeLine(line, state);
25
+ state = tokens.endState;
26
+ return new CodeTextLine(CodeTextLine.spansOf(line, tokens));
27
+ }).toList();
28
+ }
29
+ static spansOf(line, tokens) {
30
+ const spans = [];
31
+ let at = 0;
32
+ for (const token of tokens.tokens) {
33
+ if (token.start > at)
34
+ spans.push(new CodeTextSpan(line.slice(at, token.start), null));
35
+ spans.push(new CodeTextSpan(line.slice(token.start, token.end), token.type, token.modifiers));
36
+ at = token.end;
37
+ }
38
+ if (at < line.length || spans.length === 0)
39
+ spans.push(new CodeTextSpan(line.slice(at), null));
40
+ return spans;
41
+ }
42
+ }
@@ -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
+ import { type IReadOnlyList } from "@noldova/context.collections";
9
+ export declare class CodeTextSpan {
10
+ private static readonly NO_MODIFIERS;
11
+ readonly text: string;
12
+ readonly type: string | null;
13
+ readonly modifiers: IReadOnlyList<string>;
14
+ constructor(text: string, type: string | null, modifiers?: IReadOnlyList<string>);
15
+ }
@@ -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
+ import { List } from "@noldova/context.collections";
9
+ export class CodeTextSpan {
10
+ static NO_MODIFIERS = new List();
11
+ text;
12
+ type;
13
+ modifiers;
14
+ constructor(text, type, modifiers = CodeTextSpan.NO_MODIFIERS) {
15
+ this.text = text;
16
+ this.type = type;
17
+ this.modifiers = modifiers;
18
+ }
19
+ }
@@ -0,0 +1,39 @@
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 "./code-bar.js";
9
+ import type { CodeBarAction } from "./code-bar-action.js";
10
+ /**
11
+ * A click on a bar's action, which `CodeEditorComponent.barAction` gives
12
+ * the bar's owner.
13
+ */
14
+ export declare class CodeBarActionEvent {
15
+ /**
16
+ * The bar the action is on, as its owner gave it.
17
+ */
18
+ readonly bar: CodeBar;
19
+ /**
20
+ * The action clicked, as its owner gave it.
21
+ */
22
+ readonly action: CodeBarAction;
23
+ /**
24
+ * Creates the event, as the view does on a click.
25
+ *
26
+ * @param bar The bar the action is on.
27
+ * @param action The action clicked.
28
+ * @example
29
+ * ```ts
30
+ * import { List } from "@noldova/context.collections";
31
+ * import { CodeBar, CodeBarAction, CodeBarActionEvent } from "@noldova/code.editor.angular";
32
+ *
33
+ * const ours = new CodeBarAction("ours", "Ours");
34
+ * const bar = new CodeBar("conflict-1", 12, "Conflict 1 is open.", null, new List([ours]));
35
+ * const event = new CodeBarActionEvent(bar, ours);
36
+ * ```
37
+ */
38
+ constructor(bar: CodeBar, action: CodeBarAction);
39
+ }
@@ -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 CodeBarActionEvent {
9
+ bar;
10
+ action;
11
+ constructor(bar, action) {
12
+ this.bar = bar;
13
+ this.action = action;
14
+ }
15
+ }
@@ -0,0 +1,40 @@
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
+ /**
9
+ * A button on a {@link CodeBar}; a click on it reaches the bar's owner as a
10
+ * {@link CodeBarActionEvent} through `CodeEditorComponent.barAction`.
11
+ */
12
+ export declare class CodeBarAction {
13
+ /**
14
+ * The owner's name for the action, which the event gives back.
15
+ */
16
+ readonly id: string;
17
+ /**
18
+ * The button's text.
19
+ */
20
+ readonly label: string;
21
+ /**
22
+ * The name of an icon of the kit's icon font, shown before the text, or
23
+ * null for none.
24
+ */
25
+ readonly icon: string | null;
26
+ /**
27
+ * Creates an action.
28
+ *
29
+ * @param id The owner's name for the action.
30
+ * @param label The button's text.
31
+ * @param icon An icon's name, or null, when not given, for none.
32
+ * @example
33
+ * ```ts
34
+ * import { CodeBarAction } from "@noldova/code.editor.angular";
35
+ *
36
+ * const take = new CodeBarAction("take", "Take", "check");
37
+ * ```
38
+ */
39
+ constructor(id: string, label: string, icon?: string | null);
40
+ }
@@ -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 CodeBarAction {
9
+ id;
10
+ label;
11
+ icon;
12
+ constructor(id, label, icon = null) {
13
+ this.id = id;
14
+ this.label = label;
15
+ this.icon = icon;
16
+ }
17
+ }
@@ -0,0 +1,78 @@
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 { CodeBarAction } from "./code-bar-action.js";
10
+ import { InsertedRows } from "../rows/inserted-rows.js";
11
+ /**
12
+ * A bar one row high across the code view between two lines, with an icon,
13
+ * a note and actions, such as a merge conflict's choices.
14
+ *
15
+ * @remarks
16
+ * Later fields come as optional constructor parameters at the end.
17
+ */
18
+ export declare class CodeBar extends InsertedRows {
19
+ /**
20
+ * The line the rows come before, from 0; the document's line count puts
21
+ * them after its last line.
22
+ */
23
+ readonly beforeLine: number;
24
+ /**
25
+ * The owner's name for the bar, which a {@link CodeBarActionEvent} gives
26
+ * back.
27
+ */
28
+ readonly id: string;
29
+ /**
30
+ * The bar's text.
31
+ */
32
+ readonly note: string;
33
+ /**
34
+ * The name of an icon of the kit's icon font, shown before the note, or
35
+ * null for none.
36
+ */
37
+ readonly icon: string | null;
38
+ /**
39
+ * The buttons at the bar's end, in order.
40
+ */
41
+ readonly actions: IReadOnlyList<CodeBarAction>;
42
+ /**
43
+ * The bar's CSS background, or null for the kit's code header color.
44
+ */
45
+ readonly background: string | null;
46
+ /**
47
+ * The bar's CSS text color, or null for the kit's muted text color.
48
+ */
49
+ readonly color: string | null;
50
+ /**
51
+ * Creates a bar.
52
+ *
53
+ * @param id The owner's name for the bar.
54
+ * @param beforeLine The line the bar comes before, from 0.
55
+ * @param note The bar's text.
56
+ * @param icon An icon's name, or null for none.
57
+ * @param actions The buttons at the bar's end.
58
+ * @param background The bar's CSS background, or null, when not given, for
59
+ * the default.
60
+ * @param color The bar's CSS text color, or null, when not given, for the
61
+ * default.
62
+ * @throws {ArgumentOutOfRangeException} When `beforeLine` is negative or not a whole number.
63
+ * @example
64
+ * ```ts
65
+ * import { List } from "@noldova/context.collections";
66
+ * import { CodeBar, CodeBarAction, CodeDecorations, type CodeGutterMarker, type CodeInsertedRows, type CodeLineDecoration, type CodeRangeDecoration }
67
+ * from "@noldova/code.editor.angular";
68
+ *
69
+ * const bar = new CodeBar("conflict-1", 12, "Conflict 1 is open.", "warning", new List([new CodeBarAction("ours", "Ours")]));
70
+ * const layer = new CodeDecorations(new List<CodeLineDecoration>(), new List<CodeRangeDecoration>(), new List<CodeGutterMarker>(), new List<CodeInsertedRows>([bar]));
71
+ * ```
72
+ */
73
+ constructor(id: string, beforeLine: number, note: string, icon: string | null, actions: IReadOnlyList<CodeBarAction>, background?: string | null, color?: string | null);
74
+ /**
75
+ * Always 1.
76
+ */
77
+ get rowCount(): number;
78
+ }
@@ -0,0 +1,34 @@
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 { InsertedRows } from "../rows/inserted-rows.js";
9
+ export class CodeBar extends InsertedRows {
10
+ beforeLine;
11
+ id;
12
+ note;
13
+ icon;
14
+ actions;
15
+ background;
16
+ color;
17
+ constructor(id, beforeLine, note, icon, actions, background = null, color = null) {
18
+ super(beforeLine);
19
+ this.beforeLine = beforeLine;
20
+ this.id = id;
21
+ this.note = note;
22
+ this.icon = icon;
23
+ this.actions = actions;
24
+ this.background = background;
25
+ this.color = color;
26
+ }
27
+ get rowCount() {
28
+ return 1;
29
+ }
30
+ /** @internal */
31
+ rowAt(builder) {
32
+ return builder.barRow(this);
33
+ }
34
+ }
@@ -0,0 +1,121 @@
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 { ICodeNumbering } from "../../interfaces/i-code-numbering.js";
11
+ import type { CodeGutterMarker } from "./code-gutter-marker.js";
12
+ import type { CodeInsertedRows } from "../rows/code-inserted-rows.js";
13
+ import type { CodeLineDecoration } from "./code-line-decoration.js";
14
+ import type { CodeRangeDecoration } from "./code-range-decoration.js";
15
+ /**
16
+ * A layer of decorations held in lists, indexed by line, so the view finds
17
+ * the ones in view without reading the rest.
18
+ *
19
+ * @remarks
20
+ * In 0.0.x its positions are its owner's to remap: after an edit, the owner
21
+ * gives the view a new layer.
22
+ */
23
+ export declare class CodeDecorations implements ICodeDecorations {
24
+ private static readonly NO_LINES;
25
+ private static readonly NO_RANGES;
26
+ private static readonly NO_MARKERS;
27
+ private static readonly NO_ROWS;
28
+ /**
29
+ * Its line decorations.
30
+ */
31
+ readonly lines: IReadOnlyList<CodeLineDecoration>;
32
+ /**
33
+ * Its range decorations.
34
+ */
35
+ readonly ranges: IReadOnlyList<CodeRangeDecoration>;
36
+ /**
37
+ * Its gutter markers.
38
+ */
39
+ readonly markers: IReadOnlyList<CodeGutterMarker>;
40
+ /**
41
+ * The rows it inserts between lines.
42
+ */
43
+ readonly rows: IReadOnlyList<CodeInsertedRows>;
44
+ /**
45
+ * Its second line number column, or null.
46
+ */
47
+ readonly numbering: ICodeNumbering | null;
48
+ private readonly lineIndex;
49
+ private readonly rangeIndex;
50
+ private readonly markerIndex;
51
+ /**
52
+ * Creates a layer; each part is empty, and the numbering null, when not
53
+ * given.
54
+ *
55
+ * @param lines Its line decorations.
56
+ * @param ranges Its range decorations.
57
+ * @param markers Its gutter markers.
58
+ * @param rows The rows it inserts between lines.
59
+ * @param numbering Its second line number column, or null.
60
+ * @example
61
+ * ```ts
62
+ * import { List } from "@noldova/context.collections";
63
+ * import { CodeDecorations, CodeGutterMarker, CodeLineDecoration, type CodeRangeDecoration } from "@noldova/code.editor.angular";
64
+ *
65
+ * const warnings = new CodeDecorations(new List([new CodeLineDecoration(3, 1, "var(--nol-warning-background)")]), new List<CodeRangeDecoration>(),
66
+ * new List([new CodeGutterMarker(3, "!", "var(--nol-warning)")]));
67
+ * ```
68
+ */
69
+ constructor(lines?: IReadOnlyList<CodeLineDecoration>, ranges?: IReadOnlyList<CodeRangeDecoration>, markers?: IReadOnlyList<CodeGutterMarker>, rows?: IReadOnlyList<CodeInsertedRows>, numbering?: ICodeNumbering | null);
70
+ /**
71
+ * Gives the line decorations that reach a run of lines.
72
+ *
73
+ * @param start The run's first line, from 0.
74
+ * @param end The line after the run.
75
+ * @returns The line decorations, in the order given.
76
+ * @example
77
+ * ```ts
78
+ * import { List } from "@noldova/context.collections";
79
+ * import { CodeDecorations, CodeLineDecoration } from "@noldova/code.editor.angular";
80
+ *
81
+ * const layer = new CodeDecorations(new List([new CodeLineDecoration(3, 2, "var(--nol-warning-background)")]));
82
+ * const shown = layer.linesIn(0, 4);
83
+ * const none = layer.linesIn(5, 10);
84
+ * ```
85
+ */
86
+ linesIn(start: number, end: number): IReadOnlyList<CodeLineDecoration>;
87
+ /**
88
+ * Gives the range decorations that reach a run of lines.
89
+ *
90
+ * @param start The run's first line, from 0.
91
+ * @param end The line after the run.
92
+ * @returns The range decorations, in the order given.
93
+ * @example
94
+ * ```ts
95
+ * import { TextPosition, TextRange } from "@noldova/code.editor";
96
+ * import { List } from "@noldova/context.collections";
97
+ * import { CodeDecorations, type CodeLineDecoration, CodeRangeDecoration } from "@noldova/code.editor.angular";
98
+ *
99
+ * const layer = new CodeDecorations(new List<CodeLineDecoration>(),
100
+ * new List([new CodeRangeDecoration(new TextRange(new TextPosition(2, 4), new TextPosition(5, 0)), "var(--nol-list-highlight)")]));
101
+ * const shown = layer.rangesIn(4, 8);
102
+ * ```
103
+ */
104
+ rangesIn(start: number, end: number): IReadOnlyList<CodeRangeDecoration>;
105
+ /**
106
+ * Gives the gutter markers on a run of lines.
107
+ *
108
+ * @param start The run's first line, from 0.
109
+ * @param end The line after the run.
110
+ * @returns The markers, in the order given.
111
+ * @example
112
+ * ```ts
113
+ * import { List } from "@noldova/context.collections";
114
+ * import { CodeDecorations, CodeGutterMarker, type CodeLineDecoration, type CodeRangeDecoration } from "@noldova/code.editor.angular";
115
+ *
116
+ * const layer = new CodeDecorations(new List<CodeLineDecoration>(), new List<CodeRangeDecoration>(), new List([new CodeGutterMarker(7, "!", "var(--nol-warning)")]));
117
+ * const shown = layer.markersIn(0, 10);
118
+ * ```
119
+ */
120
+ markersIn(start: number, end: number): IReadOnlyList<CodeGutterMarker>;
121
+ }
@@ -0,0 +1,42 @@
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 { List } from "@noldova/context.collections";
9
+ import { LineIndex } from "../rows/line-index.js";
10
+ export class CodeDecorations {
11
+ static NO_LINES = new List();
12
+ static NO_RANGES = new List();
13
+ static NO_MARKERS = new List();
14
+ static NO_ROWS = new List();
15
+ lines;
16
+ ranges;
17
+ markers;
18
+ rows;
19
+ numbering;
20
+ lineIndex;
21
+ rangeIndex;
22
+ markerIndex;
23
+ constructor(lines = CodeDecorations.NO_LINES, ranges = CodeDecorations.NO_RANGES, markers = CodeDecorations.NO_MARKERS, rows = CodeDecorations.NO_ROWS, numbering = null) {
24
+ this.lines = lines;
25
+ this.ranges = ranges;
26
+ this.markers = markers;
27
+ this.rows = rows;
28
+ this.numbering = numbering;
29
+ this.lineIndex = new LineIndex(lines, t => t.startLine, t => t.startLine + t.lineCount);
30
+ this.rangeIndex = new LineIndex(ranges, t => t.range.start.line, t => t.range.end.line + 1);
31
+ this.markerIndex = new LineIndex(markers, t => t.line, t => t.line + 1);
32
+ }
33
+ linesIn(start, end) {
34
+ return this.lineIndex.overlapping(start, end);
35
+ }
36
+ rangesIn(start, end) {
37
+ return this.rangeIndex.overlapping(start, end);
38
+ }
39
+ markersIn(start, end) {
40
+ return this.markerIndex.overlapping(start, end);
41
+ }
42
+ }
@@ -0,0 +1,46 @@
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
+ /**
9
+ * A sign in a line's gutter cell, such as a diff's `+` or a conflict's `!`;
10
+ * when several layers mark one line, the latest layer's marker shows.
11
+ *
12
+ * @remarks
13
+ * In 0.0.x its line is its owner's to remap after an edit. Later fields,
14
+ * such as an icon and a click, come as optional constructor parameters at
15
+ * the end.
16
+ */
17
+ export declare class CodeGutterMarker {
18
+ /**
19
+ * The line it marks, from 0.
20
+ */
21
+ readonly line: number;
22
+ /**
23
+ * The sign it shows, a character or two.
24
+ */
25
+ readonly text: string;
26
+ /**
27
+ * The sign's CSS color.
28
+ */
29
+ readonly color: string;
30
+ /**
31
+ * Creates a marker.
32
+ *
33
+ * @param line The line it marks, from 0.
34
+ * @param text The sign it shows.
35
+ * @param color The sign's CSS color.
36
+ * @throws {ArgumentOutOfRangeException} When `line` is negative or not a whole number.
37
+ * @example
38
+ * ```ts
39
+ * import { List } from "@noldova/context.collections";
40
+ * import { CodeDecorations, CodeGutterMarker, type CodeLineDecoration, type CodeRangeDecoration } from "@noldova/code.editor.angular";
41
+ *
42
+ * const layer = new CodeDecorations(new List<CodeLineDecoration>(), new List<CodeRangeDecoration>(), new List([new CodeGutterMarker(7, "!", "var(--nol-warning)")]));
43
+ * ```
44
+ */
45
+ constructor(line: number, text: string, color: string);
46
+ }
@@ -0,0 +1,20 @@
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 { TextPosition } from "@noldova/code.editor";
9
+ import { Resources } from "../../../resources.js";
10
+ export class CodeGutterMarker {
11
+ line;
12
+ text;
13
+ color;
14
+ constructor(line, text, color) {
15
+ TextPosition.requireCount(line, Resources.lineParameter);
16
+ this.line = line;
17
+ this.text = text;
18
+ this.color = color;
19
+ }
20
+ }
@@ -0,0 +1,48 @@
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
+ /**
9
+ * A background over a run of whole lines of the code view, painted behind
10
+ * their text and in their gutter cells.
11
+ *
12
+ * @remarks
13
+ * In 0.0.x the view never moves a decoration through an edit: its positions
14
+ * are its owner's to remap, by giving the view new decorations after each
15
+ * change. Later fields come as optional constructor parameters at the end,
16
+ * so adding one never breaks an owner.
17
+ */
18
+ export declare class CodeLineDecoration {
19
+ /**
20
+ * The first line it paints, from 0.
21
+ */
22
+ readonly startLine: number;
23
+ /**
24
+ * How many lines it paints; 0 paints none.
25
+ */
26
+ readonly lineCount: number;
27
+ /**
28
+ * The CSS background it paints, such as a color, a `color-mix()` or a
29
+ * gradient.
30
+ */
31
+ readonly background: string;
32
+ /**
33
+ * Creates a line decoration.
34
+ *
35
+ * @param startLine The first line it paints, from 0.
36
+ * @param lineCount How many lines it paints.
37
+ * @param background The CSS background it paints.
38
+ * @throws {ArgumentOutOfRangeException} When `startLine` or `lineCount` is negative or not a whole number.
39
+ * @example
40
+ * ```ts
41
+ * import { List } from "@noldova/context.collections";
42
+ * import { CodeDecorations, CodeLineDecoration } from "@noldova/code.editor.angular";
43
+ *
44
+ * const added = new CodeDecorations(new List([new CodeLineDecoration(4, 2, "var(--nol-added-background)")]));
45
+ * ```
46
+ */
47
+ constructor(startLine: number, lineCount: number, background: string);
48
+ }
@@ -0,0 +1,21 @@
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 { TextPosition } from "@noldova/code.editor";
9
+ import { Resources } from "../../../resources.js";
10
+ export class CodeLineDecoration {
11
+ startLine;
12
+ lineCount;
13
+ background;
14
+ constructor(startLine, lineCount, background) {
15
+ TextPosition.requireCount(startLine, Resources.startLineParameter);
16
+ TextPosition.requireCount(lineCount, Resources.lineCountParameter);
17
+ this.startLine = startLine;
18
+ this.lineCount = lineCount;
19
+ this.background = background;
20
+ }
21
+ }