@opentui/core 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,6 @@ import {
8
8
  registerEnvVar2,
9
9
  env2,
10
10
  stringWidth,
11
- stripANSI,
12
11
  Worker,
13
12
  DEFAULT_FOREGROUND_RGB2,
14
13
  DEFAULT_BACKGROUND_RGB2,
@@ -64,7 +63,7 @@ import {
64
63
  PositionType2,
65
64
  Unit2,
66
65
  Wrap2
67
- } from "./chunk-bun-tsc14mt5.js";
66
+ } from "./chunk-bun-wsqkxxm5.js";
68
67
 
69
68
  // src/lib/border.ts
70
69
  var VALID_BORDER_STYLES = ["single", "double", "rounded", "heavy"];
@@ -8081,8 +8080,7 @@ class ExtmarksController2 {
8081
8080
  return;
8082
8081
  }
8083
8082
  const targetOffset = currentOffset + 1;
8084
- const textLength = this.editBuffer.getText().length;
8085
- if (targetOffset > textLength) {
8083
+ if (this.editBuffer.offsetToPosition(targetOffset) === null) {
8086
8084
  this.originalMoveCursorRight();
8087
8085
  return;
8088
8086
  }
@@ -8256,28 +8254,12 @@ class ExtmarksController2 {
8256
8254
  this.originalDeleteLine();
8257
8255
  return;
8258
8256
  }
8259
- const text = this.editBuffer.getText();
8260
- const currentOffset = this.editorView.getVisualCursor().offset;
8261
- let lineStart = 0;
8262
- for (let i = currentOffset - 1;i >= 0; i--) {
8263
- if (text[i] === `
8264
- `) {
8265
- lineStart = i + 1;
8266
- break;
8267
- }
8268
- }
8269
- let lineEnd = text.length;
8270
- for (let i = currentOffset;i < text.length; i++) {
8271
- if (text[i] === `
8272
- `) {
8273
- lineEnd = i + 1;
8274
- break;
8275
- }
8276
- }
8277
- const deleteLength = lineEnd - lineStart;
8257
+ const row = this.editBuffer.getCursorPosition().row;
8258
+ const lineStart = this.editBuffer.getLineStartOffset(row);
8259
+ const [start, end] = row + 1 < this.editBuffer.getLineCount() ? [lineStart, this.editBuffer.getLineStartOffset(row + 1)] : [Math.max(0, lineStart - 1), this.editBuffer.getEOL().offset];
8278
8260
  this.originalDeleteLine();
8279
8261
  this.saveSnapshot();
8280
- this.adjustExtmarksAfterDeletion(lineStart, deleteLength);
8262
+ this.adjustExtmarksAfterDeletion(start, end - start);
8281
8263
  });
8282
8264
  }
8283
8265
  wrapInsertion() {
@@ -8468,15 +8450,11 @@ class ExtmarksController2 {
8468
8450
  }
8469
8451
  updateHighlights() {
8470
8452
  this.editBuffer.clearAllHighlights();
8471
- let text;
8472
8453
  for (const extmark of this.extmarks.values()) {
8473
8454
  if (extmark.styleId !== undefined) {
8474
- text ??= this.editBuffer.getText();
8475
- const startWithoutNewlines = this.offsetExcludingNewlines(extmark.start, text);
8476
- const endWithoutNewlines = this.offsetExcludingNewlines(extmark.end, text);
8477
8455
  this.editBuffer.addHighlightByCharRange({
8478
- start: startWithoutNewlines,
8479
- end: endWithoutNewlines,
8456
+ start: this.offsetExcludingNewlines(extmark.start),
8457
+ end: this.offsetExcludingNewlines(extmark.end),
8480
8458
  styleId: extmark.styleId,
8481
8459
  priority: extmark.priority ?? 0,
8482
8460
  hlRef: extmark.id & 65535
@@ -8484,37 +8462,8 @@ class ExtmarksController2 {
8484
8462
  }
8485
8463
  }
8486
8464
  }
8487
- offsetExcludingNewlines(offset, text) {
8488
- let displayWidthSoFar = 0;
8489
- let newlineCount = 0;
8490
- let i = 0;
8491
- while (i < text.length && displayWidthSoFar < offset) {
8492
- if (text[i] === `
8493
- `) {
8494
- displayWidthSoFar++;
8495
- newlineCount++;
8496
- i++;
8497
- } else {
8498
- let j = i;
8499
- while (j < text.length && text[j] !== `
8500
- `) {
8501
- j++;
8502
- }
8503
- const chunk = text.substring(i, j);
8504
- const chunkWidth = stringWidth(chunk);
8505
- if (displayWidthSoFar + chunkWidth < offset) {
8506
- displayWidthSoFar += chunkWidth;
8507
- i = j;
8508
- } else {
8509
- for (let k = i;k < j && displayWidthSoFar < offset; k++) {
8510
- const charWidth = stringWidth(text[k]);
8511
- displayWidthSoFar += charWidth;
8512
- }
8513
- break;
8514
- }
8515
- }
8516
- }
8517
- return offset - newlineCount;
8465
+ offsetExcludingNewlines(offset) {
8466
+ return offset - (this.editBuffer.offsetToPosition(offset)?.row ?? 0);
8518
8467
  }
8519
8468
  create(options) {
8520
8469
  if (this.destroyed) {
@@ -9033,11 +8982,12 @@ function buildTerminalPaletteSignature2(colors) {
9033
8982
 
9034
8983
  // src/lib/paste.ts
9035
8984
  var PASTE_TEXT_DECODER = new TextDecoder;
8985
+ var ANSI_SEQUENCES = /(?:\x1b\[|\x9b)[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]?|(?:\x1b[P\]X^_]|[\x90\x98\x9d-\x9f])[^\x07\x1b\x9c]*(?:\x07|\x1b\\|\x9c)?|\x1b[\x20-\x2f]*[\x30-\x7e]?/g;
9036
8986
  function decodePasteBytes2(bytes) {
9037
8987
  return PASTE_TEXT_DECODER.decode(bytes);
9038
8988
  }
9039
8989
  function stripAnsiSequences2(text) {
9040
- return stripANSI(text);
8990
+ return text.replace(ANSI_SEQUENCES, "");
9041
8991
  }
9042
8992
 
9043
8993
  // src/lib/host-clipboard.internal.ts
@@ -13429,6 +13379,10 @@ class EditBuffer2 extends EventEmitter5 {
13429
13379
  getLineStartOffset(row) {
13430
13380
  return this.position(6 /* LineStart */, row)?.offset ?? 0;
13431
13381
  }
13382
+ measureText(text) {
13383
+ this.guard();
13384
+ return this.lib.contextEditBufferMeasureText(this.native.handle.context, this.native.handle, this.lib.encoder.encode(text));
13385
+ }
13432
13386
  getTextRange(startOffset, endOffset) {
13433
13387
  this.guard();
13434
13388
  if (startOffset >= endOffset)
@@ -24910,5 +24864,5 @@ Captured external output:
24910
24864
 
24911
24865
  export { isValidBorderStyle2, parseBorderStyle2, BorderChars2, getBorderFromSides2, getBorderSides2, borderCharsToArray2, BorderCharArrays2, KeyEvent2, PasteEvent2, KeyHandler2, InternalKeyHandler2, fonts2, measureText2, getCharacterPositions2, coordinateToCharacterIndex2, renderFontToFrameBuffer2, convertThemeToStyles2, SyntaxStyle2, hastToStyledText2, SystemClock2, nonAlphanumericKeys2, terminalNamedSingleStrokeKeys2, parseKeypress2, LinearScrollAccel2, MacOSScrollAccel2, parseAlign2, parseAlignItems2, parseBoxSizing2, parseDimension2, parseDirection2, parseDisplay2, parseEdge2, parseFlexDirection2, parseGutter2, parseJustify2, parseLogLevel2, parseMeasureMode2, parseOverflow2, parsePositionType2, parseUnit2, parseWrap2, MouseParser2, Selection2, convertGlobalToLocalSelection2, ASCIIFontSelectionHelper2, StdinParser2, addDefaultParsers2, TreeSitterClient2, treeSitterToTextChunks2, treeSitterToStyledText2, DataPathsManager2, getDataPaths2, extensionToFiletype2, basenameToFiletype2, extToFiletype2, pathToFiletype2, infoStringToFiletype2, getTreeSitterClient2, destroyTreeSitterClient2, ExtmarksController2, createExtmarksController2, TerminalPalette2, createTerminalPalette2, normalizeTerminalPalette2, buildTerminalPaletteSignature2, decodePasteBytes2, stripAnsiSequences2, createHostClipboard2, createClipboard2, ClipboardTarget2, createRendererClipboardAdapter2, normalizeMarkdownLinkTarget, detectLinks2, acquireSessionBufferLease2, ResourceContext2, OptimizedBuffer2, h2, isVNode2, maybeMakeRenderable2, wrapWithDelegates2, instantiate2, delegate2, LayoutEvents2, RenderableEvents2, isRenderable2, BaseRenderable2, Renderable2, RootRenderable2, TextBuffer2, TextBufferView2, EditBuffer2, EditorView2, Timeline2, engine2, getTimelineEngine2, createTimeline2, ANSI, BoxRenderable2, TextBufferRenderable2, CodeRenderable2, ImageLoadError2, ImageError2, imageInfo2, NativeImage2, NativeImagePool2, resolveImageRenderProtocol2, ImageRenderable2, isTextNodeRenderable2, TextNodeRenderable2, RootTextNodeRenderable2, TextRenderable2, NativeSession2, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture2, ConsolePosition2, TerminalConsole2, EditBufferRenderableEvents2, isEditBufferRenderable2, EditBufferRenderable2, buildKittyKeyboardFlags2, MouseEvent2, MouseButton2, createCliRenderer2, CliRenderEvents2, RendererControlState2, CliRenderer2 };
24912
24866
 
24913
- //# debugId=979769E7103DB2AA64756E2164756E21
24914
- //# sourceMappingURL=chunk-bun-s01c2jyn.js.map
24867
+ //# debugId=0A05D818D68CBE1E64756E2164756E21
24868
+ //# sourceMappingURL=chunk-bun-ww65h9av.js.map