@opentui/core 0.0.0-20251205-41c885f6 → 0.0.0-20251209-015faccd

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/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,
@@ -58,6 +61,7 @@ import {
58
61
  brightRed,
59
62
  brightWhite,
60
63
  brightYellow,
64
+ buildKittyKeyboardFlags,
61
65
  capture,
62
66
  clearEnvCache,
63
67
  convertGlobalToLocalSelection,
@@ -71,6 +75,7 @@ import {
71
75
  dim,
72
76
  env,
73
77
  envRegistry,
78
+ exports_src,
74
79
  extToFiletype,
75
80
  fg,
76
81
  fonts,
@@ -133,7 +138,7 @@ import {
133
138
  white,
134
139
  wrapWithDelegates,
135
140
  yellow
136
- } from "./index-x5bb5xvn.js";
141
+ } from "./index-4s3xr47p.js";
137
142
  // src/text-buffer-view.ts
138
143
  class TextBufferView {
139
144
  lib;
@@ -2197,7 +2202,6 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
2197
2202
  }
2198
2203
  }
2199
2204
  // src/renderables/Box.ts
2200
- import { Edge, Gutter } from "bun-yoga";
2201
2205
  function isGapType(value) {
2202
2206
  if (value === undefined) {
2203
2207
  return true;
@@ -2414,7 +2418,6 @@ class BoxRenderable extends Renderable {
2414
2418
  }
2415
2419
  }
2416
2420
  // src/renderables/TextBufferRenderable.ts
2417
- import { MeasureMode } from "bun-yoga";
2418
2421
  class TextBufferRenderable extends Renderable {
2419
2422
  selectable = true;
2420
2423
  _defaultFg;
@@ -3754,8 +3757,720 @@ class LineNumberRenderable extends Renderable {
3754
3757
  }
3755
3758
  }
3756
3759
 
3757
- // src/renderables/Diff.ts
3758
- import { parsePatch } from "diff";
3760
+ // ../../node_modules/diff/libesm/diff/base.js
3761
+ class Diff {
3762
+ diff(oldStr, newStr, options = {}) {
3763
+ let callback;
3764
+ if (typeof options === "function") {
3765
+ callback = options;
3766
+ options = {};
3767
+ } else if ("callback" in options) {
3768
+ callback = options.callback;
3769
+ }
3770
+ const oldString = this.castInput(oldStr, options);
3771
+ const newString = this.castInput(newStr, options);
3772
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
3773
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
3774
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
3775
+ }
3776
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
3777
+ var _a;
3778
+ const done = (value) => {
3779
+ value = this.postProcess(value, options);
3780
+ if (callback) {
3781
+ setTimeout(function() {
3782
+ callback(value);
3783
+ }, 0);
3784
+ return;
3785
+ } else {
3786
+ return value;
3787
+ }
3788
+ };
3789
+ const newLen = newTokens.length, oldLen = oldTokens.length;
3790
+ let editLength = 1;
3791
+ let maxEditLength = newLen + oldLen;
3792
+ if (options.maxEditLength != null) {
3793
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
3794
+ }
3795
+ const maxExecutionTime = (_a = options.timeout) !== null && _a !== undefined ? _a : Infinity;
3796
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
3797
+ const bestPath = [{ oldPos: -1, lastComponent: undefined }];
3798
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
3799
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
3800
+ return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
3801
+ }
3802
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
3803
+ const execEditLength = () => {
3804
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength);diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
3805
+ let basePath;
3806
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
3807
+ if (removePath) {
3808
+ bestPath[diagonalPath - 1] = undefined;
3809
+ }
3810
+ let canAdd = false;
3811
+ if (addPath) {
3812
+ const addPathNewPos = addPath.oldPos - diagonalPath;
3813
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
3814
+ }
3815
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
3816
+ if (!canAdd && !canRemove) {
3817
+ bestPath[diagonalPath] = undefined;
3818
+ continue;
3819
+ }
3820
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
3821
+ basePath = this.addToPath(addPath, true, false, 0, options);
3822
+ } else {
3823
+ basePath = this.addToPath(removePath, false, true, 1, options);
3824
+ }
3825
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
3826
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
3827
+ return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
3828
+ } else {
3829
+ bestPath[diagonalPath] = basePath;
3830
+ if (basePath.oldPos + 1 >= oldLen) {
3831
+ maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
3832
+ }
3833
+ if (newPos + 1 >= newLen) {
3834
+ minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
3835
+ }
3836
+ }
3837
+ }
3838
+ editLength++;
3839
+ };
3840
+ if (callback) {
3841
+ (function exec() {
3842
+ setTimeout(function() {
3843
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
3844
+ return callback(undefined);
3845
+ }
3846
+ if (!execEditLength()) {
3847
+ exec();
3848
+ }
3849
+ }, 0);
3850
+ })();
3851
+ } else {
3852
+ while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
3853
+ const ret = execEditLength();
3854
+ if (ret) {
3855
+ return ret;
3856
+ }
3857
+ }
3858
+ }
3859
+ }
3860
+ addToPath(path, added, removed, oldPosInc, options) {
3861
+ const last = path.lastComponent;
3862
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
3863
+ return {
3864
+ oldPos: path.oldPos + oldPosInc,
3865
+ lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
3866
+ };
3867
+ } else {
3868
+ return {
3869
+ oldPos: path.oldPos + oldPosInc,
3870
+ lastComponent: { count: 1, added, removed, previousComponent: last }
3871
+ };
3872
+ }
3873
+ }
3874
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
3875
+ const newLen = newTokens.length, oldLen = oldTokens.length;
3876
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
3877
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
3878
+ newPos++;
3879
+ oldPos++;
3880
+ commonCount++;
3881
+ if (options.oneChangePerToken) {
3882
+ basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
3883
+ }
3884
+ }
3885
+ if (commonCount && !options.oneChangePerToken) {
3886
+ basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
3887
+ }
3888
+ basePath.oldPos = oldPos;
3889
+ return newPos;
3890
+ }
3891
+ equals(left, right, options) {
3892
+ if (options.comparator) {
3893
+ return options.comparator(left, right);
3894
+ } else {
3895
+ return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
3896
+ }
3897
+ }
3898
+ removeEmpty(array) {
3899
+ const ret = [];
3900
+ for (let i = 0;i < array.length; i++) {
3901
+ if (array[i]) {
3902
+ ret.push(array[i]);
3903
+ }
3904
+ }
3905
+ return ret;
3906
+ }
3907
+ castInput(value, options) {
3908
+ return value;
3909
+ }
3910
+ tokenize(value, options) {
3911
+ return Array.from(value);
3912
+ }
3913
+ join(chars) {
3914
+ return chars.join("");
3915
+ }
3916
+ postProcess(changeObjects, options) {
3917
+ return changeObjects;
3918
+ }
3919
+ get useLongestToken() {
3920
+ return false;
3921
+ }
3922
+ buildValues(lastComponent, newTokens, oldTokens) {
3923
+ const components = [];
3924
+ let nextComponent;
3925
+ while (lastComponent) {
3926
+ components.push(lastComponent);
3927
+ nextComponent = lastComponent.previousComponent;
3928
+ delete lastComponent.previousComponent;
3929
+ lastComponent = nextComponent;
3930
+ }
3931
+ components.reverse();
3932
+ const componentLen = components.length;
3933
+ let componentPos = 0, newPos = 0, oldPos = 0;
3934
+ for (;componentPos < componentLen; componentPos++) {
3935
+ const component = components[componentPos];
3936
+ if (!component.removed) {
3937
+ if (!component.added && this.useLongestToken) {
3938
+ let value = newTokens.slice(newPos, newPos + component.count);
3939
+ value = value.map(function(value2, i) {
3940
+ const oldValue = oldTokens[oldPos + i];
3941
+ return oldValue.length > value2.length ? oldValue : value2;
3942
+ });
3943
+ component.value = this.join(value);
3944
+ } else {
3945
+ component.value = this.join(newTokens.slice(newPos, newPos + component.count));
3946
+ }
3947
+ newPos += component.count;
3948
+ if (!component.added) {
3949
+ oldPos += component.count;
3950
+ }
3951
+ } else {
3952
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
3953
+ oldPos += component.count;
3954
+ }
3955
+ }
3956
+ return components;
3957
+ }
3958
+ }
3959
+
3960
+ // ../../node_modules/diff/libesm/diff/character.js
3961
+ class CharacterDiff extends Diff {
3962
+ }
3963
+ var characterDiff = new CharacterDiff;
3964
+
3965
+ // ../../node_modules/diff/libesm/util/string.js
3966
+ function longestCommonPrefix(str1, str2) {
3967
+ let i;
3968
+ for (i = 0;i < str1.length && i < str2.length; i++) {
3969
+ if (str1[i] != str2[i]) {
3970
+ return str1.slice(0, i);
3971
+ }
3972
+ }
3973
+ return str1.slice(0, i);
3974
+ }
3975
+ function longestCommonSuffix(str1, str2) {
3976
+ let i;
3977
+ if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
3978
+ return "";
3979
+ }
3980
+ for (i = 0;i < str1.length && i < str2.length; i++) {
3981
+ if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
3982
+ return str1.slice(-i);
3983
+ }
3984
+ }
3985
+ return str1.slice(-i);
3986
+ }
3987
+ function replacePrefix(string, oldPrefix, newPrefix) {
3988
+ if (string.slice(0, oldPrefix.length) != oldPrefix) {
3989
+ throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
3990
+ }
3991
+ return newPrefix + string.slice(oldPrefix.length);
3992
+ }
3993
+ function replaceSuffix(string, oldSuffix, newSuffix) {
3994
+ if (!oldSuffix) {
3995
+ return string + newSuffix;
3996
+ }
3997
+ if (string.slice(-oldSuffix.length) != oldSuffix) {
3998
+ throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
3999
+ }
4000
+ return string.slice(0, -oldSuffix.length) + newSuffix;
4001
+ }
4002
+ function removePrefix(string, oldPrefix) {
4003
+ return replacePrefix(string, oldPrefix, "");
4004
+ }
4005
+ function removeSuffix(string, oldSuffix) {
4006
+ return replaceSuffix(string, oldSuffix, "");
4007
+ }
4008
+ function maximumOverlap(string1, string2) {
4009
+ return string2.slice(0, overlapCount(string1, string2));
4010
+ }
4011
+ function overlapCount(a, b) {
4012
+ let startA = 0;
4013
+ if (a.length > b.length) {
4014
+ startA = a.length - b.length;
4015
+ }
4016
+ let endB = b.length;
4017
+ if (a.length < b.length) {
4018
+ endB = a.length;
4019
+ }
4020
+ const map = Array(endB);
4021
+ let k = 0;
4022
+ map[0] = 0;
4023
+ for (let j = 1;j < endB; j++) {
4024
+ if (b[j] == b[k]) {
4025
+ map[j] = map[k];
4026
+ } else {
4027
+ map[j] = k;
4028
+ }
4029
+ while (k > 0 && b[j] != b[k]) {
4030
+ k = map[k];
4031
+ }
4032
+ if (b[j] == b[k]) {
4033
+ k++;
4034
+ }
4035
+ }
4036
+ k = 0;
4037
+ for (let i = startA;i < a.length; i++) {
4038
+ while (k > 0 && a[i] != b[k]) {
4039
+ k = map[k];
4040
+ }
4041
+ if (a[i] == b[k]) {
4042
+ k++;
4043
+ }
4044
+ }
4045
+ return k;
4046
+ }
4047
+ function trailingWs(string) {
4048
+ let i;
4049
+ for (i = string.length - 1;i >= 0; i--) {
4050
+ if (!string[i].match(/\s/)) {
4051
+ break;
4052
+ }
4053
+ }
4054
+ return string.substring(i + 1);
4055
+ }
4056
+ function leadingWs(string) {
4057
+ const match = string.match(/^\s*/);
4058
+ return match ? match[0] : "";
4059
+ }
4060
+
4061
+ // ../../node_modules/diff/libesm/diff/word.js
4062
+ 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}";
4063
+ var tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
4064
+
4065
+ class WordDiff extends Diff {
4066
+ equals(left, right, options) {
4067
+ if (options.ignoreCase) {
4068
+ left = left.toLowerCase();
4069
+ right = right.toLowerCase();
4070
+ }
4071
+ return left.trim() === right.trim();
4072
+ }
4073
+ tokenize(value, options = {}) {
4074
+ let parts;
4075
+ if (options.intlSegmenter) {
4076
+ const segmenter = options.intlSegmenter;
4077
+ if (segmenter.resolvedOptions().granularity != "word") {
4078
+ throw new Error('The segmenter passed must have a granularity of "word"');
4079
+ }
4080
+ parts = Array.from(segmenter.segment(value), (segment) => segment.segment);
4081
+ } else {
4082
+ parts = value.match(tokenizeIncludingWhitespace) || [];
4083
+ }
4084
+ const tokens = [];
4085
+ let prevPart = null;
4086
+ parts.forEach((part) => {
4087
+ if (/\s/.test(part)) {
4088
+ if (prevPart == null) {
4089
+ tokens.push(part);
4090
+ } else {
4091
+ tokens.push(tokens.pop() + part);
4092
+ }
4093
+ } else if (prevPart != null && /\s/.test(prevPart)) {
4094
+ if (tokens[tokens.length - 1] == prevPart) {
4095
+ tokens.push(tokens.pop() + part);
4096
+ } else {
4097
+ tokens.push(prevPart + part);
4098
+ }
4099
+ } else {
4100
+ tokens.push(part);
4101
+ }
4102
+ prevPart = part;
4103
+ });
4104
+ return tokens;
4105
+ }
4106
+ join(tokens) {
4107
+ return tokens.map((token, i) => {
4108
+ if (i == 0) {
4109
+ return token;
4110
+ } else {
4111
+ return token.replace(/^\s+/, "");
4112
+ }
4113
+ }).join("");
4114
+ }
4115
+ postProcess(changes, options) {
4116
+ if (!changes || options.oneChangePerToken) {
4117
+ return changes;
4118
+ }
4119
+ let lastKeep = null;
4120
+ let insertion = null;
4121
+ let deletion = null;
4122
+ changes.forEach((change) => {
4123
+ if (change.added) {
4124
+ insertion = change;
4125
+ } else if (change.removed) {
4126
+ deletion = change;
4127
+ } else {
4128
+ if (insertion || deletion) {
4129
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
4130
+ }
4131
+ lastKeep = change;
4132
+ insertion = null;
4133
+ deletion = null;
4134
+ }
4135
+ });
4136
+ if (insertion || deletion) {
4137
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
4138
+ }
4139
+ return changes;
4140
+ }
4141
+ }
4142
+ var wordDiff = new WordDiff;
4143
+ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
4144
+ if (deletion && insertion) {
4145
+ const oldWsPrefix = leadingWs(deletion.value);
4146
+ const oldWsSuffix = trailingWs(deletion.value);
4147
+ const newWsPrefix = leadingWs(insertion.value);
4148
+ const newWsSuffix = trailingWs(insertion.value);
4149
+ if (startKeep) {
4150
+ const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
4151
+ startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
4152
+ deletion.value = removePrefix(deletion.value, commonWsPrefix);
4153
+ insertion.value = removePrefix(insertion.value, commonWsPrefix);
4154
+ }
4155
+ if (endKeep) {
4156
+ const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
4157
+ endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
4158
+ deletion.value = removeSuffix(deletion.value, commonWsSuffix);
4159
+ insertion.value = removeSuffix(insertion.value, commonWsSuffix);
4160
+ }
4161
+ } else if (insertion) {
4162
+ if (startKeep) {
4163
+ const ws = leadingWs(insertion.value);
4164
+ insertion.value = insertion.value.substring(ws.length);
4165
+ }
4166
+ if (endKeep) {
4167
+ const ws = leadingWs(endKeep.value);
4168
+ endKeep.value = endKeep.value.substring(ws.length);
4169
+ }
4170
+ } else if (startKeep && endKeep) {
4171
+ const newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value);
4172
+ const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
4173
+ deletion.value = removePrefix(deletion.value, newWsStart);
4174
+ const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
4175
+ deletion.value = removeSuffix(deletion.value, newWsEnd);
4176
+ endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
4177
+ startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
4178
+ } else if (endKeep) {
4179
+ const endKeepWsPrefix = leadingWs(endKeep.value);
4180
+ const deletionWsSuffix = trailingWs(deletion.value);
4181
+ const overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
4182
+ deletion.value = removeSuffix(deletion.value, overlap);
4183
+ } else if (startKeep) {
4184
+ const startKeepWsSuffix = trailingWs(startKeep.value);
4185
+ const deletionWsPrefix = leadingWs(deletion.value);
4186
+ const overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
4187
+ deletion.value = removePrefix(deletion.value, overlap);
4188
+ }
4189
+ }
4190
+
4191
+ class WordsWithSpaceDiff extends Diff {
4192
+ tokenize(value) {
4193
+ const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
4194
+ return value.match(regex) || [];
4195
+ }
4196
+ }
4197
+ var wordsWithSpaceDiff = new WordsWithSpaceDiff;
4198
+
4199
+ // ../../node_modules/diff/libesm/diff/line.js
4200
+ class LineDiff extends Diff {
4201
+ constructor() {
4202
+ super(...arguments);
4203
+ this.tokenize = tokenize;
4204
+ }
4205
+ equals(left, right, options) {
4206
+ if (options.ignoreWhitespace) {
4207
+ if (!options.newlineIsToken || !left.includes(`
4208
+ `)) {
4209
+ left = left.trim();
4210
+ }
4211
+ if (!options.newlineIsToken || !right.includes(`
4212
+ `)) {
4213
+ right = right.trim();
4214
+ }
4215
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
4216
+ if (left.endsWith(`
4217
+ `)) {
4218
+ left = left.slice(0, -1);
4219
+ }
4220
+ if (right.endsWith(`
4221
+ `)) {
4222
+ right = right.slice(0, -1);
4223
+ }
4224
+ }
4225
+ return super.equals(left, right, options);
4226
+ }
4227
+ }
4228
+ var lineDiff = new LineDiff;
4229
+ function tokenize(value, options) {
4230
+ if (options.stripTrailingCr) {
4231
+ value = value.replace(/\r\n/g, `
4232
+ `);
4233
+ }
4234
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
4235
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
4236
+ linesAndNewlines.pop();
4237
+ }
4238
+ for (let i = 0;i < linesAndNewlines.length; i++) {
4239
+ const line = linesAndNewlines[i];
4240
+ if (i % 2 && !options.newlineIsToken) {
4241
+ retLines[retLines.length - 1] += line;
4242
+ } else {
4243
+ retLines.push(line);
4244
+ }
4245
+ }
4246
+ return retLines;
4247
+ }
4248
+
4249
+ // ../../node_modules/diff/libesm/diff/sentence.js
4250
+ function isSentenceEndPunct(char) {
4251
+ return char == "." || char == "!" || char == "?";
4252
+ }
4253
+
4254
+ class SentenceDiff extends Diff {
4255
+ tokenize(value) {
4256
+ var _a;
4257
+ const result = [];
4258
+ let tokenStartI = 0;
4259
+ for (let i = 0;i < value.length; i++) {
4260
+ if (i == value.length - 1) {
4261
+ result.push(value.slice(tokenStartI));
4262
+ break;
4263
+ }
4264
+ if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
4265
+ result.push(value.slice(tokenStartI, i + 1));
4266
+ i = tokenStartI = i + 1;
4267
+ while ((_a = value[i + 1]) === null || _a === undefined ? undefined : _a.match(/\s/)) {
4268
+ i++;
4269
+ }
4270
+ result.push(value.slice(tokenStartI, i + 1));
4271
+ tokenStartI = i + 1;
4272
+ }
4273
+ }
4274
+ return result;
4275
+ }
4276
+ }
4277
+ var sentenceDiff = new SentenceDiff;
4278
+
4279
+ // ../../node_modules/diff/libesm/diff/css.js
4280
+ class CssDiff extends Diff {
4281
+ tokenize(value) {
4282
+ return value.split(/([{}:;,]|\s+)/);
4283
+ }
4284
+ }
4285
+ var cssDiff = new CssDiff;
4286
+
4287
+ // ../../node_modules/diff/libesm/diff/json.js
4288
+ class JsonDiff extends Diff {
4289
+ constructor() {
4290
+ super(...arguments);
4291
+ this.tokenize = tokenize;
4292
+ }
4293
+ get useLongestToken() {
4294
+ return true;
4295
+ }
4296
+ castInput(value, options) {
4297
+ const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
4298
+ return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
4299
+ }
4300
+ equals(left, right, options) {
4301
+ return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
4302
+ }
4303
+ }
4304
+ var jsonDiff = new JsonDiff;
4305
+ function canonicalize(obj, stack, replacementStack, replacer, key) {
4306
+ stack = stack || [];
4307
+ replacementStack = replacementStack || [];
4308
+ if (replacer) {
4309
+ obj = replacer(key === undefined ? "" : key, obj);
4310
+ }
4311
+ let i;
4312
+ for (i = 0;i < stack.length; i += 1) {
4313
+ if (stack[i] === obj) {
4314
+ return replacementStack[i];
4315
+ }
4316
+ }
4317
+ let canonicalizedObj;
4318
+ if (Object.prototype.toString.call(obj) === "[object Array]") {
4319
+ stack.push(obj);
4320
+ canonicalizedObj = new Array(obj.length);
4321
+ replacementStack.push(canonicalizedObj);
4322
+ for (i = 0;i < obj.length; i += 1) {
4323
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
4324
+ }
4325
+ stack.pop();
4326
+ replacementStack.pop();
4327
+ return canonicalizedObj;
4328
+ }
4329
+ if (obj && obj.toJSON) {
4330
+ obj = obj.toJSON();
4331
+ }
4332
+ if (typeof obj === "object" && obj !== null) {
4333
+ stack.push(obj);
4334
+ canonicalizedObj = {};
4335
+ replacementStack.push(canonicalizedObj);
4336
+ const sortedKeys = [];
4337
+ let key2;
4338
+ for (key2 in obj) {
4339
+ if (Object.prototype.hasOwnProperty.call(obj, key2)) {
4340
+ sortedKeys.push(key2);
4341
+ }
4342
+ }
4343
+ sortedKeys.sort();
4344
+ for (i = 0;i < sortedKeys.length; i += 1) {
4345
+ key2 = sortedKeys[i];
4346
+ canonicalizedObj[key2] = canonicalize(obj[key2], stack, replacementStack, replacer, key2);
4347
+ }
4348
+ stack.pop();
4349
+ replacementStack.pop();
4350
+ } else {
4351
+ canonicalizedObj = obj;
4352
+ }
4353
+ return canonicalizedObj;
4354
+ }
4355
+
4356
+ // ../../node_modules/diff/libesm/diff/array.js
4357
+ class ArrayDiff extends Diff {
4358
+ tokenize(value) {
4359
+ return value.slice();
4360
+ }
4361
+ join(value) {
4362
+ return value;
4363
+ }
4364
+ removeEmpty(value) {
4365
+ return value;
4366
+ }
4367
+ }
4368
+ var arrayDiff = new ArrayDiff;
4369
+
4370
+ // ../../node_modules/diff/libesm/patch/parse.js
4371
+ function parsePatch(uniDiff) {
4372
+ const diffstr = uniDiff.split(/\n/), list = [];
4373
+ let i = 0;
4374
+ function parseIndex() {
4375
+ const index = {};
4376
+ list.push(index);
4377
+ while (i < diffstr.length) {
4378
+ const line = diffstr[i];
4379
+ if (/^(---|\+\+\+|@@)\s/.test(line)) {
4380
+ break;
4381
+ }
4382
+ const header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
4383
+ if (header) {
4384
+ index.index = header[1];
4385
+ }
4386
+ i++;
4387
+ }
4388
+ parseFileHeader(index);
4389
+ parseFileHeader(index);
4390
+ index.hunks = [];
4391
+ while (i < diffstr.length) {
4392
+ const line = diffstr[i];
4393
+ if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(line)) {
4394
+ break;
4395
+ } else if (/^@@/.test(line)) {
4396
+ index.hunks.push(parseHunk());
4397
+ } else if (line) {
4398
+ throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(line));
4399
+ } else {
4400
+ i++;
4401
+ }
4402
+ }
4403
+ }
4404
+ function parseFileHeader(index) {
4405
+ const fileHeader = /^(---|\+\+\+)\s+(.*)\r?$/.exec(diffstr[i]);
4406
+ if (fileHeader) {
4407
+ const data = fileHeader[2].split("\t", 2), header = (data[1] || "").trim();
4408
+ let fileName = data[0].replace(/\\\\/g, "\\");
4409
+ if (/^".*"$/.test(fileName)) {
4410
+ fileName = fileName.substr(1, fileName.length - 2);
4411
+ }
4412
+ if (fileHeader[1] === "---") {
4413
+ index.oldFileName = fileName;
4414
+ index.oldHeader = header;
4415
+ } else {
4416
+ index.newFileName = fileName;
4417
+ index.newHeader = header;
4418
+ }
4419
+ i++;
4420
+ }
4421
+ }
4422
+ function parseHunk() {
4423
+ var _a;
4424
+ const chunkHeaderIndex = i, chunkHeaderLine = diffstr[i++], chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
4425
+ const hunk = {
4426
+ oldStart: +chunkHeader[1],
4427
+ oldLines: typeof chunkHeader[2] === "undefined" ? 1 : +chunkHeader[2],
4428
+ newStart: +chunkHeader[3],
4429
+ newLines: typeof chunkHeader[4] === "undefined" ? 1 : +chunkHeader[4],
4430
+ lines: []
4431
+ };
4432
+ if (hunk.oldLines === 0) {
4433
+ hunk.oldStart += 1;
4434
+ }
4435
+ if (hunk.newLines === 0) {
4436
+ hunk.newStart += 1;
4437
+ }
4438
+ let addCount = 0, removeCount = 0;
4439
+ for (;i < diffstr.length && (removeCount < hunk.oldLines || addCount < hunk.newLines || ((_a = diffstr[i]) === null || _a === undefined ? undefined : _a.startsWith("\\"))); i++) {
4440
+ const operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? " " : diffstr[i][0];
4441
+ if (operation === "+" || operation === "-" || operation === " " || operation === "\\") {
4442
+ hunk.lines.push(diffstr[i]);
4443
+ if (operation === "+") {
4444
+ addCount++;
4445
+ } else if (operation === "-") {
4446
+ removeCount++;
4447
+ } else if (operation === " ") {
4448
+ addCount++;
4449
+ removeCount++;
4450
+ }
4451
+ } else {
4452
+ throw new Error(`Hunk at line ${chunkHeaderIndex + 1} contained invalid line ${diffstr[i]}`);
4453
+ }
4454
+ }
4455
+ if (!addCount && hunk.newLines === 1) {
4456
+ hunk.newLines = 0;
4457
+ }
4458
+ if (!removeCount && hunk.oldLines === 1) {
4459
+ hunk.oldLines = 0;
4460
+ }
4461
+ if (addCount !== hunk.newLines) {
4462
+ throw new Error("Added line count did not match for hunk at line " + (chunkHeaderIndex + 1));
4463
+ }
4464
+ if (removeCount !== hunk.oldLines) {
4465
+ throw new Error("Removed line count did not match for hunk at line " + (chunkHeaderIndex + 1));
4466
+ }
4467
+ return hunk;
4468
+ }
4469
+ while (i < diffstr.length) {
4470
+ parseIndex();
4471
+ }
4472
+ return list;
4473
+ }
3759
4474
 
3760
4475
  // src/renderables/Text.ts
3761
4476
  class TextRenderable extends TextBufferRenderable {
@@ -3859,6 +4574,7 @@ class DiffRenderable extends Renderable {
3859
4574
  _view;
3860
4575
  _parsedDiff = null;
3861
4576
  _parseError = null;
4577
+ _fg;
3862
4578
  _filetype;
3863
4579
  _syntaxStyle;
3864
4580
  _wrapMode;
@@ -3896,6 +4612,7 @@ class DiffRenderable extends Renderable {
3896
4612
  });
3897
4613
  this._diff = options.diff ?? "";
3898
4614
  this._view = options.view ?? "unified";
4615
+ this._fg = options.fg ? parseColor(options.fg) : undefined;
3899
4616
  this._filetype = options.filetype;
3900
4617
  this._syntaxStyle = options.syntaxStyle;
3901
4618
  this._wrapMode = options.wrapMode;
@@ -4056,6 +4773,7 @@ class DiffRenderable extends Renderable {
4056
4773
  syntaxStyle: this._syntaxStyle ?? SyntaxStyle.create(),
4057
4774
  width: "100%",
4058
4775
  height: "100%",
4776
+ ...this._fg !== undefined && { fg: this._fg },
4059
4777
  ...drawUnstyledText !== undefined && { drawUnstyledText },
4060
4778
  ...this._selectionBg !== undefined && { selectionBg: this._selectionBg },
4061
4779
  ...this._selectionFg !== undefined && { selectionFg: this._selectionFg },
@@ -4087,6 +4805,9 @@ class DiffRenderable extends Renderable {
4087
4805
  if (this._selectionFg !== undefined) {
4088
4806
  existingRenderable.selectionFg = this._selectionFg;
4089
4807
  }
4808
+ if (this._fg !== undefined) {
4809
+ existingRenderable.fg = this._fg;
4810
+ }
4090
4811
  return existingRenderable;
4091
4812
  }
4092
4813
  }
@@ -4698,8 +5419,78 @@ class DiffRenderable extends Renderable {
4698
5419
  this.rebuildView();
4699
5420
  }
4700
5421
  }
5422
+ get fg() {
5423
+ return this._fg;
5424
+ }
5425
+ set fg(value) {
5426
+ const parsed = value ? parseColor(value) : undefined;
5427
+ if (this._fg !== parsed) {
5428
+ this._fg = parsed;
5429
+ if (this.leftCodeRenderable) {
5430
+ this.leftCodeRenderable.fg = parsed;
5431
+ }
5432
+ if (this.rightCodeRenderable) {
5433
+ this.rightCodeRenderable.fg = parsed;
5434
+ }
5435
+ }
5436
+ }
5437
+ }
5438
+ // src/lib/keymapping.ts
5439
+ var defaultKeyAliases = {
5440
+ enter: "return",
5441
+ esc: "escape"
5442
+ };
5443
+ function mergeKeyAliases(defaults, custom) {
5444
+ return { ...defaults, ...custom };
5445
+ }
5446
+ function mergeKeyBindings(defaults, custom) {
5447
+ const map = new Map;
5448
+ for (const binding of defaults) {
5449
+ const key = getKeyBindingKey(binding);
5450
+ map.set(key, binding);
5451
+ }
5452
+ for (const binding of custom) {
5453
+ const key = getKeyBindingKey(binding);
5454
+ map.set(key, binding);
5455
+ }
5456
+ return Array.from(map.values());
5457
+ }
5458
+ function getKeyBindingKey(binding) {
5459
+ return `${binding.name}:${binding.ctrl ? 1 : 0}:${binding.shift ? 1 : 0}:${binding.meta ? 1 : 0}:${binding.super ? 1 : 0}`;
5460
+ }
5461
+ function buildKeyBindingsMap(bindings, aliasMap) {
5462
+ const map = new Map;
5463
+ const aliases = aliasMap || {};
5464
+ for (const binding of bindings) {
5465
+ const key = getKeyBindingKey(binding);
5466
+ map.set(key, binding.action);
5467
+ }
5468
+ for (const binding of bindings) {
5469
+ const normalizedName = aliases[binding.name] || binding.name;
5470
+ if (normalizedName !== binding.name) {
5471
+ const aliasedKey = getKeyBindingKey({ ...binding, name: normalizedName });
5472
+ map.set(aliasedKey, binding.action);
5473
+ }
5474
+ }
5475
+ return map;
4701
5476
  }
5477
+
4702
5478
  // src/renderables/Input.ts
5479
+ var defaultInputKeybindings = [
5480
+ { name: "left", action: "move-left" },
5481
+ { name: "right", action: "move-right" },
5482
+ { name: "home", action: "move-home" },
5483
+ { name: "end", action: "move-end" },
5484
+ { name: "backspace", action: "delete-backward" },
5485
+ { name: "delete", action: "delete-forward" },
5486
+ { name: "return", action: "submit" },
5487
+ { name: "linefeed", action: "submit" },
5488
+ { name: "a", ctrl: true, action: "move-home" },
5489
+ { name: "e", ctrl: true, action: "move-end" },
5490
+ { name: "f", ctrl: true, action: "move-right" },
5491
+ { name: "b", ctrl: true, action: "move-left" },
5492
+ { name: "d", ctrl: true, action: "delete-forward" }
5493
+ ];
4703
5494
  var InputRenderableEvents;
4704
5495
  ((InputRenderableEvents2) => {
4705
5496
  InputRenderableEvents2["INPUT"] = "input";
@@ -4721,6 +5512,9 @@ class InputRenderable extends Renderable {
4721
5512
  _cursorStyle;
4722
5513
  _maxLength;
4723
5514
  _lastCommittedValue = "";
5515
+ _keyBindingsMap;
5516
+ _keyAliasMap;
5517
+ _keyBindings;
4724
5518
  _defaultOptions = {
4725
5519
  backgroundColor: "transparent",
4726
5520
  textColor: "#FFFFFF",
@@ -4750,6 +5544,10 @@ class InputRenderable extends Renderable {
4750
5544
  this._placeholderColor = parseColor(options.placeholderColor || this._defaultOptions.placeholderColor);
4751
5545
  this._cursorColor = parseColor(options.cursorColor || this._defaultOptions.cursorColor);
4752
5546
  this._cursorStyle = options.cursorStyle || this._defaultOptions.cursorStyle;
5547
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
5548
+ this._keyBindings = options.keyBindings || [];
5549
+ const mergedBindings = mergeKeyBindings(defaultInputKeybindings, this._keyBindings);
5550
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
4753
5551
  }
4754
5552
  updateCursorPosition() {
4755
5553
  if (!this._focused)
@@ -4880,39 +5678,58 @@ class InputRenderable extends Renderable {
4880
5678
  handleKeyPress(key) {
4881
5679
  const keyName = typeof key === "string" ? key : key.name;
4882
5680
  const keySequence = typeof key === "string" ? key : key.sequence;
4883
- switch (keyName) {
4884
- case "left":
4885
- this.cursorPosition = this._cursorPosition - 1;
4886
- return true;
4887
- case "right":
4888
- this.cursorPosition = this._cursorPosition + 1;
4889
- return true;
4890
- case "home":
4891
- this.cursorPosition = 0;
4892
- return true;
4893
- case "end":
4894
- this.cursorPosition = this._value.length;
4895
- return true;
4896
- case "backspace":
4897
- this.deleteCharacter("backward");
4898
- return true;
4899
- case "delete":
4900
- this.deleteCharacter("forward");
5681
+ const keyCtrl = typeof key === "string" ? false : key.ctrl;
5682
+ const keyShift = typeof key === "string" ? false : key.shift;
5683
+ const keyMeta = typeof key === "string" ? false : key.meta;
5684
+ const keySuper = typeof key === "string" ? false : key.super;
5685
+ const keyHyper = typeof key === "string" ? false : key.hyper;
5686
+ const bindingKey = getKeyBindingKey({
5687
+ name: keyName,
5688
+ ctrl: keyCtrl,
5689
+ shift: keyShift,
5690
+ meta: keyMeta,
5691
+ super: keySuper,
5692
+ action: "move-left"
5693
+ });
5694
+ const action = this._keyBindingsMap.get(bindingKey);
5695
+ if (action) {
5696
+ switch (action) {
5697
+ case "move-left":
5698
+ this.cursorPosition = this._cursorPosition - 1;
5699
+ return true;
5700
+ case "move-right":
5701
+ this.cursorPosition = this._cursorPosition + 1;
5702
+ return true;
5703
+ case "move-home":
5704
+ this.cursorPosition = 0;
5705
+ return true;
5706
+ case "move-end":
5707
+ this.cursorPosition = this._value.length;
5708
+ return true;
5709
+ case "delete-backward":
5710
+ this.deleteCharacter("backward");
5711
+ return true;
5712
+ case "delete-forward":
5713
+ this.deleteCharacter("forward");
5714
+ return true;
5715
+ case "submit":
5716
+ if (this._value !== this._lastCommittedValue) {
5717
+ this._lastCommittedValue = this._value;
5718
+ this.emit("change" /* CHANGE */, this._value);
5719
+ }
5720
+ this.emit("enter" /* ENTER */, this._value);
5721
+ return true;
5722
+ }
5723
+ }
5724
+ if (!keyCtrl && !keyMeta && !keySuper && !keyHyper) {
5725
+ if (keyName === "space") {
5726
+ this.insertText(" ");
4901
5727
  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);
5728
+ }
5729
+ if (keySequence && keySequence.length === 1 && keySequence.charCodeAt(0) >= 32 && keySequence.charCodeAt(0) <= 126) {
5730
+ this.insertText(keySequence);
4909
5731
  return true;
4910
- default:
4911
- if (keySequence && keySequence.length === 1 && keySequence.charCodeAt(0) >= 32 && keySequence.charCodeAt(0) <= 126) {
4912
- this.insertText(keySequence);
4913
- return true;
4914
- }
4915
- break;
5732
+ }
4916
5733
  }
4917
5734
  return false;
4918
5735
  }
@@ -4992,6 +5809,16 @@ class InputRenderable extends Renderable {
4992
5809
  this._ctx.setCursorPosition(0, 0, false);
4993
5810
  }
4994
5811
  }
5812
+ set keyBindings(bindings) {
5813
+ this._keyBindings = bindings;
5814
+ const mergedBindings = mergeKeyBindings(defaultInputKeybindings, bindings);
5815
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
5816
+ }
5817
+ set keyAliasMap(aliases) {
5818
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
5819
+ const mergedBindings = mergeKeyBindings(defaultInputKeybindings, this._keyBindings);
5820
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
5821
+ }
4995
5822
  }
4996
5823
  // src/renderables/Slider.ts
4997
5824
  var defaultThumbBackgroundColor = RGBA.fromHex("#9a9ea3");
@@ -5592,7 +6419,7 @@ class ContentRenderable extends BoxRenderable {
5592
6419
  }
5593
6420
  _getVisibleChildren() {
5594
6421
  if (this._viewportCulling) {
5595
- return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis).map((child) => child.num);
6422
+ return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis, 0).map((child) => child.num);
5596
6423
  }
5597
6424
  return this.getChildrenSortedByPrimaryAxis().map((child) => child.num);
5598
6425
  }
@@ -6144,6 +6971,16 @@ class ScrollBoxRenderable extends BoxRenderable {
6144
6971
  }
6145
6972
  }
6146
6973
  // src/renderables/Select.ts
6974
+ var defaultSelectKeybindings = [
6975
+ { name: "up", action: "move-up" },
6976
+ { name: "k", action: "move-up" },
6977
+ { name: "down", action: "move-down" },
6978
+ { name: "j", action: "move-down" },
6979
+ { name: "up", shift: true, action: "move-up-fast" },
6980
+ { name: "down", shift: true, action: "move-down-fast" },
6981
+ { name: "return", action: "select-current" },
6982
+ { name: "linefeed", action: "select-current" }
6983
+ ];
6147
6984
  var SelectRenderableEvents;
6148
6985
  ((SelectRenderableEvents2) => {
6149
6986
  SelectRenderableEvents2["SELECTION_CHANGED"] = "selectionChanged";
@@ -6172,6 +7009,9 @@ class SelectRenderable extends Renderable {
6172
7009
  linesPerItem;
6173
7010
  fontHeight;
6174
7011
  _fastScrollStep;
7012
+ _keyBindingsMap;
7013
+ _keyAliasMap;
7014
+ _keyBindings;
6175
7015
  _defaultOptions = {
6176
7016
  backgroundColor: "transparent",
6177
7017
  textColor: "#FFFFFF",
@@ -6211,6 +7051,10 @@ class SelectRenderable extends Renderable {
6211
7051
  this._descriptionColor = parseColor(options.descriptionColor || this._defaultOptions.descriptionColor);
6212
7052
  this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor || this._defaultOptions.selectedDescriptionColor);
6213
7053
  this._fastScrollStep = options.fastScrollStep || this._defaultOptions.fastScrollStep;
7054
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
7055
+ this._keyBindings = options.keyBindings || [];
7056
+ const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, this._keyBindings);
7057
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
6214
7058
  this.requestRender();
6215
7059
  }
6216
7060
  renderSelf(buffer, deltaTime) {
@@ -6351,20 +7195,37 @@ class SelectRenderable extends Renderable {
6351
7195
  }
6352
7196
  handleKeyPress(key) {
6353
7197
  const keyName = typeof key === "string" ? key : key.name;
6354
- const isShift = typeof key !== "string" && key.shift;
6355
- switch (keyName) {
6356
- case "up":
6357
- case "k":
6358
- this.moveUp(isShift ? this._fastScrollStep : 1);
6359
- return true;
6360
- case "down":
6361
- case "j":
6362
- this.moveDown(isShift ? this._fastScrollStep : 1);
6363
- return true;
6364
- case "return":
6365
- case "linefeed":
6366
- this.selectCurrent();
6367
- return true;
7198
+ const keyCtrl = typeof key === "string" ? false : key.ctrl;
7199
+ const keyShift = typeof key === "string" ? false : key.shift;
7200
+ const keyMeta = typeof key === "string" ? false : key.meta;
7201
+ const keySuper = typeof key === "string" ? false : key.super;
7202
+ const bindingKey = getKeyBindingKey({
7203
+ name: keyName,
7204
+ ctrl: keyCtrl,
7205
+ shift: keyShift,
7206
+ meta: keyMeta,
7207
+ super: keySuper,
7208
+ action: "move-up"
7209
+ });
7210
+ const action = this._keyBindingsMap.get(bindingKey);
7211
+ if (action) {
7212
+ switch (action) {
7213
+ case "move-up":
7214
+ this.moveUp(1);
7215
+ return true;
7216
+ case "move-down":
7217
+ this.moveDown(1);
7218
+ return true;
7219
+ case "move-up-fast":
7220
+ this.moveUp(this._fastScrollStep);
7221
+ return true;
7222
+ case "move-down-fast":
7223
+ this.moveDown(this._fastScrollStep);
7224
+ return true;
7225
+ case "select-current":
7226
+ this.selectCurrent();
7227
+ return true;
7228
+ }
6368
7229
  }
6369
7230
  return false;
6370
7231
  }
@@ -6470,6 +7331,16 @@ class SelectRenderable extends Renderable {
6470
7331
  set fastScrollStep(step) {
6471
7332
  this._fastScrollStep = step;
6472
7333
  }
7334
+ set keyBindings(bindings) {
7335
+ this._keyBindings = bindings;
7336
+ const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, bindings);
7337
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
7338
+ }
7339
+ set keyAliasMap(aliases) {
7340
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
7341
+ const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, this._keyBindings);
7342
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
7343
+ }
6473
7344
  set selectedIndex(value) {
6474
7345
  const newIndex = value ?? this._defaultOptions.selectedIndex;
6475
7346
  const clampedIndex = this._options.length > 0 ? Math.min(Math.max(0, newIndex), this._options.length - 1) : 0;
@@ -6481,6 +7352,14 @@ class SelectRenderable extends Renderable {
6481
7352
  }
6482
7353
  }
6483
7354
  // src/renderables/TabSelect.ts
7355
+ var defaultTabSelectKeybindings = [
7356
+ { name: "left", action: "move-left" },
7357
+ { name: "[", action: "move-left" },
7358
+ { name: "right", action: "move-right" },
7359
+ { name: "]", action: "move-right" },
7360
+ { name: "return", action: "select-current" },
7361
+ { name: "linefeed", action: "select-current" }
7362
+ ];
6484
7363
  var TabSelectRenderableEvents;
6485
7364
  ((TabSelectRenderableEvents2) => {
6486
7365
  TabSelectRenderableEvents2["SELECTION_CHANGED"] = "selectionChanged";
@@ -6515,6 +7394,9 @@ class TabSelectRenderable extends Renderable {
6515
7394
  _showDescription;
6516
7395
  _showUnderline;
6517
7396
  _wrapSelection;
7397
+ _keyBindingsMap;
7398
+ _keyAliasMap;
7399
+ _keyBindings;
6518
7400
  constructor(ctx, options) {
6519
7401
  const calculatedHeight = calculateDynamicHeight(options.showUnderline ?? true, options.showDescription ?? true);
6520
7402
  super(ctx, { ...options, height: calculatedHeight, buffered: true });
@@ -6532,6 +7414,10 @@ class TabSelectRenderable extends Renderable {
6532
7414
  this._selectedBackgroundColor = parseColor(options.selectedBackgroundColor || "#334455");
6533
7415
  this._selectedTextColor = parseColor(options.selectedTextColor || "#FFFF00");
6534
7416
  this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor || "#CCCCCC");
7417
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
7418
+ this._keyBindings = options.keyBindings || [];
7419
+ const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
7420
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
6535
7421
  }
6536
7422
  calculateDynamicHeight() {
6537
7423
  return calculateDynamicHeight(this._showUnderline, this._showDescription);
@@ -6682,19 +7568,31 @@ class TabSelectRenderable extends Renderable {
6682
7568
  }
6683
7569
  handleKeyPress(key) {
6684
7570
  const keyName = typeof key === "string" ? key : key.name;
6685
- switch (keyName) {
6686
- case "left":
6687
- case "[":
6688
- this.moveLeft();
6689
- return true;
6690
- case "right":
6691
- case "]":
6692
- this.moveRight();
6693
- return true;
6694
- case "return":
6695
- case "linefeed":
6696
- this.selectCurrent();
6697
- return true;
7571
+ const keyCtrl = typeof key === "string" ? false : key.ctrl;
7572
+ const keyShift = typeof key === "string" ? false : key.shift;
7573
+ const keyMeta = typeof key === "string" ? false : key.meta;
7574
+ const keySuper = typeof key === "string" ? false : key.super;
7575
+ const bindingKey = getKeyBindingKey({
7576
+ name: keyName,
7577
+ ctrl: keyCtrl,
7578
+ shift: keyShift,
7579
+ meta: keyMeta,
7580
+ super: keySuper,
7581
+ action: "move-left"
7582
+ });
7583
+ const action = this._keyBindingsMap.get(bindingKey);
7584
+ if (action) {
7585
+ switch (action) {
7586
+ case "move-left":
7587
+ this.moveLeft();
7588
+ return true;
7589
+ case "move-right":
7590
+ this.moveRight();
7591
+ return true;
7592
+ case "select-current":
7593
+ this.selectCurrent();
7594
+ return true;
7595
+ }
6698
7596
  }
6699
7597
  return false;
6700
7598
  }
@@ -6783,10 +7681,18 @@ class TabSelectRenderable extends Renderable {
6783
7681
  this.updateScrollOffset();
6784
7682
  this.requestRender();
6785
7683
  }
7684
+ set keyBindings(bindings) {
7685
+ this._keyBindings = bindings;
7686
+ const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, bindings);
7687
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
7688
+ }
7689
+ set keyAliasMap(aliases) {
7690
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
7691
+ const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
7692
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
7693
+ }
6786
7694
  }
6787
7695
  // src/renderables/EditBufferRenderable.ts
6788
- import { MeasureMode as MeasureMode2 } from "bun-yoga";
6789
-
6790
7696
  class EditBufferRenderable extends Renderable {
6791
7697
  _focusable = true;
6792
7698
  selectable = true;
@@ -7086,7 +7992,7 @@ class EditBufferRenderable extends Renderable {
7086
7992
  setupMeasureFunc() {
7087
7993
  const measureFunc = (width, widthMode, height, heightMode) => {
7088
7994
  let effectiveWidth;
7089
- if (widthMode === MeasureMode2.Undefined || isNaN(width)) {
7995
+ if (widthMode === MeasureMode.Undefined || isNaN(width)) {
7090
7996
  effectiveWidth = 0;
7091
7997
  } else {
7092
7998
  effectiveWidth = width;
@@ -7095,7 +8001,7 @@ class EditBufferRenderable extends Renderable {
7095
8001
  const measureResult = this.editorView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
7096
8002
  const measuredWidth = measureResult ? Math.max(1, measureResult.maxWidth) : 1;
7097
8003
  const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
7098
- if (widthMode === MeasureMode2.AtMost && this._positionType !== "absolute") {
8004
+ if (widthMode === MeasureMode.AtMost && this._positionType !== "absolute") {
7099
8005
  return {
7100
8006
  width: Math.min(effectiveWidth, measuredWidth),
7101
8007
  height: Math.min(effectiveHeight, measuredHeight)
@@ -7278,31 +8184,6 @@ class EditBufferRenderable extends Renderable {
7278
8184
  }
7279
8185
  }
7280
8186
 
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
8187
  // src/renderables/Textarea.ts
7307
8188
  var defaultTextareaKeybindings = [
7308
8189
  { name: "left", action: "move-left" },
@@ -7355,6 +8236,8 @@ class TextareaRenderable extends EditBufferRenderable {
7355
8236
  _focusedBackgroundColor;
7356
8237
  _focusedTextColor;
7357
8238
  _keyBindingsMap;
8239
+ _keyAliasMap;
8240
+ _keyBindings;
7358
8241
  _actionHandlers;
7359
8242
  _initialValueSet = false;
7360
8243
  _submitListener = undefined;
@@ -7378,8 +8261,10 @@ class TextareaRenderable extends EditBufferRenderable {
7378
8261
  this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || options.backgroundColor || defaults.focusedBackgroundColor);
7379
8262
  this._focusedTextColor = parseColor(options.focusedTextColor || options.textColor || defaults.focusedTextColor);
7380
8263
  this._placeholder = options.placeholder ?? defaults.placeholder;
7381
- const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, options.keyBindings || []);
7382
- this._keyBindingsMap = buildKeyBindingsMap(mergedBindings);
8264
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
8265
+ this._keyBindings = options.keyBindings || [];
8266
+ const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, this._keyBindings);
8267
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
7383
8268
  this._actionHandlers = this.buildActionHandlers();
7384
8269
  this._submitListener = options.onSubmit;
7385
8270
  if (options.initialValue) {
@@ -7447,6 +8332,7 @@ class TextareaRenderable extends EditBufferRenderable {
7447
8332
  const keyShift = typeof key === "string" ? false : key.shift;
7448
8333
  const keyMeta = typeof key === "string" ? false : key.meta;
7449
8334
  const keySuper = typeof key === "string" ? false : key.super;
8335
+ const keyHyper = typeof key === "string" ? false : key.hyper;
7450
8336
  const bindingKey = getKeyBindingKey({
7451
8337
  name: keyName,
7452
8338
  ctrl: keyCtrl,
@@ -7462,16 +8348,22 @@ class TextareaRenderable extends EditBufferRenderable {
7462
8348
  return handler();
7463
8349
  }
7464
8350
  }
7465
- if (keySequence && !keyCtrl && !keyMeta) {
7466
- const firstCharCode = keySequence.charCodeAt(0);
7467
- if (firstCharCode < 32) {
7468
- return false;
8351
+ if (!keyCtrl && !keyMeta && !keySuper && !keyHyper) {
8352
+ if (keyName === "space") {
8353
+ this.insertText(" ");
8354
+ return true;
7469
8355
  }
7470
- if (firstCharCode === 127) {
7471
- return false;
8356
+ if (keySequence) {
8357
+ const firstCharCode = keySequence.charCodeAt(0);
8358
+ if (firstCharCode < 32) {
8359
+ return false;
8360
+ }
8361
+ if (firstCharCode === 127) {
8362
+ return false;
8363
+ }
8364
+ this.insertText(keySequence);
8365
+ return true;
7472
8366
  }
7473
- this.insertText(keySequence);
7474
- return true;
7475
8367
  }
7476
8368
  return false;
7477
8369
  }
@@ -7572,7 +8464,13 @@ class TextareaRenderable extends EditBufferRenderable {
7572
8464
  const select = options?.select ?? false;
7573
8465
  this.updateSelectionForMovement(select, true);
7574
8466
  const cursor = this.editorView.getCursor();
7575
- this.editBuffer.setCursor(cursor.row, 0);
8467
+ if (cursor.col === 0 && cursor.row > 0) {
8468
+ this.editBuffer.setCursor(cursor.row - 1, 0);
8469
+ const prevLineEol = this.editBuffer.getEOL();
8470
+ this.editBuffer.setCursor(prevLineEol.row, prevLineEol.col);
8471
+ } else {
8472
+ this.editBuffer.setCursor(cursor.row, 0);
8473
+ }
7576
8474
  this.updateSelectionForMovement(select, false);
7577
8475
  this.requestRender();
7578
8476
  return true;
@@ -7580,8 +8478,14 @@ class TextareaRenderable extends EditBufferRenderable {
7580
8478
  gotoLineEnd(options) {
7581
8479
  const select = options?.select ?? false;
7582
8480
  this.updateSelectionForMovement(select, true);
8481
+ const cursor = this.editorView.getCursor();
7583
8482
  const eol = this.editBuffer.getEOL();
7584
- this.editBuffer.setCursor(eol.row, eol.col);
8483
+ const lineCount = this.editBuffer.getLineCount();
8484
+ if (cursor.col === eol.col && cursor.row < lineCount - 1) {
8485
+ this.editBuffer.setCursor(cursor.row + 1, 0);
8486
+ } else {
8487
+ this.editBuffer.setCursor(eol.row, eol.col);
8488
+ }
7585
8489
  this.updateSelectionForMovement(select, false);
7586
8490
  this.requestRender();
7587
8491
  return true;
@@ -7750,15 +8654,19 @@ class TextareaRenderable extends EditBufferRenderable {
7750
8654
  return this._submitListener;
7751
8655
  }
7752
8656
  set keyBindings(bindings) {
8657
+ this._keyBindings = bindings;
7753
8658
  const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, bindings);
7754
- this._keyBindingsMap = buildKeyBindingsMap(mergedBindings);
8659
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
8660
+ }
8661
+ set keyAliasMap(aliases) {
8662
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
8663
+ const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, this._keyBindings);
8664
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
7755
8665
  }
7756
8666
  get extmarks() {
7757
8667
  return this.editorView.extmarks;
7758
8668
  }
7759
8669
  }
7760
- // src/index.ts
7761
- import * as Yoga from "bun-yoga";
7762
8670
  export {
7763
8671
  yellow,
7764
8672
  wrapWithDelegates,
@@ -7838,6 +8746,7 @@ export {
7838
8746
  convertGlobalToLocalSelection,
7839
8747
  clearEnvCache,
7840
8748
  capture,
8749
+ buildKittyKeyboardFlags,
7841
8750
  brightYellow,
7842
8751
  brightWhite,
7843
8752
  brightRed,
@@ -7868,7 +8777,7 @@ export {
7868
8777
  applyChromaticAberration,
7869
8778
  applyAsciiArt,
7870
8779
  addDefaultParsers,
7871
- Yoga,
8780
+ exports_src as Yoga,
7872
8781
  VignetteEffect,
7873
8782
  VRenderable,
7874
8783
  TreeSitterClient,
@@ -7946,5 +8855,5 @@ export {
7946
8855
  ASCIIFont
7947
8856
  };
7948
8857
 
7949
- //# debugId=8B540B053341534264756E2164756E21
8858
+ //# debugId=23F67606D23EDCE364756E2164756E21
7950
8859
  //# sourceMappingURL=index.js.map