@noldova/code.editor 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.
- package/LICENSE +21 -0
- package/README.md +4 -2
- package/api/index.d.ts +6288 -0
- package/api/index.js +80 -0
- package/api/index.js.map +1 -0
- package/enums/edit-kind.js +14 -0
- package/enums/edit-kind.js.map +1 -0
- package/enums/key-dispatch-result.js +15 -0
- package/enums/key-dispatch-result.js.map +1 -0
- package/enums/worker-job-answer.js +14 -0
- package/enums/worker-job-answer.js.map +1 -0
- package/exceptions/condition-syntax.exception.js +20 -0
- package/exceptions/condition-syntax.exception.js.map +1 -0
- package/exceptions/edits-overlap.exception.js +20 -0
- package/exceptions/edits-overlap.exception.js.map +1 -0
- package/exceptions/key-syntax.exception.js +18 -0
- package/exceptions/key-syntax.exception.js.map +1 -0
- package/exceptions/registration-exists.exception.js +20 -0
- package/exceptions/registration-exists.exception.js.map +1 -0
- package/exceptions/registration-missing.exception.js +20 -0
- package/exceptions/registration-missing.exception.js.map +1 -0
- package/exceptions/search-pattern.exception.js +18 -0
- package/exceptions/search-pattern.exception.js.map +1 -0
- package/exceptions/value-missing.exception.js +16 -0
- package/exceptions/value-missing.exception.js.map +1 -0
- package/interfaces/background/i-background-job.js +9 -0
- package/interfaces/background/i-background-job.js.map +1 -0
- package/interfaces/background/i-background-runner.js +9 -0
- package/interfaces/background/i-background-runner.js.map +1 -0
- package/interfaces/background/i-message-post-options.js +9 -0
- package/interfaces/background/i-message-post-options.js.map +1 -0
- package/interfaces/background/i-message-scope.js +9 -0
- package/interfaces/background/i-message-scope.js.map +1 -0
- package/interfaces/background/i-worker-job-failure.js +9 -0
- package/interfaces/background/i-worker-job-failure.js.map +1 -0
- package/interfaces/background/i-worker-job-message.js +9 -0
- package/interfaces/background/i-worker-job-message.js.map +1 -0
- package/interfaces/background/i-worker-job-missing.js +9 -0
- package/interfaces/background/i-worker-job-missing.js.map +1 -0
- package/interfaces/background/i-worker-job-output.js +9 -0
- package/interfaces/background/i-worker-job-output.js.map +1 -0
- package/interfaces/background/i-worker-job-request.js +9 -0
- package/interfaces/background/i-worker-job-request.js.map +1 -0
- package/interfaces/i-command.js +9 -0
- package/interfaces/i-command.js.map +1 -0
- package/interfaces/i-condition-node.js +9 -0
- package/interfaces/i-condition-node.js.map +1 -0
- package/interfaces/i-diff-algorithm.js +9 -0
- package/interfaces/i-diff-algorithm.js.map +1 -0
- package/interfaces/i-editor-contribution.js +9 -0
- package/interfaces/i-editor-contribution.js.map +1 -0
- package/interfaces/i-key-binding-rule.js +9 -0
- package/interfaces/i-key-binding-rule.js.map +1 -0
- package/interfaces/i-language-definition.js +9 -0
- package/interfaces/i-language-definition.js.map +1 -0
- package/interfaces/i-move-command.js +9 -0
- package/interfaces/i-move-command.js.map +1 -0
- package/interfaces/i-plural-phrase.js +9 -0
- package/interfaces/i-plural-phrase.js.map +1 -0
- package/interfaces/tokens/i-highlighter.js +9 -0
- package/interfaces/tokens/i-highlighter.js.map +1 -0
- package/interfaces/tokens/i-line-tokenizer.js +9 -0
- package/interfaces/tokens/i-line-tokenizer.js.map +1 -0
- package/interfaces/tokens/i-token-modifier-definition.js +9 -0
- package/interfaces/tokens/i-token-modifier-definition.js.map +1 -0
- package/interfaces/tokens/i-token-type-definition.js +9 -0
- package/interfaces/tokens/i-token-type-definition.js.map +1 -0
- package/interfaces/tokens/i-tokenizer-state.js +9 -0
- package/interfaces/tokens/i-tokenizer-state.js.map +1 -0
- package/models/commands/command-context.js +30 -0
- package/models/commands/command-context.js.map +1 -0
- package/models/commands/session-command.js +22 -0
- package/models/commands/session-command.js.map +1 -0
- package/models/commands/session-move-command.js +17 -0
- package/models/commands/session-move-command.js.map +1 -0
- package/models/conditions/condition-and.js +20 -0
- package/models/conditions/condition-and.js.map +1 -0
- package/models/conditions/condition-equals.js +21 -0
- package/models/conditions/condition-equals.js.map +1 -0
- package/models/conditions/condition-key.js +18 -0
- package/models/conditions/condition-key.js.map +1 -0
- package/models/conditions/condition-literal.js +17 -0
- package/models/conditions/condition-literal.js.map +1 -0
- package/models/conditions/condition-name.js +17 -0
- package/models/conditions/condition-name.js.map +1 -0
- package/models/conditions/condition-not.js +18 -0
- package/models/conditions/condition-not.js.map +1 -0
- package/models/conditions/condition-or.js +20 -0
- package/models/conditions/condition-or.js.map +1 -0
- package/models/conditions/condition-token.js +18 -0
- package/models/conditions/condition-token.js.map +1 -0
- package/models/conditions/condition-truth.js +18 -0
- package/models/conditions/condition-truth.js.map +1 -0
- package/models/conditions/condition-value.js +9 -0
- package/models/conditions/condition-value.js.map +1 -0
- package/models/conditions/condition.js +44 -0
- package/models/conditions/condition.js.map +1 -0
- package/models/diff-span.js +20 -0
- package/models/diff-span.js.map +1 -0
- package/models/editing/applied-edit.js +22 -0
- package/models/editing/applied-edit.js.map +1 -0
- package/models/editing/edit-transaction.js +22 -0
- package/models/editing/edit-transaction.js.map +1 -0
- package/models/editing/undo-step.js +24 -0
- package/models/editing/undo-step.js.map +1 -0
- package/models/editor-feature-set.js +18 -0
- package/models/editor-feature-set.js.map +1 -0
- package/models/editor-feature.js +24 -0
- package/models/editor-feature.js.map +1 -0
- package/models/keys/key-binding-entry.js +57 -0
- package/models/keys/key-binding-entry.js.map +1 -0
- package/models/keys/key-binding-rule.js +20 -0
- package/models/keys/key-binding-rule.js.map +1 -0
- package/models/keys/key-binding-source.js +16 -0
- package/models/keys/key-binding-source.js.map +1 -0
- package/models/keys/key-chord.js +74 -0
- package/models/keys/key-chord.js.map +1 -0
- package/models/keys/key-dispatcher.js +42 -0
- package/models/keys/key-dispatcher.js.map +1 -0
- package/models/keys/key-press.js +24 -0
- package/models/keys/key-press.js.map +1 -0
- package/models/keys/key-sequence.js +37 -0
- package/models/keys/key-sequence.js.map +1 -0
- package/models/languages/block-comment.js +16 -0
- package/models/languages/block-comment.js.map +1 -0
- package/models/languages/bracket-pair.js +16 -0
- package/models/languages/bracket-pair.js.map +1 -0
- package/models/languages/language-definition.js +32 -0
- package/models/languages/language-definition.js.map +1 -0
- package/models/languages/language-file.js +29 -0
- package/models/languages/language-file.js.map +1 -0
- package/models/phrase-set.js +16 -0
- package/models/phrase-set.js.map +1 -0
- package/models/phrase-text.js +9 -0
- package/models/phrase-text.js.map +1 -0
- package/models/plural-phrase.js +24 -0
- package/models/plural-phrase.js.map +1 -0
- package/models/registration.js +21 -0
- package/models/registration.js.map +1 -0
- package/models/search-query.js +20 -0
- package/models/search-query.js.map +1 -0
- package/models/setting.js +39 -0
- package/models/setting.js.map +1 -0
- package/models/text/line-chunk.js +115 -0
- package/models/text/line-chunk.js.map +1 -0
- package/models/text/line-segment.js +22 -0
- package/models/text/line-segment.js.map +1 -0
- package/models/text/line-split.js +32 -0
- package/models/text/line-split.js.map +1 -0
- package/models/text/text-change.js +20 -0
- package/models/text/text-change.js.map +1 -0
- package/models/text/text-document.js +265 -0
- package/models/text/text-document.js.map +1 -0
- package/models/text/text-edit.js +16 -0
- package/models/text/text-edit.js.map +1 -0
- package/models/text/text-position.js +30 -0
- package/models/text/text-position.js.map +1 -0
- package/models/text/text-range.js +30 -0
- package/models/text/text-range.js.map +1 -0
- package/models/text/text-selection.js +22 -0
- package/models/text/text-selection.js.map +1 -0
- package/models/tokens/highlighter-assignment.js +16 -0
- package/models/tokens/highlighter-assignment.js.map +1 -0
- package/models/tokens/line-token.js +22 -0
- package/models/tokens/line-token.js.map +1 -0
- package/models/tokens/line-tokens.js +16 -0
- package/models/tokens/line-tokens.js.map +1 -0
- package/models/tokens/stale-state.js +13 -0
- package/models/tokens/stale-state.js.map +1 -0
- package/models/tokens/token-modifier-definition.js +16 -0
- package/models/tokens/token-modifier-definition.js.map +1 -0
- package/models/tokens/token-type-definition.js +18 -0
- package/models/tokens/token-type-definition.js.map +1 -0
- package/models/worker-job-response.js +9 -0
- package/models/worker-job-response.js.map +1 -0
- package/package.json +27 -4
- package/resources.js +384 -0
- package/resources.js.map +1 -0
- package/services/background/background-job-registry.js +29 -0
- package/services/background/background-job-registry.js.map +1 -0
- package/services/background/sliced-runner.js +35 -0
- package/services/background/sliced-runner.js.map +1 -0
- package/services/background/worker-job-host.js +46 -0
- package/services/background/worker-job-host.js.map +1 -0
- package/services/commands/command-registry.js +31 -0
- package/services/commands/command-registry.js.map +1 -0
- package/services/commands/core-commands.js +55 -0
- package/services/commands/core-commands.js.map +1 -0
- package/services/commands/selection-moves.js +126 -0
- package/services/commands/selection-moves.js.map +1 -0
- package/services/conditions/condition-parser.js +105 -0
- package/services/conditions/condition-parser.js.map +1 -0
- package/services/conditions/condition-registry.js +25 -0
- package/services/conditions/condition-registry.js.map +1 -0
- package/services/conditions/condition-values.js +23 -0
- package/services/conditions/condition-values.js.map +1 -0
- package/services/conditions/core-conditions.js +24 -0
- package/services/conditions/core-conditions.js.map +1 -0
- package/services/core-contribution.js +27 -0
- package/services/core-contribution.js.map +1 -0
- package/services/core-key-bindings.js +70 -0
- package/services/core-key-bindings.js.map +1 -0
- package/services/core-settings.js +18 -0
- package/services/core-settings.js.map +1 -0
- package/services/diff-algorithm-registry.js +38 -0
- package/services/diff-algorithm-registry.js.map +1 -0
- package/services/editing/editor-session.js +165 -0
- package/services/editing/editor-session.js.map +1 -0
- package/services/editing/position-mapper.js +38 -0
- package/services/editing/position-mapper.js.map +1 -0
- package/services/editing/text-editing.js +120 -0
- package/services/editing/text-editing.js.map +1 -0
- package/services/editing/undo-history.js +85 -0
- package/services/editing/undo-history.js.map +1 -0
- package/services/editor-features.js +13 -0
- package/services/editor-features.js.map +1 -0
- package/services/editor-registries.js +56 -0
- package/services/editor-registries.js.map +1 -0
- package/services/key-binding-registry.js +76 -0
- package/services/key-binding-registry.js.map +1 -0
- package/services/language-registry.js +56 -0
- package/services/language-registry.js.map +1 -0
- package/services/phrase-registry.js +82 -0
- package/services/phrase-registry.js.map +1 -0
- package/services/platforms.js +16 -0
- package/services/platforms.js.map +1 -0
- package/services/registry-entries.js +45 -0
- package/services/registry-entries.js.map +1 -0
- package/services/required.js +25 -0
- package/services/required.js.map +1 -0
- package/services/search-results.js +128 -0
- package/services/search-results.js.map +1 -0
- package/services/setting-registry.js +105 -0
- package/services/setting-registry.js.map +1 -0
- package/services/text-search.js +66 -0
- package/services/text-search.js.map +1 -0
- package/services/tokens/built-in-token-types.js +41 -0
- package/services/tokens/built-in-token-types.js.map +1 -0
- package/services/tokens/highlighter-registry.js +55 -0
- package/services/tokens/highlighter-registry.js.map +1 -0
- package/services/tokens/token-cache.js +118 -0
- package/services/tokens/token-cache.js.map +1 -0
- package/services/tokens/token-segments.js +29 -0
- package/services/tokens/token-segments.js.map +1 -0
- package/services/tokens/token-styles.js +41 -0
- package/services/tokens/token-styles.js.map +1 -0
- package/services/tokens/token-type-registry.js +63 -0
- package/services/tokens/token-type-registry.js.map +1 -0
|
@@ -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
|
+
export class KeyBindingRule {
|
|
9
|
+
command;
|
|
10
|
+
key;
|
|
11
|
+
when;
|
|
12
|
+
args;
|
|
13
|
+
constructor(command, key = undefined, when = undefined, args = undefined) {
|
|
14
|
+
this.command = command;
|
|
15
|
+
this.key = key;
|
|
16
|
+
this.when = when;
|
|
17
|
+
this.args = args;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=key-binding-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-binding-rule.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/keys/key-binding-rule.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,OAAO,cAAc;IACT,OAAO,CAAS;IAChB,GAAG,CAAqB;IACxB,IAAI,CAAiC;IACrC,IAAI,CAAU;IAE9B,YAAmB,OAAe,EAAE,MAA0B,SAAS,EAAE,OAAuC,SAAS,EAAE,OAAgB,SAAS;QAClJ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -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
|
+
export class KeyBindingSource {
|
|
9
|
+
name;
|
|
10
|
+
entries;
|
|
11
|
+
constructor(name, entries) {
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.entries = entries;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=key-binding-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-binding-source.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/keys/key-binding-source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,gBAAgB;IACX,IAAI,CAAS;IACb,OAAO,CAA6B;IAEpD,YAAmB,IAAY,EAAE,OAAmC;QAClE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 { KeySyntaxException } from "../../exceptions/key-syntax.exception.js";
|
|
10
|
+
import { Resources } from "../../resources.js";
|
|
11
|
+
import { Required } from "../../services/required.js";
|
|
12
|
+
export class KeyChord {
|
|
13
|
+
text;
|
|
14
|
+
name;
|
|
15
|
+
key;
|
|
16
|
+
shift;
|
|
17
|
+
control;
|
|
18
|
+
alt;
|
|
19
|
+
meta;
|
|
20
|
+
constructor(text, name, modifiers) {
|
|
21
|
+
this.text = text;
|
|
22
|
+
this.name = name;
|
|
23
|
+
this.key = name.toLowerCase();
|
|
24
|
+
this.shift = modifiers.has(Resources.modifierShift);
|
|
25
|
+
this.control = modifiers.has(Resources.modifierControl);
|
|
26
|
+
this.alt = modifiers.has(Resources.modifierAlt);
|
|
27
|
+
this.meta = modifiers.has(Resources.modifierMeta);
|
|
28
|
+
}
|
|
29
|
+
static parse(text, primary) {
|
|
30
|
+
const parts = text.split(Resources.keyJoiner);
|
|
31
|
+
const key = Required.at(parts, parts.length - 1);
|
|
32
|
+
if (String.isNullOrEmpty(key))
|
|
33
|
+
throw new KeySyntaxException(text);
|
|
34
|
+
const modifiers = new Set();
|
|
35
|
+
for (const part of parts.slice(0, -1)) {
|
|
36
|
+
const modifier = Resources.modifierNames.get(part.toLowerCase());
|
|
37
|
+
if (Object.isUndefined(modifier))
|
|
38
|
+
throw new KeySyntaxException(text);
|
|
39
|
+
modifiers.add(modifier === Resources.modifierPrimary ? primary : modifier);
|
|
40
|
+
}
|
|
41
|
+
return new KeyChord(text, Resources.keyAliases.get(key.toLowerCase()) ?? key, modifiers);
|
|
42
|
+
}
|
|
43
|
+
matches(press) {
|
|
44
|
+
return press.shift === this.shift && press.control === this.control && press.alt === this.alt && press.meta === this.meta && this.keyMatches(press);
|
|
45
|
+
}
|
|
46
|
+
equals(other) {
|
|
47
|
+
return this.key === other.key && this.shift === other.shift && this.control === other.control && this.alt === other.alt && this.meta === other.meta;
|
|
48
|
+
}
|
|
49
|
+
label(platform) {
|
|
50
|
+
if (platform === Resources.platformMac)
|
|
51
|
+
return KeyChord.joined([this.control ? Resources.macControlLabel : null, this.alt ? Resources.macAltLabel : null,
|
|
52
|
+
this.shift ? Resources.macShiftLabel : null, this.meta ? Resources.macMetaLabel : null, this.keyLabel()], Resources.macLabelJoiner);
|
|
53
|
+
const meta = platform === Resources.platformWindows ? Resources.windowsMetaLabel : Resources.linuxMetaLabel;
|
|
54
|
+
return KeyChord.joined([this.control ? Resources.controlLabel : null, this.shift ? Resources.shiftLabel : null, this.alt ? Resources.altLabel : null,
|
|
55
|
+
this.meta ? meta : null, this.keyLabel()], Resources.keyLabelJoiner);
|
|
56
|
+
}
|
|
57
|
+
static joined(parts, joiner) {
|
|
58
|
+
return parts.filter(t => !Object.isNull(t)).join(joiner);
|
|
59
|
+
}
|
|
60
|
+
keyLabel() {
|
|
61
|
+
if (this.name === Resources.space)
|
|
62
|
+
return Resources.spaceLabel;
|
|
63
|
+
return this.name.charAt(0).toUpperCase() + this.name.slice(1);
|
|
64
|
+
}
|
|
65
|
+
keyMatches(press) {
|
|
66
|
+
const code = press.code.toLowerCase();
|
|
67
|
+
if (this.key.length > 1)
|
|
68
|
+
return press.key.toLowerCase() === this.key || code === this.key;
|
|
69
|
+
if (press.key.toLowerCase() === this.key)
|
|
70
|
+
return true;
|
|
71
|
+
return !Resources.layoutKeyPattern.test(press.key) && (code === Resources.letterCodePrefix + this.key || code === Resources.digitCodePrefix + this.key);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=key-chord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-chord.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/keys/key-chord.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGtD,MAA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AC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IAEO,UAAU,CAAC,KAAe;QAChC,MAAM,IAAI,GAAW,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9C,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;YACrB,OAAO,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QACnE,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,GAAG;YACtC,OAAO,IAAI,CAAC;QAEd,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,KAAK,SAAS,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1J,CAAC;CACF"}
|
|
@@ -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 { List } from "@noldova/context.collections";
|
|
10
|
+
import { KeyDispatchResult } from "../../enums/key-dispatch-result.js";
|
|
11
|
+
import { Resources } from "../../resources.js";
|
|
12
|
+
export class KeyDispatcher {
|
|
13
|
+
pressed = new List();
|
|
14
|
+
get pending() {
|
|
15
|
+
return this.pressed.count() > 0;
|
|
16
|
+
}
|
|
17
|
+
pendingLabel(conditions) {
|
|
18
|
+
const platform = String(conditions.get(Resources.platformCondition));
|
|
19
|
+
return this.pending ? this.pressed.select(t => t.label(platform)).toArray().join(Resources.sequenceJoiner) : null;
|
|
20
|
+
}
|
|
21
|
+
dispatch(press, contexts) {
|
|
22
|
+
if (this.pending && Resources.modifierKeys.contains(press.key))
|
|
23
|
+
return KeyDispatchResult.Pending;
|
|
24
|
+
const next = contexts.select(t => t.registries.keyBindings.continuing(this.pressed, press, t.conditions)).firstOrDefault(t => !Object.isNull(t)) ?? null;
|
|
25
|
+
if (!Object.isNull(next)) {
|
|
26
|
+
this.pressed.add(next);
|
|
27
|
+
return KeyDispatchResult.Pending;
|
|
28
|
+
}
|
|
29
|
+
const wasPending = this.pending;
|
|
30
|
+
const ran = contexts.any(t => t.registries.keyBindings.dispatchAfter(this.pressed, press, t));
|
|
31
|
+
this.pressed.clear();
|
|
32
|
+
if (ran)
|
|
33
|
+
return KeyDispatchResult.Handled;
|
|
34
|
+
return wasPending ? KeyDispatchResult.Cancelled : KeyDispatchResult.None;
|
|
35
|
+
}
|
|
36
|
+
cancel() {
|
|
37
|
+
const wasPending = this.pending;
|
|
38
|
+
this.pressed.clear();
|
|
39
|
+
return wasPending;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=key-dispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-dispatcher.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/keys/key-dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAsB,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAM/C,MAAM,OAAO,aAAa;IACP,OAAO,GAAmB,IAAI,IAAI,EAAY,CAAC;IAEhE,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClC,C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AAK,EAAE,CAAC,CAAC,CAAC,CAAC;QACvG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,GAAG;YACL,OAAO,iBAAiB,CAAC,OAAO,CAAC;QAEnC,OAAO,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC;IAC3E,CAAC;IAEM,MAAM;QACX,MAAM,UAAU,GAAY,IAAI,CAAC,OAAO,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAErB,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -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
|
+
export class KeyPress {
|
|
9
|
+
key;
|
|
10
|
+
code;
|
|
11
|
+
shift;
|
|
12
|
+
control;
|
|
13
|
+
alt;
|
|
14
|
+
meta;
|
|
15
|
+
constructor(key, code, shift, control, alt, meta) {
|
|
16
|
+
this.key = key;
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.shift = shift;
|
|
19
|
+
this.control = control;
|
|
20
|
+
this.alt = alt;
|
|
21
|
+
this.meta = meta;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=key-press.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-press.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/keys/key-press.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,QAAQ;IACH,GAAG,CAAS;IACZ,IAAI,CAAS;IACb,KAAK,CAAU;IACf,OAAO,CAAU;IACjB,GAAG,CAAU;IACb,IAAI,CAAU;IAE9B,YAAmB,GAAW,EAAE,IAAY,EAAE,KAAc,EAAE,OAAgB,EAAE,GAAY,EAAE,IAAa;QACzG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { List } from "@noldova/context.collections";
|
|
10
|
+
import { ArgumentException } from "@noldova/context.exceptions";
|
|
11
|
+
import { Resources } from "../../resources.js";
|
|
12
|
+
import { KeyChord } from "./key-chord.js";
|
|
13
|
+
export class KeySequence {
|
|
14
|
+
text;
|
|
15
|
+
chords;
|
|
16
|
+
constructor(text, chords) {
|
|
17
|
+
this.text = text;
|
|
18
|
+
this.chords = chords;
|
|
19
|
+
}
|
|
20
|
+
get first() {
|
|
21
|
+
return this.chords.get(0);
|
|
22
|
+
}
|
|
23
|
+
static parse(text, primary) {
|
|
24
|
+
const parts = text.split(Resources.sequenceJoiner).filter(t => !String.isNullOrEmpty(t));
|
|
25
|
+
if (parts.length > Resources.sequenceChordLimit)
|
|
26
|
+
throw new ArgumentException(Resources.formatKeySequenceLength(text, Resources.sequenceChordLimit), Resources.keyParameter);
|
|
27
|
+
const chords = new List(parts.map(t => KeyChord.parse(t, primary)));
|
|
28
|
+
return new KeySequence(text, chords.count() === 0 ? new List([KeyChord.parse(text, primary)]) : chords);
|
|
29
|
+
}
|
|
30
|
+
equals(other) {
|
|
31
|
+
return this.chords.count() === other.chords.count() && this.chords.zip(other.chords, (mine, theirs) => mine.equals(theirs)).all(t => t);
|
|
32
|
+
}
|
|
33
|
+
label(platform) {
|
|
34
|
+
return this.chords.select(t => t.label(platform)).toArray().join(Resources.sequenceJoiner);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=key-sequence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-sequence.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/keys/key-sequence.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAsB,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,OAAO,WAAW;IACN,IAAI,CAAS;IACb,MAAM,CAA0B;IAEhD,YAAoB,IAAY,EAAE,MAA+B;QAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,IAAY,EAAE,OAAe;QAC/C,MAAM,KAAK,GAAsB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5G,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,kBAAkB;YAC7C,MAAM,IAAI,iBAAiB,CAAC,SAAS,CAAC,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,kBAAkB,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;QAC7H,MAAM,MAAM,GAAmB,IAAI,IAAI,CAAW,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAE9F,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACpH,CAAC;IAEM,MAAM,CAAC,KAAkB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1I,CAAC;IAEM,KAAK,CAAC,QAAgB;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC7F,CAAC;CACF"}
|
|
@@ -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
|
+
export class BlockComment {
|
|
9
|
+
open;
|
|
10
|
+
close;
|
|
11
|
+
constructor(open, close) {
|
|
12
|
+
this.open = open;
|
|
13
|
+
this.close = close;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=block-comment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-comment.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/languages/block-comment.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,YAAY;IACP,IAAI,CAAS;IACb,KAAK,CAAS;IAE9B,YAAmB,IAAY,EAAE,KAAa;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -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
|
+
export class BracketPair {
|
|
9
|
+
open;
|
|
10
|
+
close;
|
|
11
|
+
constructor(open, close) {
|
|
12
|
+
this.open = open;
|
|
13
|
+
this.close = close;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=bracket-pair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bracket-pair.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/languages/bracket-pair.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,WAAW;IACN,IAAI,CAAS;IACb,KAAK,CAAS;IAE9B,YAAmB,IAAY,EAAE,KAAa;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 LanguageDefinition {
|
|
9
|
+
id;
|
|
10
|
+
aliases;
|
|
11
|
+
extensions;
|
|
12
|
+
filenames;
|
|
13
|
+
filenamePatterns;
|
|
14
|
+
firstLine;
|
|
15
|
+
lineComment;
|
|
16
|
+
blockComment;
|
|
17
|
+
brackets;
|
|
18
|
+
wordCharacters;
|
|
19
|
+
constructor(id, aliases = undefined, extensions = undefined, filenames = undefined, filenamePatterns = undefined, firstLine = undefined, lineComment = undefined, blockComment = undefined, brackets = undefined, wordCharacters = undefined) {
|
|
20
|
+
this.id = id;
|
|
21
|
+
this.aliases = aliases;
|
|
22
|
+
this.extensions = extensions;
|
|
23
|
+
this.filenames = filenames;
|
|
24
|
+
this.filenamePatterns = filenamePatterns;
|
|
25
|
+
this.firstLine = firstLine;
|
|
26
|
+
this.lineComment = lineComment;
|
|
27
|
+
this.blockComment = blockComment;
|
|
28
|
+
this.brackets = brackets;
|
|
29
|
+
this.wordCharacters = wordCharacters;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=language-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-definition.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/languages/language-definition.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,OAAO,kBAAkB;IACb,EAAE,CAAS;IACX,OAAO,CAAoC;IAC3C,UAAU,CAAoC;IAC9C,SAAS,CAAoC;IAC7C,gBAAgB,CAAoC;IACpD,SAAS,CAAqB;IAC9B,WAAW,CAAqB;IAChC,YAAY,CAA2B;IACvC,QAAQ,CAAyC;IACjD,cAAc,CAAqB;IAEnD,YAAmB,EAAU,EAAE,UAA6C,SAAS,EAAE,aAAgD,SAAS,EAC9I,YAA+C,SAAS,EAAE,mBAAsD,SAAS,EAAE,YAAgC,SAAS,EACpK,cAAkC,SAAS,EAAE,eAAyC,SAAS,EAAE,WAAmD,SAAS,EAC7J,iBAAqC,SAAS;QAC9C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { Resources } from "../../resources.js";
|
|
9
|
+
export class LanguageFile {
|
|
10
|
+
path;
|
|
11
|
+
name;
|
|
12
|
+
constructor(path) {
|
|
13
|
+
this.path = path.replaceAll(Resources.windowsPathSeparator, Resources.pathSeparator).toLowerCase();
|
|
14
|
+
this.name = this.path.slice(this.path.lastIndexOf(Resources.pathSeparator) + 1);
|
|
15
|
+
}
|
|
16
|
+
hasName(names) {
|
|
17
|
+
return names.any(t => t.toLowerCase() === this.name);
|
|
18
|
+
}
|
|
19
|
+
hasExtension(extension) {
|
|
20
|
+
return this.name.endsWith(extension.toLowerCase());
|
|
21
|
+
}
|
|
22
|
+
matchesPattern(patterns) {
|
|
23
|
+
return patterns.any(t => (t.includes(Resources.pathSeparator) ? new RegExp(Resources.formatPathPatternSource(LanguageFile.sourceOf(t)), Resources.unicodeFlag).test(this.path) : new RegExp(Resources.formatNamePatternSource(LanguageFile.sourceOf(t)), Resources.unicodeFlag).test(this.name)));
|
|
24
|
+
}
|
|
25
|
+
static sourceOf(glob) {
|
|
26
|
+
return glob.toLowerCase().replace(Resources.globPartPattern, part => Resources.globSources.get(part) ?? part.replace(Resources.globSpecialPattern, Resources.regexEscape));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=language-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-file.js","sourceRoot":"","sources":["../../../../../src/noldova.code.editor/src/models/languages/language-file.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,OAAO,YAAY;IACP,IAAI,CAAS;IACb,IAAI,CAAS;IAE7B,YAAmB,IAAY;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,oBAAoB,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;QACnG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IAClF,CAAC;IAEM,OAAO,CAAC,KAA4B;QACzC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAEM,YAAY,CAAC,SAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;IACrD,CAAC;IAEM,cAAc,CAAC,QAA+B;QACnD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,uBAAuB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,uBAAuB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpS,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,IAAY;QAClC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,kBAAkB,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7K,CAAC;CACF"}
|
|
@@ -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
|
+
export class PhraseSet {
|
|
9
|
+
locale;
|
|
10
|
+
phrases;
|
|
11
|
+
constructor(locale, phrases) {
|
|
12
|
+
this.locale = locale;
|
|
13
|
+
this.phrases = phrases;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=phrase-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phrase-set.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor/src/models/phrase-set.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,SAAS;IACJ,MAAM,CAAS;IACf,OAAO,CAAkC;IAEzD,YAAmB,MAAc,EAAE,OAAwC;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phrase-text.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor/src/models/phrase-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -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
|
+
export class PluralPhrase {
|
|
9
|
+
other;
|
|
10
|
+
zero;
|
|
11
|
+
one;
|
|
12
|
+
two;
|
|
13
|
+
few;
|
|
14
|
+
many;
|
|
15
|
+
constructor(other, zero = undefined, one = undefined, two = undefined, few = undefined, many = undefined) {
|
|
16
|
+
this.other = other;
|
|
17
|
+
this.zero = zero;
|
|
18
|
+
this.one = one;
|
|
19
|
+
this.two = two;
|
|
20
|
+
this.few = few;
|
|
21
|
+
this.many = many;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=plural-phrase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plural-phrase.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor/src/models/plural-phrase.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,YAAY;IACP,KAAK,CAAS;IACd,IAAI,CAAqB;IACzB,GAAG,CAAqB;IACxB,GAAG,CAAqB;IACxB,GAAG,CAAqB;IACxB,IAAI,CAAqB;IAEzC,YAAmB,KAAa,EAAE,OAA2B,SAAS,EAAE,MAA0B,SAAS,EAAE,MAA0B,SAAS,EAC9I,MAA0B,SAAS,EAAE,OAA2B,SAAS;QACzE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -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
|
+
export class Registration {
|
|
9
|
+
remove;
|
|
10
|
+
removed = false;
|
|
11
|
+
constructor(remove) {
|
|
12
|
+
this.remove = remove;
|
|
13
|
+
}
|
|
14
|
+
[Symbol.dispose]() {
|
|
15
|
+
if (this.removed)
|
|
16
|
+
return;
|
|
17
|
+
this.removed = true;
|
|
18
|
+
this.remove();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor/src/models/registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,YAAY;IACN,MAAM,CAAa;IAC5B,OAAO,GAAY,KAAK,CAAC;IAEjC,YAAmB,MAAkB;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,IAAI,CAAC,OAAO;YACd,OAAO;QACT,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -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
|
+
export class SearchQuery {
|
|
9
|
+
text;
|
|
10
|
+
isRegex;
|
|
11
|
+
isCaseSensitive;
|
|
12
|
+
isWholeWord;
|
|
13
|
+
constructor(text, isRegex = false, isCaseSensitive = false, isWholeWord = false) {
|
|
14
|
+
this.text = text;
|
|
15
|
+
this.isRegex = isRegex;
|
|
16
|
+
this.isCaseSensitive = isCaseSensitive;
|
|
17
|
+
this.isWholeWord = isWholeWord;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=search-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-query.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor/src/models/search-query.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,WAAW;IACN,IAAI,CAAS;IACb,OAAO,CAAU;IACjB,eAAe,CAAU;IACzB,WAAW,CAAU;IAErC,YAAmB,IAAY,EAAE,UAAmB,KAAK,EAAE,kBAA2B,KAAK,EAAE,cAAuB,KAAK;QACvH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -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 "@noldova/context.core";
|
|
9
|
+
export class Setting {
|
|
10
|
+
id;
|
|
11
|
+
defaultValue;
|
|
12
|
+
description;
|
|
13
|
+
reader;
|
|
14
|
+
constructor(id, defaultValue, description, reader) {
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.defaultValue = defaultValue;
|
|
17
|
+
this.description = description;
|
|
18
|
+
this.reader = reader;
|
|
19
|
+
}
|
|
20
|
+
static boolean(id, defaultValue, description) {
|
|
21
|
+
return new Setting(id, defaultValue, description, t => Object.isBoolean(t) ? t : null);
|
|
22
|
+
}
|
|
23
|
+
static number(id, defaultValue, description, minimum = -Infinity, maximum = Infinity) {
|
|
24
|
+
return new Setting(id, defaultValue, description, t => Object.isNumber(t) && Number.isFinite(t) && t >= minimum && t <= maximum ? t : null);
|
|
25
|
+
}
|
|
26
|
+
static integer(id, defaultValue, description, minimum = -Infinity, maximum = Infinity) {
|
|
27
|
+
return new Setting(id, defaultValue, description, t => Object.isNumber(t) && Number.isInteger(t) && t >= minimum && t <= maximum ? t : null);
|
|
28
|
+
}
|
|
29
|
+
static string(id, defaultValue, description) {
|
|
30
|
+
return new Setting(id, defaultValue, description, t => Object.isString(t) ? t : null);
|
|
31
|
+
}
|
|
32
|
+
static choice(id, defaultValue, choices, description) {
|
|
33
|
+
return new Setting(id, defaultValue, description, t => choices.firstOrDefault(c => c === t) ?? null);
|
|
34
|
+
}
|
|
35
|
+
read(value) {
|
|
36
|
+
return this.reader(value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=setting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setting.js","sourceRoot":"","sources":["../../../../src/noldova.code.editor/src/models/setting.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,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AAC,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACvJ,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,EAAU,EAAE,YAAoB,EAAE,WAAmB;QACxE,OAAO,IAAI,OAAO,CAAS,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAChG,CAAC;IAEM,MAAM,CAAC,MAAM,CAAmB,EAAU,EAAE,YAAe,EAAE,OAAyB,EAAE,WAAmB;QAChH,OAAO,IAAI,OAAO,CAAI,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;IAC1G,CAAC;IAEM,IAAI,CAAC,KAAc;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,115 @@
|
|
|
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 { BinarySearchService } from "@noldova/context.collections";
|
|
10
|
+
import { Required } from "../../services/required.js";
|
|
11
|
+
export class LineChunk {
|
|
12
|
+
length;
|
|
13
|
+
source;
|
|
14
|
+
starts;
|
|
15
|
+
textEnds;
|
|
16
|
+
lineTexts;
|
|
17
|
+
lineEndings;
|
|
18
|
+
count;
|
|
19
|
+
constructor(source, starts, textEnds, texts, endings) {
|
|
20
|
+
this.source = source;
|
|
21
|
+
this.starts = starts;
|
|
22
|
+
this.textEnds = textEnds;
|
|
23
|
+
this.lineTexts = texts;
|
|
24
|
+
this.lineEndings = endings;
|
|
25
|
+
this.count = Object.isNull(source) ? texts.length : textEnds.length;
|
|
26
|
+
this.length = Object.isNull(source) ? LineChunk.measure(texts, endings) : source.length;
|
|
27
|
+
}
|
|
28
|
+
static ofLines(texts, endings) {
|
|
29
|
+
return new LineChunk(null, [], [], texts, endings);
|
|
30
|
+
}
|
|
31
|
+
static ofSource(source, starts, textEnds) {
|
|
32
|
+
return new LineChunk(source, starts, textEnds, [], []);
|
|
33
|
+
}
|
|
34
|
+
get lineCount() {
|
|
35
|
+
return this.count;
|
|
36
|
+
}
|
|
37
|
+
get texts() {
|
|
38
|
+
this.split();
|
|
39
|
+
return this.lineTexts;
|
|
40
|
+
}
|
|
41
|
+
get endings() {
|
|
42
|
+
this.split();
|
|
43
|
+
return this.lineEndings;
|
|
44
|
+
}
|
|
45
|
+
textAt(line) {
|
|
46
|
+
if (Object.isNull(this.source))
|
|
47
|
+
return Required.at(this.lineTexts, line);
|
|
48
|
+
return this.source.slice(Required.at(this.starts, line), Required.at(this.textEnds, line));
|
|
49
|
+
}
|
|
50
|
+
endingAt(line) {
|
|
51
|
+
if (Object.isNull(this.source))
|
|
52
|
+
return Required.at(this.lineEndings, line);
|
|
53
|
+
return this.source.slice(Required.at(this.textEnds, line), Required.at(this.starts, line + 1));
|
|
54
|
+
}
|
|
55
|
+
text() {
|
|
56
|
+
if (!Object.isNull(this.source))
|
|
57
|
+
return this.source;
|
|
58
|
+
const parts = [];
|
|
59
|
+
for (let index = 0; index < this.count; index++)
|
|
60
|
+
parts.push(Required.at(this.lineTexts, index), Required.at(this.lineEndings, index));
|
|
61
|
+
return parts.join(String.empty);
|
|
62
|
+
}
|
|
63
|
+
replace(start, deleteCount, texts, endings) {
|
|
64
|
+
this.split();
|
|
65
|
+
this.lineTexts = this.lineTexts.slice(0, start).concat(texts, this.lineTexts.slice(start + deleteCount));
|
|
66
|
+
this.lineEndings = this.lineEndings.slice(0, start).concat(endings, this.lineEndings.slice(start + deleteCount));
|
|
67
|
+
this.count = this.lineTexts.length;
|
|
68
|
+
this.length = LineChunk.measure(this.lineTexts, this.lineEndings);
|
|
69
|
+
}
|
|
70
|
+
offsetOf(line) {
|
|
71
|
+
if (!Object.isNull(this.source))
|
|
72
|
+
return Required.at(this.starts, line);
|
|
73
|
+
let offset = 0;
|
|
74
|
+
for (let index = 0; index < line; index++)
|
|
75
|
+
offset += Required.at(this.lineTexts, index).length + Required.at(this.lineEndings, index).length;
|
|
76
|
+
return offset;
|
|
77
|
+
}
|
|
78
|
+
lineAt(offset) {
|
|
79
|
+
if (!Object.isNull(this.source))
|
|
80
|
+
return Math.min(BinarySearchService.floorIndex(this.starts, offset), this.count - 1);
|
|
81
|
+
let rest = offset;
|
|
82
|
+
let line = 0;
|
|
83
|
+
let length = Required.at(this.lineTexts, 0).length + Required.at(this.lineEndings, 0).length;
|
|
84
|
+
while (rest >= length && line < this.count - 1) {
|
|
85
|
+
rest -= length;
|
|
86
|
+
line++;
|
|
87
|
+
length = Required.at(this.lineTexts, line).length + Required.at(this.lineEndings, line).length;
|
|
88
|
+
}
|
|
89
|
+
return line;
|
|
90
|
+
}
|
|
91
|
+
split() {
|
|
92
|
+
if (Object.isNull(this.source))
|
|
93
|
+
return;
|
|
94
|
+
const texts = [];
|
|
95
|
+
const endings = [];
|
|
96
|
+
for (let index = 0; index < this.count; index++) {
|
|
97
|
+
texts.push(this.textAt(index));
|
|
98
|
+
endings.push(this.endingAt(index));
|
|
99
|
+
}
|
|
100
|
+
this.lineTexts = texts;
|
|
101
|
+
this.lineEndings = endings;
|
|
102
|
+
this.starts = [];
|
|
103
|
+
this.textEnds = [];
|
|
104
|
+
this.source = null;
|
|
105
|
+
}
|
|
106
|
+
static measure(texts, endings) {
|
|
107
|
+
let length = 0;
|
|
108
|
+
for (const text of texts)
|
|
109
|
+
length += text.length;
|
|
110
|
+
for (const ending of endings)
|
|
111
|
+
length += ending.length;
|
|
112
|
+
return length;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=line-chunk.js.map
|