@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.
@@ -7,7 +7,6 @@ import {
7
7
  registerEnvVar2,
8
8
  env2,
9
9
  stringWidth,
10
- stripANSI,
11
10
  Worker,
12
11
  DEFAULT_FOREGROUND_RGB2,
13
12
  DEFAULT_BACKGROUND_RGB2,
@@ -63,7 +62,7 @@ import {
63
62
  PositionType2,
64
63
  Unit2,
65
64
  Wrap2
66
- } from "./chunk-node-df90qrqc.js";
65
+ } from "./chunk-node-f7c1g447.js";
67
66
 
68
67
  // src/lib/border.ts
69
68
  var VALID_BORDER_STYLES = ["single", "double", "rounded", "heavy"];
@@ -8080,8 +8079,7 @@ class ExtmarksController2 {
8080
8079
  return;
8081
8080
  }
8082
8081
  const targetOffset = currentOffset + 1;
8083
- const textLength = this.editBuffer.getText().length;
8084
- if (targetOffset > textLength) {
8082
+ if (this.editBuffer.offsetToPosition(targetOffset) === null) {
8085
8083
  this.originalMoveCursorRight();
8086
8084
  return;
8087
8085
  }
@@ -8255,28 +8253,12 @@ class ExtmarksController2 {
8255
8253
  this.originalDeleteLine();
8256
8254
  return;
8257
8255
  }
8258
- const text = this.editBuffer.getText();
8259
- const currentOffset = this.editorView.getVisualCursor().offset;
8260
- let lineStart = 0;
8261
- for (let i = currentOffset - 1;i >= 0; i--) {
8262
- if (text[i] === `
8263
- `) {
8264
- lineStart = i + 1;
8265
- break;
8266
- }
8267
- }
8268
- let lineEnd = text.length;
8269
- for (let i = currentOffset;i < text.length; i++) {
8270
- if (text[i] === `
8271
- `) {
8272
- lineEnd = i + 1;
8273
- break;
8274
- }
8275
- }
8276
- const deleteLength = lineEnd - lineStart;
8256
+ const row = this.editBuffer.getCursorPosition().row;
8257
+ const lineStart = this.editBuffer.getLineStartOffset(row);
8258
+ const [start, end] = row + 1 < this.editBuffer.getLineCount() ? [lineStart, this.editBuffer.getLineStartOffset(row + 1)] : [Math.max(0, lineStart - 1), this.editBuffer.getEOL().offset];
8277
8259
  this.originalDeleteLine();
8278
8260
  this.saveSnapshot();
8279
- this.adjustExtmarksAfterDeletion(lineStart, deleteLength);
8261
+ this.adjustExtmarksAfterDeletion(start, end - start);
8280
8262
  });
8281
8263
  }
8282
8264
  wrapInsertion() {
@@ -8467,15 +8449,11 @@ class ExtmarksController2 {
8467
8449
  }
8468
8450
  updateHighlights() {
8469
8451
  this.editBuffer.clearAllHighlights();
8470
- let text;
8471
8452
  for (const extmark of this.extmarks.values()) {
8472
8453
  if (extmark.styleId !== undefined) {
8473
- text ??= this.editBuffer.getText();
8474
- const startWithoutNewlines = this.offsetExcludingNewlines(extmark.start, text);
8475
- const endWithoutNewlines = this.offsetExcludingNewlines(extmark.end, text);
8476
8454
  this.editBuffer.addHighlightByCharRange({
8477
- start: startWithoutNewlines,
8478
- end: endWithoutNewlines,
8455
+ start: this.offsetExcludingNewlines(extmark.start),
8456
+ end: this.offsetExcludingNewlines(extmark.end),
8479
8457
  styleId: extmark.styleId,
8480
8458
  priority: extmark.priority ?? 0,
8481
8459
  hlRef: extmark.id & 65535
@@ -8483,37 +8461,8 @@ class ExtmarksController2 {
8483
8461
  }
8484
8462
  }
8485
8463
  }
8486
- offsetExcludingNewlines(offset, text) {
8487
- let displayWidthSoFar = 0;
8488
- let newlineCount = 0;
8489
- let i = 0;
8490
- while (i < text.length && displayWidthSoFar < offset) {
8491
- if (text[i] === `
8492
- `) {
8493
- displayWidthSoFar++;
8494
- newlineCount++;
8495
- i++;
8496
- } else {
8497
- let j = i;
8498
- while (j < text.length && text[j] !== `
8499
- `) {
8500
- j++;
8501
- }
8502
- const chunk = text.substring(i, j);
8503
- const chunkWidth = stringWidth(chunk);
8504
- if (displayWidthSoFar + chunkWidth < offset) {
8505
- displayWidthSoFar += chunkWidth;
8506
- i = j;
8507
- } else {
8508
- for (let k = i;k < j && displayWidthSoFar < offset; k++) {
8509
- const charWidth = stringWidth(text[k]);
8510
- displayWidthSoFar += charWidth;
8511
- }
8512
- break;
8513
- }
8514
- }
8515
- }
8516
- return offset - newlineCount;
8464
+ offsetExcludingNewlines(offset) {
8465
+ return offset - (this.editBuffer.offsetToPosition(offset)?.row ?? 0);
8517
8466
  }
8518
8467
  create(options) {
8519
8468
  if (this.destroyed) {
@@ -9032,11 +8981,12 @@ function buildTerminalPaletteSignature2(colors) {
9032
8981
 
9033
8982
  // src/lib/paste.ts
9034
8983
  var PASTE_TEXT_DECODER = new TextDecoder;
8984
+ 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;
9035
8985
  function decodePasteBytes2(bytes) {
9036
8986
  return PASTE_TEXT_DECODER.decode(bytes);
9037
8987
  }
9038
8988
  function stripAnsiSequences2(text) {
9039
- return stripANSI(text);
8989
+ return text.replace(ANSI_SEQUENCES, "");
9040
8990
  }
9041
8991
 
9042
8992
  // src/lib/host-clipboard.internal.ts
@@ -13428,6 +13378,10 @@ class EditBuffer2 extends EventEmitter5 {
13428
13378
  getLineStartOffset(row) {
13429
13379
  return this.position(6 /* LineStart */, row)?.offset ?? 0;
13430
13380
  }
13381
+ measureText(text) {
13382
+ this.guard();
13383
+ return this.lib.contextEditBufferMeasureText(this.native.handle.context, this.native.handle, this.lib.encoder.encode(text));
13384
+ }
13431
13385
  getTextRange(startOffset, endOffset) {
13432
13386
  this.guard();
13433
13387
  if (startOffset >= endOffset)
@@ -24909,5 +24863,5 @@ Captured external output:
24909
24863
 
24910
24864
  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 };
24911
24865
 
24912
- //# debugId=F60FFBDDA6EDFB1964756E2164756E21
24913
- //# sourceMappingURL=chunk-node-hjr2tm60.js.map
24866
+ //# debugId=E07A36EC189ECB8064756E2164756E21
24867
+ //# sourceMappingURL=chunk-node-jh6t3wnm.js.map