@opentui/core 0.0.0-20251205-41c885f6 → 0.0.0-20251208-bec95e7d
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/3d.js +31289 -53
- package/3d.js.map +136 -3
- package/Renderable.d.ts +2 -1
- package/{index-x5bb5xvn.js → index-crebvcxc.js} +2525 -160
- package/index-crebvcxc.js.map +59 -0
- package/index.d.ts +1 -1
- package/index.js +984 -101
- package/index.js.map +23 -14
- package/lib/bunfs.d.ts +7 -0
- package/lib/keymapping.d.ts +4 -1
- package/lib/yoga.options.d.ts +1 -1
- package/package.json +9 -9
- package/parser.worker.js +17 -3
- package/parser.worker.js.map +6 -5
- package/renderables/Diff.d.ts +4 -0
- package/renderables/Input.d.ts +10 -0
- package/renderables/Select.d.ts +10 -0
- package/renderables/TabSelect.d.ts +10 -0
- package/renderables/Textarea.d.ts +5 -1
- package/renderer.d.ts +19 -0
- package/testing/mock-keys.d.ts +12 -0
- package/testing/test-recorder.d.ts +44 -0
- package/testing.d.ts +1 -0
- package/testing.js +69 -3
- package/testing.js.map +6 -5
- package/index-x5bb5xvn.js.map +0 -53
package/index.js
CHANGED
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
ConsolePosition,
|
|
10
10
|
DataPathsManager,
|
|
11
11
|
DebugOverlayCorner,
|
|
12
|
+
Edge,
|
|
12
13
|
ExtmarksController,
|
|
14
|
+
Gutter,
|
|
13
15
|
InternalKeyHandler,
|
|
14
16
|
KeyEvent,
|
|
15
17
|
KeyHandler,
|
|
@@ -17,6 +19,7 @@ import {
|
|
|
17
19
|
LinearScrollAccel,
|
|
18
20
|
LogLevel,
|
|
19
21
|
MacOSScrollAccel,
|
|
22
|
+
MeasureMode,
|
|
20
23
|
MouseButton,
|
|
21
24
|
MouseEvent,
|
|
22
25
|
MouseParser,
|
|
@@ -71,6 +74,7 @@ import {
|
|
|
71
74
|
dim,
|
|
72
75
|
env,
|
|
73
76
|
envRegistry,
|
|
77
|
+
exports_src,
|
|
74
78
|
extToFiletype,
|
|
75
79
|
fg,
|
|
76
80
|
fonts,
|
|
@@ -133,7 +137,7 @@ import {
|
|
|
133
137
|
white,
|
|
134
138
|
wrapWithDelegates,
|
|
135
139
|
yellow
|
|
136
|
-
} from "./index-
|
|
140
|
+
} from "./index-crebvcxc.js";
|
|
137
141
|
// src/text-buffer-view.ts
|
|
138
142
|
class TextBufferView {
|
|
139
143
|
lib;
|
|
@@ -2197,7 +2201,6 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
|
|
|
2197
2201
|
}
|
|
2198
2202
|
}
|
|
2199
2203
|
// src/renderables/Box.ts
|
|
2200
|
-
import { Edge, Gutter } from "bun-yoga";
|
|
2201
2204
|
function isGapType(value) {
|
|
2202
2205
|
if (value === undefined) {
|
|
2203
2206
|
return true;
|
|
@@ -2414,7 +2417,6 @@ class BoxRenderable extends Renderable {
|
|
|
2414
2417
|
}
|
|
2415
2418
|
}
|
|
2416
2419
|
// src/renderables/TextBufferRenderable.ts
|
|
2417
|
-
import { MeasureMode } from "bun-yoga";
|
|
2418
2420
|
class TextBufferRenderable extends Renderable {
|
|
2419
2421
|
selectable = true;
|
|
2420
2422
|
_defaultFg;
|
|
@@ -3754,8 +3756,720 @@ class LineNumberRenderable extends Renderable {
|
|
|
3754
3756
|
}
|
|
3755
3757
|
}
|
|
3756
3758
|
|
|
3757
|
-
//
|
|
3758
|
-
|
|
3759
|
+
// ../../node_modules/diff/libesm/diff/base.js
|
|
3760
|
+
class Diff {
|
|
3761
|
+
diff(oldStr, newStr, options = {}) {
|
|
3762
|
+
let callback;
|
|
3763
|
+
if (typeof options === "function") {
|
|
3764
|
+
callback = options;
|
|
3765
|
+
options = {};
|
|
3766
|
+
} else if ("callback" in options) {
|
|
3767
|
+
callback = options.callback;
|
|
3768
|
+
}
|
|
3769
|
+
const oldString = this.castInput(oldStr, options);
|
|
3770
|
+
const newString = this.castInput(newStr, options);
|
|
3771
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
3772
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
3773
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
3774
|
+
}
|
|
3775
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
3776
|
+
var _a;
|
|
3777
|
+
const done = (value) => {
|
|
3778
|
+
value = this.postProcess(value, options);
|
|
3779
|
+
if (callback) {
|
|
3780
|
+
setTimeout(function() {
|
|
3781
|
+
callback(value);
|
|
3782
|
+
}, 0);
|
|
3783
|
+
return;
|
|
3784
|
+
} else {
|
|
3785
|
+
return value;
|
|
3786
|
+
}
|
|
3787
|
+
};
|
|
3788
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
3789
|
+
let editLength = 1;
|
|
3790
|
+
let maxEditLength = newLen + oldLen;
|
|
3791
|
+
if (options.maxEditLength != null) {
|
|
3792
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
3793
|
+
}
|
|
3794
|
+
const maxExecutionTime = (_a = options.timeout) !== null && _a !== undefined ? _a : Infinity;
|
|
3795
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
3796
|
+
const bestPath = [{ oldPos: -1, lastComponent: undefined }];
|
|
3797
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
3798
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
3799
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
3800
|
+
}
|
|
3801
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
3802
|
+
const execEditLength = () => {
|
|
3803
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength);diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
3804
|
+
let basePath;
|
|
3805
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
3806
|
+
if (removePath) {
|
|
3807
|
+
bestPath[diagonalPath - 1] = undefined;
|
|
3808
|
+
}
|
|
3809
|
+
let canAdd = false;
|
|
3810
|
+
if (addPath) {
|
|
3811
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
3812
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
3813
|
+
}
|
|
3814
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
3815
|
+
if (!canAdd && !canRemove) {
|
|
3816
|
+
bestPath[diagonalPath] = undefined;
|
|
3817
|
+
continue;
|
|
3818
|
+
}
|
|
3819
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
3820
|
+
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
3821
|
+
} else {
|
|
3822
|
+
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
3823
|
+
}
|
|
3824
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
3825
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
3826
|
+
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
3827
|
+
} else {
|
|
3828
|
+
bestPath[diagonalPath] = basePath;
|
|
3829
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
3830
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
3831
|
+
}
|
|
3832
|
+
if (newPos + 1 >= newLen) {
|
|
3833
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
editLength++;
|
|
3838
|
+
};
|
|
3839
|
+
if (callback) {
|
|
3840
|
+
(function exec() {
|
|
3841
|
+
setTimeout(function() {
|
|
3842
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
3843
|
+
return callback(undefined);
|
|
3844
|
+
}
|
|
3845
|
+
if (!execEditLength()) {
|
|
3846
|
+
exec();
|
|
3847
|
+
}
|
|
3848
|
+
}, 0);
|
|
3849
|
+
})();
|
|
3850
|
+
} else {
|
|
3851
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
3852
|
+
const ret = execEditLength();
|
|
3853
|
+
if (ret) {
|
|
3854
|
+
return ret;
|
|
3855
|
+
}
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
addToPath(path, added, removed, oldPosInc, options) {
|
|
3860
|
+
const last = path.lastComponent;
|
|
3861
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
3862
|
+
return {
|
|
3863
|
+
oldPos: path.oldPos + oldPosInc,
|
|
3864
|
+
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
3865
|
+
};
|
|
3866
|
+
} else {
|
|
3867
|
+
return {
|
|
3868
|
+
oldPos: path.oldPos + oldPosInc,
|
|
3869
|
+
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
3870
|
+
};
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
3874
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
3875
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
3876
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
3877
|
+
newPos++;
|
|
3878
|
+
oldPos++;
|
|
3879
|
+
commonCount++;
|
|
3880
|
+
if (options.oneChangePerToken) {
|
|
3881
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
3882
|
+
}
|
|
3883
|
+
}
|
|
3884
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
3885
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
3886
|
+
}
|
|
3887
|
+
basePath.oldPos = oldPos;
|
|
3888
|
+
return newPos;
|
|
3889
|
+
}
|
|
3890
|
+
equals(left, right, options) {
|
|
3891
|
+
if (options.comparator) {
|
|
3892
|
+
return options.comparator(left, right);
|
|
3893
|
+
} else {
|
|
3894
|
+
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3897
|
+
removeEmpty(array) {
|
|
3898
|
+
const ret = [];
|
|
3899
|
+
for (let i = 0;i < array.length; i++) {
|
|
3900
|
+
if (array[i]) {
|
|
3901
|
+
ret.push(array[i]);
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
return ret;
|
|
3905
|
+
}
|
|
3906
|
+
castInput(value, options) {
|
|
3907
|
+
return value;
|
|
3908
|
+
}
|
|
3909
|
+
tokenize(value, options) {
|
|
3910
|
+
return Array.from(value);
|
|
3911
|
+
}
|
|
3912
|
+
join(chars) {
|
|
3913
|
+
return chars.join("");
|
|
3914
|
+
}
|
|
3915
|
+
postProcess(changeObjects, options) {
|
|
3916
|
+
return changeObjects;
|
|
3917
|
+
}
|
|
3918
|
+
get useLongestToken() {
|
|
3919
|
+
return false;
|
|
3920
|
+
}
|
|
3921
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
3922
|
+
const components = [];
|
|
3923
|
+
let nextComponent;
|
|
3924
|
+
while (lastComponent) {
|
|
3925
|
+
components.push(lastComponent);
|
|
3926
|
+
nextComponent = lastComponent.previousComponent;
|
|
3927
|
+
delete lastComponent.previousComponent;
|
|
3928
|
+
lastComponent = nextComponent;
|
|
3929
|
+
}
|
|
3930
|
+
components.reverse();
|
|
3931
|
+
const componentLen = components.length;
|
|
3932
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
3933
|
+
for (;componentPos < componentLen; componentPos++) {
|
|
3934
|
+
const component = components[componentPos];
|
|
3935
|
+
if (!component.removed) {
|
|
3936
|
+
if (!component.added && this.useLongestToken) {
|
|
3937
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
3938
|
+
value = value.map(function(value2, i) {
|
|
3939
|
+
const oldValue = oldTokens[oldPos + i];
|
|
3940
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
3941
|
+
});
|
|
3942
|
+
component.value = this.join(value);
|
|
3943
|
+
} else {
|
|
3944
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
3945
|
+
}
|
|
3946
|
+
newPos += component.count;
|
|
3947
|
+
if (!component.added) {
|
|
3948
|
+
oldPos += component.count;
|
|
3949
|
+
}
|
|
3950
|
+
} else {
|
|
3951
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
3952
|
+
oldPos += component.count;
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
return components;
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3959
|
+
// ../../node_modules/diff/libesm/diff/character.js
|
|
3960
|
+
class CharacterDiff extends Diff {
|
|
3961
|
+
}
|
|
3962
|
+
var characterDiff = new CharacterDiff;
|
|
3963
|
+
|
|
3964
|
+
// ../../node_modules/diff/libesm/util/string.js
|
|
3965
|
+
function longestCommonPrefix(str1, str2) {
|
|
3966
|
+
let i;
|
|
3967
|
+
for (i = 0;i < str1.length && i < str2.length; i++) {
|
|
3968
|
+
if (str1[i] != str2[i]) {
|
|
3969
|
+
return str1.slice(0, i);
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
return str1.slice(0, i);
|
|
3973
|
+
}
|
|
3974
|
+
function longestCommonSuffix(str1, str2) {
|
|
3975
|
+
let i;
|
|
3976
|
+
if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
|
|
3977
|
+
return "";
|
|
3978
|
+
}
|
|
3979
|
+
for (i = 0;i < str1.length && i < str2.length; i++) {
|
|
3980
|
+
if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
|
|
3981
|
+
return str1.slice(-i);
|
|
3982
|
+
}
|
|
3983
|
+
}
|
|
3984
|
+
return str1.slice(-i);
|
|
3985
|
+
}
|
|
3986
|
+
function replacePrefix(string, oldPrefix, newPrefix) {
|
|
3987
|
+
if (string.slice(0, oldPrefix.length) != oldPrefix) {
|
|
3988
|
+
throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
|
|
3989
|
+
}
|
|
3990
|
+
return newPrefix + string.slice(oldPrefix.length);
|
|
3991
|
+
}
|
|
3992
|
+
function replaceSuffix(string, oldSuffix, newSuffix) {
|
|
3993
|
+
if (!oldSuffix) {
|
|
3994
|
+
return string + newSuffix;
|
|
3995
|
+
}
|
|
3996
|
+
if (string.slice(-oldSuffix.length) != oldSuffix) {
|
|
3997
|
+
throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
|
|
3998
|
+
}
|
|
3999
|
+
return string.slice(0, -oldSuffix.length) + newSuffix;
|
|
4000
|
+
}
|
|
4001
|
+
function removePrefix(string, oldPrefix) {
|
|
4002
|
+
return replacePrefix(string, oldPrefix, "");
|
|
4003
|
+
}
|
|
4004
|
+
function removeSuffix(string, oldSuffix) {
|
|
4005
|
+
return replaceSuffix(string, oldSuffix, "");
|
|
4006
|
+
}
|
|
4007
|
+
function maximumOverlap(string1, string2) {
|
|
4008
|
+
return string2.slice(0, overlapCount(string1, string2));
|
|
4009
|
+
}
|
|
4010
|
+
function overlapCount(a, b) {
|
|
4011
|
+
let startA = 0;
|
|
4012
|
+
if (a.length > b.length) {
|
|
4013
|
+
startA = a.length - b.length;
|
|
4014
|
+
}
|
|
4015
|
+
let endB = b.length;
|
|
4016
|
+
if (a.length < b.length) {
|
|
4017
|
+
endB = a.length;
|
|
4018
|
+
}
|
|
4019
|
+
const map = Array(endB);
|
|
4020
|
+
let k = 0;
|
|
4021
|
+
map[0] = 0;
|
|
4022
|
+
for (let j = 1;j < endB; j++) {
|
|
4023
|
+
if (b[j] == b[k]) {
|
|
4024
|
+
map[j] = map[k];
|
|
4025
|
+
} else {
|
|
4026
|
+
map[j] = k;
|
|
4027
|
+
}
|
|
4028
|
+
while (k > 0 && b[j] != b[k]) {
|
|
4029
|
+
k = map[k];
|
|
4030
|
+
}
|
|
4031
|
+
if (b[j] == b[k]) {
|
|
4032
|
+
k++;
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
k = 0;
|
|
4036
|
+
for (let i = startA;i < a.length; i++) {
|
|
4037
|
+
while (k > 0 && a[i] != b[k]) {
|
|
4038
|
+
k = map[k];
|
|
4039
|
+
}
|
|
4040
|
+
if (a[i] == b[k]) {
|
|
4041
|
+
k++;
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
return k;
|
|
4045
|
+
}
|
|
4046
|
+
function trailingWs(string) {
|
|
4047
|
+
let i;
|
|
4048
|
+
for (i = string.length - 1;i >= 0; i--) {
|
|
4049
|
+
if (!string[i].match(/\s/)) {
|
|
4050
|
+
break;
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
return string.substring(i + 1);
|
|
4054
|
+
}
|
|
4055
|
+
function leadingWs(string) {
|
|
4056
|
+
const match = string.match(/^\s*/);
|
|
4057
|
+
return match ? match[0] : "";
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
// ../../node_modules/diff/libesm/diff/word.js
|
|
4061
|
+
var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
|
|
4062
|
+
var tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
|
|
4063
|
+
|
|
4064
|
+
class WordDiff extends Diff {
|
|
4065
|
+
equals(left, right, options) {
|
|
4066
|
+
if (options.ignoreCase) {
|
|
4067
|
+
left = left.toLowerCase();
|
|
4068
|
+
right = right.toLowerCase();
|
|
4069
|
+
}
|
|
4070
|
+
return left.trim() === right.trim();
|
|
4071
|
+
}
|
|
4072
|
+
tokenize(value, options = {}) {
|
|
4073
|
+
let parts;
|
|
4074
|
+
if (options.intlSegmenter) {
|
|
4075
|
+
const segmenter = options.intlSegmenter;
|
|
4076
|
+
if (segmenter.resolvedOptions().granularity != "word") {
|
|
4077
|
+
throw new Error('The segmenter passed must have a granularity of "word"');
|
|
4078
|
+
}
|
|
4079
|
+
parts = Array.from(segmenter.segment(value), (segment) => segment.segment);
|
|
4080
|
+
} else {
|
|
4081
|
+
parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
4082
|
+
}
|
|
4083
|
+
const tokens = [];
|
|
4084
|
+
let prevPart = null;
|
|
4085
|
+
parts.forEach((part) => {
|
|
4086
|
+
if (/\s/.test(part)) {
|
|
4087
|
+
if (prevPart == null) {
|
|
4088
|
+
tokens.push(part);
|
|
4089
|
+
} else {
|
|
4090
|
+
tokens.push(tokens.pop() + part);
|
|
4091
|
+
}
|
|
4092
|
+
} else if (prevPart != null && /\s/.test(prevPart)) {
|
|
4093
|
+
if (tokens[tokens.length - 1] == prevPart) {
|
|
4094
|
+
tokens.push(tokens.pop() + part);
|
|
4095
|
+
} else {
|
|
4096
|
+
tokens.push(prevPart + part);
|
|
4097
|
+
}
|
|
4098
|
+
} else {
|
|
4099
|
+
tokens.push(part);
|
|
4100
|
+
}
|
|
4101
|
+
prevPart = part;
|
|
4102
|
+
});
|
|
4103
|
+
return tokens;
|
|
4104
|
+
}
|
|
4105
|
+
join(tokens) {
|
|
4106
|
+
return tokens.map((token, i) => {
|
|
4107
|
+
if (i == 0) {
|
|
4108
|
+
return token;
|
|
4109
|
+
} else {
|
|
4110
|
+
return token.replace(/^\s+/, "");
|
|
4111
|
+
}
|
|
4112
|
+
}).join("");
|
|
4113
|
+
}
|
|
4114
|
+
postProcess(changes, options) {
|
|
4115
|
+
if (!changes || options.oneChangePerToken) {
|
|
4116
|
+
return changes;
|
|
4117
|
+
}
|
|
4118
|
+
let lastKeep = null;
|
|
4119
|
+
let insertion = null;
|
|
4120
|
+
let deletion = null;
|
|
4121
|
+
changes.forEach((change) => {
|
|
4122
|
+
if (change.added) {
|
|
4123
|
+
insertion = change;
|
|
4124
|
+
} else if (change.removed) {
|
|
4125
|
+
deletion = change;
|
|
4126
|
+
} else {
|
|
4127
|
+
if (insertion || deletion) {
|
|
4128
|
+
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
|
|
4129
|
+
}
|
|
4130
|
+
lastKeep = change;
|
|
4131
|
+
insertion = null;
|
|
4132
|
+
deletion = null;
|
|
4133
|
+
}
|
|
4134
|
+
});
|
|
4135
|
+
if (insertion || deletion) {
|
|
4136
|
+
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
|
|
4137
|
+
}
|
|
4138
|
+
return changes;
|
|
4139
|
+
}
|
|
4140
|
+
}
|
|
4141
|
+
var wordDiff = new WordDiff;
|
|
4142
|
+
function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
|
|
4143
|
+
if (deletion && insertion) {
|
|
4144
|
+
const oldWsPrefix = leadingWs(deletion.value);
|
|
4145
|
+
const oldWsSuffix = trailingWs(deletion.value);
|
|
4146
|
+
const newWsPrefix = leadingWs(insertion.value);
|
|
4147
|
+
const newWsSuffix = trailingWs(insertion.value);
|
|
4148
|
+
if (startKeep) {
|
|
4149
|
+
const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
|
|
4150
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
|
|
4151
|
+
deletion.value = removePrefix(deletion.value, commonWsPrefix);
|
|
4152
|
+
insertion.value = removePrefix(insertion.value, commonWsPrefix);
|
|
4153
|
+
}
|
|
4154
|
+
if (endKeep) {
|
|
4155
|
+
const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
|
|
4156
|
+
endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
|
|
4157
|
+
deletion.value = removeSuffix(deletion.value, commonWsSuffix);
|
|
4158
|
+
insertion.value = removeSuffix(insertion.value, commonWsSuffix);
|
|
4159
|
+
}
|
|
4160
|
+
} else if (insertion) {
|
|
4161
|
+
if (startKeep) {
|
|
4162
|
+
const ws = leadingWs(insertion.value);
|
|
4163
|
+
insertion.value = insertion.value.substring(ws.length);
|
|
4164
|
+
}
|
|
4165
|
+
if (endKeep) {
|
|
4166
|
+
const ws = leadingWs(endKeep.value);
|
|
4167
|
+
endKeep.value = endKeep.value.substring(ws.length);
|
|
4168
|
+
}
|
|
4169
|
+
} else if (startKeep && endKeep) {
|
|
4170
|
+
const newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value);
|
|
4171
|
+
const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
|
|
4172
|
+
deletion.value = removePrefix(deletion.value, newWsStart);
|
|
4173
|
+
const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
|
|
4174
|
+
deletion.value = removeSuffix(deletion.value, newWsEnd);
|
|
4175
|
+
endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
|
|
4176
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
|
|
4177
|
+
} else if (endKeep) {
|
|
4178
|
+
const endKeepWsPrefix = leadingWs(endKeep.value);
|
|
4179
|
+
const deletionWsSuffix = trailingWs(deletion.value);
|
|
4180
|
+
const overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
|
|
4181
|
+
deletion.value = removeSuffix(deletion.value, overlap);
|
|
4182
|
+
} else if (startKeep) {
|
|
4183
|
+
const startKeepWsSuffix = trailingWs(startKeep.value);
|
|
4184
|
+
const deletionWsPrefix = leadingWs(deletion.value);
|
|
4185
|
+
const overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
|
|
4186
|
+
deletion.value = removePrefix(deletion.value, overlap);
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4189
|
+
|
|
4190
|
+
class WordsWithSpaceDiff extends Diff {
|
|
4191
|
+
tokenize(value) {
|
|
4192
|
+
const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
|
|
4193
|
+
return value.match(regex) || [];
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
var wordsWithSpaceDiff = new WordsWithSpaceDiff;
|
|
4197
|
+
|
|
4198
|
+
// ../../node_modules/diff/libesm/diff/line.js
|
|
4199
|
+
class LineDiff extends Diff {
|
|
4200
|
+
constructor() {
|
|
4201
|
+
super(...arguments);
|
|
4202
|
+
this.tokenize = tokenize;
|
|
4203
|
+
}
|
|
4204
|
+
equals(left, right, options) {
|
|
4205
|
+
if (options.ignoreWhitespace) {
|
|
4206
|
+
if (!options.newlineIsToken || !left.includes(`
|
|
4207
|
+
`)) {
|
|
4208
|
+
left = left.trim();
|
|
4209
|
+
}
|
|
4210
|
+
if (!options.newlineIsToken || !right.includes(`
|
|
4211
|
+
`)) {
|
|
4212
|
+
right = right.trim();
|
|
4213
|
+
}
|
|
4214
|
+
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
4215
|
+
if (left.endsWith(`
|
|
4216
|
+
`)) {
|
|
4217
|
+
left = left.slice(0, -1);
|
|
4218
|
+
}
|
|
4219
|
+
if (right.endsWith(`
|
|
4220
|
+
`)) {
|
|
4221
|
+
right = right.slice(0, -1);
|
|
4222
|
+
}
|
|
4223
|
+
}
|
|
4224
|
+
return super.equals(left, right, options);
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
var lineDiff = new LineDiff;
|
|
4228
|
+
function tokenize(value, options) {
|
|
4229
|
+
if (options.stripTrailingCr) {
|
|
4230
|
+
value = value.replace(/\r\n/g, `
|
|
4231
|
+
`);
|
|
4232
|
+
}
|
|
4233
|
+
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
4234
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
4235
|
+
linesAndNewlines.pop();
|
|
4236
|
+
}
|
|
4237
|
+
for (let i = 0;i < linesAndNewlines.length; i++) {
|
|
4238
|
+
const line = linesAndNewlines[i];
|
|
4239
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
4240
|
+
retLines[retLines.length - 1] += line;
|
|
4241
|
+
} else {
|
|
4242
|
+
retLines.push(line);
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
return retLines;
|
|
4246
|
+
}
|
|
4247
|
+
|
|
4248
|
+
// ../../node_modules/diff/libesm/diff/sentence.js
|
|
4249
|
+
function isSentenceEndPunct(char) {
|
|
4250
|
+
return char == "." || char == "!" || char == "?";
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4253
|
+
class SentenceDiff extends Diff {
|
|
4254
|
+
tokenize(value) {
|
|
4255
|
+
var _a;
|
|
4256
|
+
const result = [];
|
|
4257
|
+
let tokenStartI = 0;
|
|
4258
|
+
for (let i = 0;i < value.length; i++) {
|
|
4259
|
+
if (i == value.length - 1) {
|
|
4260
|
+
result.push(value.slice(tokenStartI));
|
|
4261
|
+
break;
|
|
4262
|
+
}
|
|
4263
|
+
if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
|
|
4264
|
+
result.push(value.slice(tokenStartI, i + 1));
|
|
4265
|
+
i = tokenStartI = i + 1;
|
|
4266
|
+
while ((_a = value[i + 1]) === null || _a === undefined ? undefined : _a.match(/\s/)) {
|
|
4267
|
+
i++;
|
|
4268
|
+
}
|
|
4269
|
+
result.push(value.slice(tokenStartI, i + 1));
|
|
4270
|
+
tokenStartI = i + 1;
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
return result;
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4276
|
+
var sentenceDiff = new SentenceDiff;
|
|
4277
|
+
|
|
4278
|
+
// ../../node_modules/diff/libesm/diff/css.js
|
|
4279
|
+
class CssDiff extends Diff {
|
|
4280
|
+
tokenize(value) {
|
|
4281
|
+
return value.split(/([{}:;,]|\s+)/);
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
var cssDiff = new CssDiff;
|
|
4285
|
+
|
|
4286
|
+
// ../../node_modules/diff/libesm/diff/json.js
|
|
4287
|
+
class JsonDiff extends Diff {
|
|
4288
|
+
constructor() {
|
|
4289
|
+
super(...arguments);
|
|
4290
|
+
this.tokenize = tokenize;
|
|
4291
|
+
}
|
|
4292
|
+
get useLongestToken() {
|
|
4293
|
+
return true;
|
|
4294
|
+
}
|
|
4295
|
+
castInput(value, options) {
|
|
4296
|
+
const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
|
|
4297
|
+
return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
|
|
4298
|
+
}
|
|
4299
|
+
equals(left, right, options) {
|
|
4300
|
+
return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
|
|
4301
|
+
}
|
|
4302
|
+
}
|
|
4303
|
+
var jsonDiff = new JsonDiff;
|
|
4304
|
+
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
4305
|
+
stack = stack || [];
|
|
4306
|
+
replacementStack = replacementStack || [];
|
|
4307
|
+
if (replacer) {
|
|
4308
|
+
obj = replacer(key === undefined ? "" : key, obj);
|
|
4309
|
+
}
|
|
4310
|
+
let i;
|
|
4311
|
+
for (i = 0;i < stack.length; i += 1) {
|
|
4312
|
+
if (stack[i] === obj) {
|
|
4313
|
+
return replacementStack[i];
|
|
4314
|
+
}
|
|
4315
|
+
}
|
|
4316
|
+
let canonicalizedObj;
|
|
4317
|
+
if (Object.prototype.toString.call(obj) === "[object Array]") {
|
|
4318
|
+
stack.push(obj);
|
|
4319
|
+
canonicalizedObj = new Array(obj.length);
|
|
4320
|
+
replacementStack.push(canonicalizedObj);
|
|
4321
|
+
for (i = 0;i < obj.length; i += 1) {
|
|
4322
|
+
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
|
|
4323
|
+
}
|
|
4324
|
+
stack.pop();
|
|
4325
|
+
replacementStack.pop();
|
|
4326
|
+
return canonicalizedObj;
|
|
4327
|
+
}
|
|
4328
|
+
if (obj && obj.toJSON) {
|
|
4329
|
+
obj = obj.toJSON();
|
|
4330
|
+
}
|
|
4331
|
+
if (typeof obj === "object" && obj !== null) {
|
|
4332
|
+
stack.push(obj);
|
|
4333
|
+
canonicalizedObj = {};
|
|
4334
|
+
replacementStack.push(canonicalizedObj);
|
|
4335
|
+
const sortedKeys = [];
|
|
4336
|
+
let key2;
|
|
4337
|
+
for (key2 in obj) {
|
|
4338
|
+
if (Object.prototype.hasOwnProperty.call(obj, key2)) {
|
|
4339
|
+
sortedKeys.push(key2);
|
|
4340
|
+
}
|
|
4341
|
+
}
|
|
4342
|
+
sortedKeys.sort();
|
|
4343
|
+
for (i = 0;i < sortedKeys.length; i += 1) {
|
|
4344
|
+
key2 = sortedKeys[i];
|
|
4345
|
+
canonicalizedObj[key2] = canonicalize(obj[key2], stack, replacementStack, replacer, key2);
|
|
4346
|
+
}
|
|
4347
|
+
stack.pop();
|
|
4348
|
+
replacementStack.pop();
|
|
4349
|
+
} else {
|
|
4350
|
+
canonicalizedObj = obj;
|
|
4351
|
+
}
|
|
4352
|
+
return canonicalizedObj;
|
|
4353
|
+
}
|
|
4354
|
+
|
|
4355
|
+
// ../../node_modules/diff/libesm/diff/array.js
|
|
4356
|
+
class ArrayDiff extends Diff {
|
|
4357
|
+
tokenize(value) {
|
|
4358
|
+
return value.slice();
|
|
4359
|
+
}
|
|
4360
|
+
join(value) {
|
|
4361
|
+
return value;
|
|
4362
|
+
}
|
|
4363
|
+
removeEmpty(value) {
|
|
4364
|
+
return value;
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
var arrayDiff = new ArrayDiff;
|
|
4368
|
+
|
|
4369
|
+
// ../../node_modules/diff/libesm/patch/parse.js
|
|
4370
|
+
function parsePatch(uniDiff) {
|
|
4371
|
+
const diffstr = uniDiff.split(/\n/), list = [];
|
|
4372
|
+
let i = 0;
|
|
4373
|
+
function parseIndex() {
|
|
4374
|
+
const index = {};
|
|
4375
|
+
list.push(index);
|
|
4376
|
+
while (i < diffstr.length) {
|
|
4377
|
+
const line = diffstr[i];
|
|
4378
|
+
if (/^(---|\+\+\+|@@)\s/.test(line)) {
|
|
4379
|
+
break;
|
|
4380
|
+
}
|
|
4381
|
+
const header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
|
|
4382
|
+
if (header) {
|
|
4383
|
+
index.index = header[1];
|
|
4384
|
+
}
|
|
4385
|
+
i++;
|
|
4386
|
+
}
|
|
4387
|
+
parseFileHeader(index);
|
|
4388
|
+
parseFileHeader(index);
|
|
4389
|
+
index.hunks = [];
|
|
4390
|
+
while (i < diffstr.length) {
|
|
4391
|
+
const line = diffstr[i];
|
|
4392
|
+
if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(line)) {
|
|
4393
|
+
break;
|
|
4394
|
+
} else if (/^@@/.test(line)) {
|
|
4395
|
+
index.hunks.push(parseHunk());
|
|
4396
|
+
} else if (line) {
|
|
4397
|
+
throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(line));
|
|
4398
|
+
} else {
|
|
4399
|
+
i++;
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
function parseFileHeader(index) {
|
|
4404
|
+
const fileHeader = /^(---|\+\+\+)\s+(.*)\r?$/.exec(diffstr[i]);
|
|
4405
|
+
if (fileHeader) {
|
|
4406
|
+
const data = fileHeader[2].split("\t", 2), header = (data[1] || "").trim();
|
|
4407
|
+
let fileName = data[0].replace(/\\\\/g, "\\");
|
|
4408
|
+
if (/^".*"$/.test(fileName)) {
|
|
4409
|
+
fileName = fileName.substr(1, fileName.length - 2);
|
|
4410
|
+
}
|
|
4411
|
+
if (fileHeader[1] === "---") {
|
|
4412
|
+
index.oldFileName = fileName;
|
|
4413
|
+
index.oldHeader = header;
|
|
4414
|
+
} else {
|
|
4415
|
+
index.newFileName = fileName;
|
|
4416
|
+
index.newHeader = header;
|
|
4417
|
+
}
|
|
4418
|
+
i++;
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
function parseHunk() {
|
|
4422
|
+
var _a;
|
|
4423
|
+
const chunkHeaderIndex = i, chunkHeaderLine = diffstr[i++], chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
|
4424
|
+
const hunk = {
|
|
4425
|
+
oldStart: +chunkHeader[1],
|
|
4426
|
+
oldLines: typeof chunkHeader[2] === "undefined" ? 1 : +chunkHeader[2],
|
|
4427
|
+
newStart: +chunkHeader[3],
|
|
4428
|
+
newLines: typeof chunkHeader[4] === "undefined" ? 1 : +chunkHeader[4],
|
|
4429
|
+
lines: []
|
|
4430
|
+
};
|
|
4431
|
+
if (hunk.oldLines === 0) {
|
|
4432
|
+
hunk.oldStart += 1;
|
|
4433
|
+
}
|
|
4434
|
+
if (hunk.newLines === 0) {
|
|
4435
|
+
hunk.newStart += 1;
|
|
4436
|
+
}
|
|
4437
|
+
let addCount = 0, removeCount = 0;
|
|
4438
|
+
for (;i < diffstr.length && (removeCount < hunk.oldLines || addCount < hunk.newLines || ((_a = diffstr[i]) === null || _a === undefined ? undefined : _a.startsWith("\\"))); i++) {
|
|
4439
|
+
const operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? " " : diffstr[i][0];
|
|
4440
|
+
if (operation === "+" || operation === "-" || operation === " " || operation === "\\") {
|
|
4441
|
+
hunk.lines.push(diffstr[i]);
|
|
4442
|
+
if (operation === "+") {
|
|
4443
|
+
addCount++;
|
|
4444
|
+
} else if (operation === "-") {
|
|
4445
|
+
removeCount++;
|
|
4446
|
+
} else if (operation === " ") {
|
|
4447
|
+
addCount++;
|
|
4448
|
+
removeCount++;
|
|
4449
|
+
}
|
|
4450
|
+
} else {
|
|
4451
|
+
throw new Error(`Hunk at line ${chunkHeaderIndex + 1} contained invalid line ${diffstr[i]}`);
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4454
|
+
if (!addCount && hunk.newLines === 1) {
|
|
4455
|
+
hunk.newLines = 0;
|
|
4456
|
+
}
|
|
4457
|
+
if (!removeCount && hunk.oldLines === 1) {
|
|
4458
|
+
hunk.oldLines = 0;
|
|
4459
|
+
}
|
|
4460
|
+
if (addCount !== hunk.newLines) {
|
|
4461
|
+
throw new Error("Added line count did not match for hunk at line " + (chunkHeaderIndex + 1));
|
|
4462
|
+
}
|
|
4463
|
+
if (removeCount !== hunk.oldLines) {
|
|
4464
|
+
throw new Error("Removed line count did not match for hunk at line " + (chunkHeaderIndex + 1));
|
|
4465
|
+
}
|
|
4466
|
+
return hunk;
|
|
4467
|
+
}
|
|
4468
|
+
while (i < diffstr.length) {
|
|
4469
|
+
parseIndex();
|
|
4470
|
+
}
|
|
4471
|
+
return list;
|
|
4472
|
+
}
|
|
3759
4473
|
|
|
3760
4474
|
// src/renderables/Text.ts
|
|
3761
4475
|
class TextRenderable extends TextBufferRenderable {
|
|
@@ -3859,6 +4573,7 @@ class DiffRenderable extends Renderable {
|
|
|
3859
4573
|
_view;
|
|
3860
4574
|
_parsedDiff = null;
|
|
3861
4575
|
_parseError = null;
|
|
4576
|
+
_fg;
|
|
3862
4577
|
_filetype;
|
|
3863
4578
|
_syntaxStyle;
|
|
3864
4579
|
_wrapMode;
|
|
@@ -3896,6 +4611,7 @@ class DiffRenderable extends Renderable {
|
|
|
3896
4611
|
});
|
|
3897
4612
|
this._diff = options.diff ?? "";
|
|
3898
4613
|
this._view = options.view ?? "unified";
|
|
4614
|
+
this._fg = options.fg ? parseColor(options.fg) : undefined;
|
|
3899
4615
|
this._filetype = options.filetype;
|
|
3900
4616
|
this._syntaxStyle = options.syntaxStyle;
|
|
3901
4617
|
this._wrapMode = options.wrapMode;
|
|
@@ -4056,6 +4772,7 @@ class DiffRenderable extends Renderable {
|
|
|
4056
4772
|
syntaxStyle: this._syntaxStyle ?? SyntaxStyle.create(),
|
|
4057
4773
|
width: "100%",
|
|
4058
4774
|
height: "100%",
|
|
4775
|
+
...this._fg !== undefined && { fg: this._fg },
|
|
4059
4776
|
...drawUnstyledText !== undefined && { drawUnstyledText },
|
|
4060
4777
|
...this._selectionBg !== undefined && { selectionBg: this._selectionBg },
|
|
4061
4778
|
...this._selectionFg !== undefined && { selectionFg: this._selectionFg },
|
|
@@ -4087,6 +4804,9 @@ class DiffRenderable extends Renderable {
|
|
|
4087
4804
|
if (this._selectionFg !== undefined) {
|
|
4088
4805
|
existingRenderable.selectionFg = this._selectionFg;
|
|
4089
4806
|
}
|
|
4807
|
+
if (this._fg !== undefined) {
|
|
4808
|
+
existingRenderable.fg = this._fg;
|
|
4809
|
+
}
|
|
4090
4810
|
return existingRenderable;
|
|
4091
4811
|
}
|
|
4092
4812
|
}
|
|
@@ -4698,8 +5418,78 @@ class DiffRenderable extends Renderable {
|
|
|
4698
5418
|
this.rebuildView();
|
|
4699
5419
|
}
|
|
4700
5420
|
}
|
|
5421
|
+
get fg() {
|
|
5422
|
+
return this._fg;
|
|
5423
|
+
}
|
|
5424
|
+
set fg(value) {
|
|
5425
|
+
const parsed = value ? parseColor(value) : undefined;
|
|
5426
|
+
if (this._fg !== parsed) {
|
|
5427
|
+
this._fg = parsed;
|
|
5428
|
+
if (this.leftCodeRenderable) {
|
|
5429
|
+
this.leftCodeRenderable.fg = parsed;
|
|
5430
|
+
}
|
|
5431
|
+
if (this.rightCodeRenderable) {
|
|
5432
|
+
this.rightCodeRenderable.fg = parsed;
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
}
|
|
5437
|
+
// src/lib/keymapping.ts
|
|
5438
|
+
var defaultKeyAliases = {
|
|
5439
|
+
enter: "return",
|
|
5440
|
+
esc: "escape"
|
|
5441
|
+
};
|
|
5442
|
+
function mergeKeyAliases(defaults, custom) {
|
|
5443
|
+
return { ...defaults, ...custom };
|
|
5444
|
+
}
|
|
5445
|
+
function mergeKeyBindings(defaults, custom) {
|
|
5446
|
+
const map = new Map;
|
|
5447
|
+
for (const binding of defaults) {
|
|
5448
|
+
const key = getKeyBindingKey(binding);
|
|
5449
|
+
map.set(key, binding);
|
|
5450
|
+
}
|
|
5451
|
+
for (const binding of custom) {
|
|
5452
|
+
const key = getKeyBindingKey(binding);
|
|
5453
|
+
map.set(key, binding);
|
|
5454
|
+
}
|
|
5455
|
+
return Array.from(map.values());
|
|
5456
|
+
}
|
|
5457
|
+
function getKeyBindingKey(binding) {
|
|
5458
|
+
return `${binding.name}:${binding.ctrl ? 1 : 0}:${binding.shift ? 1 : 0}:${binding.meta ? 1 : 0}:${binding.super ? 1 : 0}`;
|
|
4701
5459
|
}
|
|
5460
|
+
function buildKeyBindingsMap(bindings, aliasMap) {
|
|
5461
|
+
const map = new Map;
|
|
5462
|
+
const aliases = aliasMap || {};
|
|
5463
|
+
for (const binding of bindings) {
|
|
5464
|
+
const key = getKeyBindingKey(binding);
|
|
5465
|
+
map.set(key, binding.action);
|
|
5466
|
+
}
|
|
5467
|
+
for (const binding of bindings) {
|
|
5468
|
+
const normalizedName = aliases[binding.name] || binding.name;
|
|
5469
|
+
if (normalizedName !== binding.name) {
|
|
5470
|
+
const aliasedKey = getKeyBindingKey({ ...binding, name: normalizedName });
|
|
5471
|
+
map.set(aliasedKey, binding.action);
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
return map;
|
|
5475
|
+
}
|
|
5476
|
+
|
|
4702
5477
|
// src/renderables/Input.ts
|
|
5478
|
+
var defaultInputKeybindings = [
|
|
5479
|
+
{ name: "left", action: "move-left" },
|
|
5480
|
+
{ name: "right", action: "move-right" },
|
|
5481
|
+
{ name: "home", action: "move-home" },
|
|
5482
|
+
{ name: "end", action: "move-end" },
|
|
5483
|
+
{ name: "backspace", action: "delete-backward" },
|
|
5484
|
+
{ name: "delete", action: "delete-forward" },
|
|
5485
|
+
{ name: "return", action: "submit" },
|
|
5486
|
+
{ name: "linefeed", action: "submit" },
|
|
5487
|
+
{ name: "a", ctrl: true, action: "move-home" },
|
|
5488
|
+
{ name: "e", ctrl: true, action: "move-end" },
|
|
5489
|
+
{ name: "f", ctrl: true, action: "move-right" },
|
|
5490
|
+
{ name: "b", ctrl: true, action: "move-left" },
|
|
5491
|
+
{ name: "d", ctrl: true, action: "delete-forward" }
|
|
5492
|
+
];
|
|
4703
5493
|
var InputRenderableEvents;
|
|
4704
5494
|
((InputRenderableEvents2) => {
|
|
4705
5495
|
InputRenderableEvents2["INPUT"] = "input";
|
|
@@ -4721,6 +5511,9 @@ class InputRenderable extends Renderable {
|
|
|
4721
5511
|
_cursorStyle;
|
|
4722
5512
|
_maxLength;
|
|
4723
5513
|
_lastCommittedValue = "";
|
|
5514
|
+
_keyBindingsMap;
|
|
5515
|
+
_keyAliasMap;
|
|
5516
|
+
_keyBindings;
|
|
4724
5517
|
_defaultOptions = {
|
|
4725
5518
|
backgroundColor: "transparent",
|
|
4726
5519
|
textColor: "#FFFFFF",
|
|
@@ -4750,6 +5543,10 @@ class InputRenderable extends Renderable {
|
|
|
4750
5543
|
this._placeholderColor = parseColor(options.placeholderColor || this._defaultOptions.placeholderColor);
|
|
4751
5544
|
this._cursorColor = parseColor(options.cursorColor || this._defaultOptions.cursorColor);
|
|
4752
5545
|
this._cursorStyle = options.cursorStyle || this._defaultOptions.cursorStyle;
|
|
5546
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
5547
|
+
this._keyBindings = options.keyBindings || [];
|
|
5548
|
+
const mergedBindings = mergeKeyBindings(defaultInputKeybindings, this._keyBindings);
|
|
5549
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
4753
5550
|
}
|
|
4754
5551
|
updateCursorPosition() {
|
|
4755
5552
|
if (!this._focused)
|
|
@@ -4880,39 +5677,52 @@ class InputRenderable extends Renderable {
|
|
|
4880
5677
|
handleKeyPress(key) {
|
|
4881
5678
|
const keyName = typeof key === "string" ? key : key.name;
|
|
4882
5679
|
const keySequence = typeof key === "string" ? key : key.sequence;
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
return true;
|
|
4902
|
-
case "return":
|
|
4903
|
-
case "linefeed":
|
|
4904
|
-
if (this._value !== this._lastCommittedValue) {
|
|
4905
|
-
this._lastCommittedValue = this._value;
|
|
4906
|
-
this.emit("change" /* CHANGE */, this._value);
|
|
4907
|
-
}
|
|
4908
|
-
this.emit("enter" /* ENTER */, this._value);
|
|
4909
|
-
return true;
|
|
4910
|
-
default:
|
|
4911
|
-
if (keySequence && keySequence.length === 1 && keySequence.charCodeAt(0) >= 32 && keySequence.charCodeAt(0) <= 126) {
|
|
4912
|
-
this.insertText(keySequence);
|
|
5680
|
+
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
5681
|
+
const keyShift = typeof key === "string" ? false : key.shift;
|
|
5682
|
+
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
5683
|
+
const keySuper = typeof key === "string" ? false : key.super;
|
|
5684
|
+
const keyHyper = typeof key === "string" ? false : key.hyper;
|
|
5685
|
+
const bindingKey = getKeyBindingKey({
|
|
5686
|
+
name: keyName,
|
|
5687
|
+
ctrl: keyCtrl,
|
|
5688
|
+
shift: keyShift,
|
|
5689
|
+
meta: keyMeta,
|
|
5690
|
+
super: keySuper,
|
|
5691
|
+
action: "move-left"
|
|
5692
|
+
});
|
|
5693
|
+
const action = this._keyBindingsMap.get(bindingKey);
|
|
5694
|
+
if (action) {
|
|
5695
|
+
switch (action) {
|
|
5696
|
+
case "move-left":
|
|
5697
|
+
this.cursorPosition = this._cursorPosition - 1;
|
|
4913
5698
|
return true;
|
|
4914
|
-
|
|
4915
|
-
|
|
5699
|
+
case "move-right":
|
|
5700
|
+
this.cursorPosition = this._cursorPosition + 1;
|
|
5701
|
+
return true;
|
|
5702
|
+
case "move-home":
|
|
5703
|
+
this.cursorPosition = 0;
|
|
5704
|
+
return true;
|
|
5705
|
+
case "move-end":
|
|
5706
|
+
this.cursorPosition = this._value.length;
|
|
5707
|
+
return true;
|
|
5708
|
+
case "delete-backward":
|
|
5709
|
+
this.deleteCharacter("backward");
|
|
5710
|
+
return true;
|
|
5711
|
+
case "delete-forward":
|
|
5712
|
+
this.deleteCharacter("forward");
|
|
5713
|
+
return true;
|
|
5714
|
+
case "submit":
|
|
5715
|
+
if (this._value !== this._lastCommittedValue) {
|
|
5716
|
+
this._lastCommittedValue = this._value;
|
|
5717
|
+
this.emit("change" /* CHANGE */, this._value);
|
|
5718
|
+
}
|
|
5719
|
+
this.emit("enter" /* ENTER */, this._value);
|
|
5720
|
+
return true;
|
|
5721
|
+
}
|
|
5722
|
+
}
|
|
5723
|
+
if (keySequence && keySequence.length === 1 && keySequence.charCodeAt(0) >= 32 && keySequence.charCodeAt(0) <= 126 && !keyCtrl && !keyMeta && !keySuper && !keyHyper) {
|
|
5724
|
+
this.insertText(keySequence);
|
|
5725
|
+
return true;
|
|
4916
5726
|
}
|
|
4917
5727
|
return false;
|
|
4918
5728
|
}
|
|
@@ -4992,6 +5802,16 @@ class InputRenderable extends Renderable {
|
|
|
4992
5802
|
this._ctx.setCursorPosition(0, 0, false);
|
|
4993
5803
|
}
|
|
4994
5804
|
}
|
|
5805
|
+
set keyBindings(bindings) {
|
|
5806
|
+
this._keyBindings = bindings;
|
|
5807
|
+
const mergedBindings = mergeKeyBindings(defaultInputKeybindings, bindings);
|
|
5808
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
5809
|
+
}
|
|
5810
|
+
set keyAliasMap(aliases) {
|
|
5811
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
|
|
5812
|
+
const mergedBindings = mergeKeyBindings(defaultInputKeybindings, this._keyBindings);
|
|
5813
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
5814
|
+
}
|
|
4995
5815
|
}
|
|
4996
5816
|
// src/renderables/Slider.ts
|
|
4997
5817
|
var defaultThumbBackgroundColor = RGBA.fromHex("#9a9ea3");
|
|
@@ -6144,6 +6964,16 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
6144
6964
|
}
|
|
6145
6965
|
}
|
|
6146
6966
|
// src/renderables/Select.ts
|
|
6967
|
+
var defaultSelectKeybindings = [
|
|
6968
|
+
{ name: "up", action: "move-up" },
|
|
6969
|
+
{ name: "k", action: "move-up" },
|
|
6970
|
+
{ name: "down", action: "move-down" },
|
|
6971
|
+
{ name: "j", action: "move-down" },
|
|
6972
|
+
{ name: "up", shift: true, action: "move-up-fast" },
|
|
6973
|
+
{ name: "down", shift: true, action: "move-down-fast" },
|
|
6974
|
+
{ name: "return", action: "select-current" },
|
|
6975
|
+
{ name: "linefeed", action: "select-current" }
|
|
6976
|
+
];
|
|
6147
6977
|
var SelectRenderableEvents;
|
|
6148
6978
|
((SelectRenderableEvents2) => {
|
|
6149
6979
|
SelectRenderableEvents2["SELECTION_CHANGED"] = "selectionChanged";
|
|
@@ -6172,6 +7002,9 @@ class SelectRenderable extends Renderable {
|
|
|
6172
7002
|
linesPerItem;
|
|
6173
7003
|
fontHeight;
|
|
6174
7004
|
_fastScrollStep;
|
|
7005
|
+
_keyBindingsMap;
|
|
7006
|
+
_keyAliasMap;
|
|
7007
|
+
_keyBindings;
|
|
6175
7008
|
_defaultOptions = {
|
|
6176
7009
|
backgroundColor: "transparent",
|
|
6177
7010
|
textColor: "#FFFFFF",
|
|
@@ -6211,6 +7044,10 @@ class SelectRenderable extends Renderable {
|
|
|
6211
7044
|
this._descriptionColor = parseColor(options.descriptionColor || this._defaultOptions.descriptionColor);
|
|
6212
7045
|
this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor || this._defaultOptions.selectedDescriptionColor);
|
|
6213
7046
|
this._fastScrollStep = options.fastScrollStep || this._defaultOptions.fastScrollStep;
|
|
7047
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
7048
|
+
this._keyBindings = options.keyBindings || [];
|
|
7049
|
+
const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, this._keyBindings);
|
|
7050
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
6214
7051
|
this.requestRender();
|
|
6215
7052
|
}
|
|
6216
7053
|
renderSelf(buffer, deltaTime) {
|
|
@@ -6351,20 +7188,37 @@ class SelectRenderable extends Renderable {
|
|
|
6351
7188
|
}
|
|
6352
7189
|
handleKeyPress(key) {
|
|
6353
7190
|
const keyName = typeof key === "string" ? key : key.name;
|
|
6354
|
-
const
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
7191
|
+
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
7192
|
+
const keyShift = typeof key === "string" ? false : key.shift;
|
|
7193
|
+
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
7194
|
+
const keySuper = typeof key === "string" ? false : key.super;
|
|
7195
|
+
const bindingKey = getKeyBindingKey({
|
|
7196
|
+
name: keyName,
|
|
7197
|
+
ctrl: keyCtrl,
|
|
7198
|
+
shift: keyShift,
|
|
7199
|
+
meta: keyMeta,
|
|
7200
|
+
super: keySuper,
|
|
7201
|
+
action: "move-up"
|
|
7202
|
+
});
|
|
7203
|
+
const action = this._keyBindingsMap.get(bindingKey);
|
|
7204
|
+
if (action) {
|
|
7205
|
+
switch (action) {
|
|
7206
|
+
case "move-up":
|
|
7207
|
+
this.moveUp(1);
|
|
7208
|
+
return true;
|
|
7209
|
+
case "move-down":
|
|
7210
|
+
this.moveDown(1);
|
|
7211
|
+
return true;
|
|
7212
|
+
case "move-up-fast":
|
|
7213
|
+
this.moveUp(this._fastScrollStep);
|
|
7214
|
+
return true;
|
|
7215
|
+
case "move-down-fast":
|
|
7216
|
+
this.moveDown(this._fastScrollStep);
|
|
7217
|
+
return true;
|
|
7218
|
+
case "select-current":
|
|
7219
|
+
this.selectCurrent();
|
|
7220
|
+
return true;
|
|
7221
|
+
}
|
|
6368
7222
|
}
|
|
6369
7223
|
return false;
|
|
6370
7224
|
}
|
|
@@ -6470,6 +7324,16 @@ class SelectRenderable extends Renderable {
|
|
|
6470
7324
|
set fastScrollStep(step) {
|
|
6471
7325
|
this._fastScrollStep = step;
|
|
6472
7326
|
}
|
|
7327
|
+
set keyBindings(bindings) {
|
|
7328
|
+
this._keyBindings = bindings;
|
|
7329
|
+
const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, bindings);
|
|
7330
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7331
|
+
}
|
|
7332
|
+
set keyAliasMap(aliases) {
|
|
7333
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
|
|
7334
|
+
const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, this._keyBindings);
|
|
7335
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7336
|
+
}
|
|
6473
7337
|
set selectedIndex(value) {
|
|
6474
7338
|
const newIndex = value ?? this._defaultOptions.selectedIndex;
|
|
6475
7339
|
const clampedIndex = this._options.length > 0 ? Math.min(Math.max(0, newIndex), this._options.length - 1) : 0;
|
|
@@ -6481,6 +7345,14 @@ class SelectRenderable extends Renderable {
|
|
|
6481
7345
|
}
|
|
6482
7346
|
}
|
|
6483
7347
|
// src/renderables/TabSelect.ts
|
|
7348
|
+
var defaultTabSelectKeybindings = [
|
|
7349
|
+
{ name: "left", action: "move-left" },
|
|
7350
|
+
{ name: "[", action: "move-left" },
|
|
7351
|
+
{ name: "right", action: "move-right" },
|
|
7352
|
+
{ name: "]", action: "move-right" },
|
|
7353
|
+
{ name: "return", action: "select-current" },
|
|
7354
|
+
{ name: "linefeed", action: "select-current" }
|
|
7355
|
+
];
|
|
6484
7356
|
var TabSelectRenderableEvents;
|
|
6485
7357
|
((TabSelectRenderableEvents2) => {
|
|
6486
7358
|
TabSelectRenderableEvents2["SELECTION_CHANGED"] = "selectionChanged";
|
|
@@ -6515,6 +7387,9 @@ class TabSelectRenderable extends Renderable {
|
|
|
6515
7387
|
_showDescription;
|
|
6516
7388
|
_showUnderline;
|
|
6517
7389
|
_wrapSelection;
|
|
7390
|
+
_keyBindingsMap;
|
|
7391
|
+
_keyAliasMap;
|
|
7392
|
+
_keyBindings;
|
|
6518
7393
|
constructor(ctx, options) {
|
|
6519
7394
|
const calculatedHeight = calculateDynamicHeight(options.showUnderline ?? true, options.showDescription ?? true);
|
|
6520
7395
|
super(ctx, { ...options, height: calculatedHeight, buffered: true });
|
|
@@ -6532,6 +7407,10 @@ class TabSelectRenderable extends Renderable {
|
|
|
6532
7407
|
this._selectedBackgroundColor = parseColor(options.selectedBackgroundColor || "#334455");
|
|
6533
7408
|
this._selectedTextColor = parseColor(options.selectedTextColor || "#FFFF00");
|
|
6534
7409
|
this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor || "#CCCCCC");
|
|
7410
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
7411
|
+
this._keyBindings = options.keyBindings || [];
|
|
7412
|
+
const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
|
|
7413
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
6535
7414
|
}
|
|
6536
7415
|
calculateDynamicHeight() {
|
|
6537
7416
|
return calculateDynamicHeight(this._showUnderline, this._showDescription);
|
|
@@ -6682,19 +7561,31 @@ class TabSelectRenderable extends Renderable {
|
|
|
6682
7561
|
}
|
|
6683
7562
|
handleKeyPress(key) {
|
|
6684
7563
|
const keyName = typeof key === "string" ? key : key.name;
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
7564
|
+
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
7565
|
+
const keyShift = typeof key === "string" ? false : key.shift;
|
|
7566
|
+
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
7567
|
+
const keySuper = typeof key === "string" ? false : key.super;
|
|
7568
|
+
const bindingKey = getKeyBindingKey({
|
|
7569
|
+
name: keyName,
|
|
7570
|
+
ctrl: keyCtrl,
|
|
7571
|
+
shift: keyShift,
|
|
7572
|
+
meta: keyMeta,
|
|
7573
|
+
super: keySuper,
|
|
7574
|
+
action: "move-left"
|
|
7575
|
+
});
|
|
7576
|
+
const action = this._keyBindingsMap.get(bindingKey);
|
|
7577
|
+
if (action) {
|
|
7578
|
+
switch (action) {
|
|
7579
|
+
case "move-left":
|
|
7580
|
+
this.moveLeft();
|
|
7581
|
+
return true;
|
|
7582
|
+
case "move-right":
|
|
7583
|
+
this.moveRight();
|
|
7584
|
+
return true;
|
|
7585
|
+
case "select-current":
|
|
7586
|
+
this.selectCurrent();
|
|
7587
|
+
return true;
|
|
7588
|
+
}
|
|
6698
7589
|
}
|
|
6699
7590
|
return false;
|
|
6700
7591
|
}
|
|
@@ -6783,10 +7674,18 @@ class TabSelectRenderable extends Renderable {
|
|
|
6783
7674
|
this.updateScrollOffset();
|
|
6784
7675
|
this.requestRender();
|
|
6785
7676
|
}
|
|
7677
|
+
set keyBindings(bindings) {
|
|
7678
|
+
this._keyBindings = bindings;
|
|
7679
|
+
const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, bindings);
|
|
7680
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7681
|
+
}
|
|
7682
|
+
set keyAliasMap(aliases) {
|
|
7683
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
|
|
7684
|
+
const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
|
|
7685
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7686
|
+
}
|
|
6786
7687
|
}
|
|
6787
7688
|
// src/renderables/EditBufferRenderable.ts
|
|
6788
|
-
import { MeasureMode as MeasureMode2 } from "bun-yoga";
|
|
6789
|
-
|
|
6790
7689
|
class EditBufferRenderable extends Renderable {
|
|
6791
7690
|
_focusable = true;
|
|
6792
7691
|
selectable = true;
|
|
@@ -7086,7 +7985,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
7086
7985
|
setupMeasureFunc() {
|
|
7087
7986
|
const measureFunc = (width, widthMode, height, heightMode) => {
|
|
7088
7987
|
let effectiveWidth;
|
|
7089
|
-
if (widthMode ===
|
|
7988
|
+
if (widthMode === MeasureMode.Undefined || isNaN(width)) {
|
|
7090
7989
|
effectiveWidth = 0;
|
|
7091
7990
|
} else {
|
|
7092
7991
|
effectiveWidth = width;
|
|
@@ -7095,7 +7994,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
7095
7994
|
const measureResult = this.editorView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
|
|
7096
7995
|
const measuredWidth = measureResult ? Math.max(1, measureResult.maxWidth) : 1;
|
|
7097
7996
|
const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
|
|
7098
|
-
if (widthMode ===
|
|
7997
|
+
if (widthMode === MeasureMode.AtMost && this._positionType !== "absolute") {
|
|
7099
7998
|
return {
|
|
7100
7999
|
width: Math.min(effectiveWidth, measuredWidth),
|
|
7101
8000
|
height: Math.min(effectiveHeight, measuredHeight)
|
|
@@ -7278,31 +8177,6 @@ class EditBufferRenderable extends Renderable {
|
|
|
7278
8177
|
}
|
|
7279
8178
|
}
|
|
7280
8179
|
|
|
7281
|
-
// src/lib/keymapping.ts
|
|
7282
|
-
function mergeKeyBindings(defaults, custom) {
|
|
7283
|
-
const map = new Map;
|
|
7284
|
-
for (const binding of defaults) {
|
|
7285
|
-
const key = getKeyBindingKey(binding);
|
|
7286
|
-
map.set(key, binding);
|
|
7287
|
-
}
|
|
7288
|
-
for (const binding of custom) {
|
|
7289
|
-
const key = getKeyBindingKey(binding);
|
|
7290
|
-
map.set(key, binding);
|
|
7291
|
-
}
|
|
7292
|
-
return Array.from(map.values());
|
|
7293
|
-
}
|
|
7294
|
-
function getKeyBindingKey(binding) {
|
|
7295
|
-
return `${binding.name}:${binding.ctrl ? 1 : 0}:${binding.shift ? 1 : 0}:${binding.meta ? 1 : 0}:${binding.super ? 1 : 0}`;
|
|
7296
|
-
}
|
|
7297
|
-
function buildKeyBindingsMap(bindings) {
|
|
7298
|
-
const map = new Map;
|
|
7299
|
-
for (const binding of bindings) {
|
|
7300
|
-
const key = getKeyBindingKey(binding);
|
|
7301
|
-
map.set(key, binding.action);
|
|
7302
|
-
}
|
|
7303
|
-
return map;
|
|
7304
|
-
}
|
|
7305
|
-
|
|
7306
8180
|
// src/renderables/Textarea.ts
|
|
7307
8181
|
var defaultTextareaKeybindings = [
|
|
7308
8182
|
{ name: "left", action: "move-left" },
|
|
@@ -7355,6 +8229,8 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
7355
8229
|
_focusedBackgroundColor;
|
|
7356
8230
|
_focusedTextColor;
|
|
7357
8231
|
_keyBindingsMap;
|
|
8232
|
+
_keyAliasMap;
|
|
8233
|
+
_keyBindings;
|
|
7358
8234
|
_actionHandlers;
|
|
7359
8235
|
_initialValueSet = false;
|
|
7360
8236
|
_submitListener = undefined;
|
|
@@ -7378,8 +8254,10 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
7378
8254
|
this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || options.backgroundColor || defaults.focusedBackgroundColor);
|
|
7379
8255
|
this._focusedTextColor = parseColor(options.focusedTextColor || options.textColor || defaults.focusedTextColor);
|
|
7380
8256
|
this._placeholder = options.placeholder ?? defaults.placeholder;
|
|
7381
|
-
|
|
7382
|
-
this.
|
|
8257
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
8258
|
+
this._keyBindings = options.keyBindings || [];
|
|
8259
|
+
const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, this._keyBindings);
|
|
8260
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7383
8261
|
this._actionHandlers = this.buildActionHandlers();
|
|
7384
8262
|
this._submitListener = options.onSubmit;
|
|
7385
8263
|
if (options.initialValue) {
|
|
@@ -7447,6 +8325,7 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
7447
8325
|
const keyShift = typeof key === "string" ? false : key.shift;
|
|
7448
8326
|
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
7449
8327
|
const keySuper = typeof key === "string" ? false : key.super;
|
|
8328
|
+
const keyHyper = typeof key === "string" ? false : key.hyper;
|
|
7450
8329
|
const bindingKey = getKeyBindingKey({
|
|
7451
8330
|
name: keyName,
|
|
7452
8331
|
ctrl: keyCtrl,
|
|
@@ -7462,7 +8341,7 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
7462
8341
|
return handler();
|
|
7463
8342
|
}
|
|
7464
8343
|
}
|
|
7465
|
-
if (keySequence && !keyCtrl && !keyMeta) {
|
|
8344
|
+
if (keySequence && !keyCtrl && !keyMeta && !keySuper && !keyHyper) {
|
|
7466
8345
|
const firstCharCode = keySequence.charCodeAt(0);
|
|
7467
8346
|
if (firstCharCode < 32) {
|
|
7468
8347
|
return false;
|
|
@@ -7750,15 +8629,19 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
7750
8629
|
return this._submitListener;
|
|
7751
8630
|
}
|
|
7752
8631
|
set keyBindings(bindings) {
|
|
8632
|
+
this._keyBindings = bindings;
|
|
7753
8633
|
const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, bindings);
|
|
7754
|
-
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings);
|
|
8634
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
8635
|
+
}
|
|
8636
|
+
set keyAliasMap(aliases) {
|
|
8637
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
|
|
8638
|
+
const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, this._keyBindings);
|
|
8639
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7755
8640
|
}
|
|
7756
8641
|
get extmarks() {
|
|
7757
8642
|
return this.editorView.extmarks;
|
|
7758
8643
|
}
|
|
7759
8644
|
}
|
|
7760
|
-
// src/index.ts
|
|
7761
|
-
import * as Yoga from "bun-yoga";
|
|
7762
8645
|
export {
|
|
7763
8646
|
yellow,
|
|
7764
8647
|
wrapWithDelegates,
|
|
@@ -7868,7 +8751,7 @@ export {
|
|
|
7868
8751
|
applyChromaticAberration,
|
|
7869
8752
|
applyAsciiArt,
|
|
7870
8753
|
addDefaultParsers,
|
|
7871
|
-
Yoga,
|
|
8754
|
+
exports_src as Yoga,
|
|
7872
8755
|
VignetteEffect,
|
|
7873
8756
|
VRenderable,
|
|
7874
8757
|
TreeSitterClient,
|
|
@@ -7946,5 +8829,5 @@ export {
|
|
|
7946
8829
|
ASCIIFont
|
|
7947
8830
|
};
|
|
7948
8831
|
|
|
7949
|
-
//# debugId=
|
|
8832
|
+
//# debugId=F8C236171D38686464756E2164756E21
|
|
7950
8833
|
//# sourceMappingURL=index.js.map
|