ccstatusline 2.0.11 → 2.0.12
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/README.md +6 -0
- package/dist/ccstatusline.js +126 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,6 +44,12 @@
|
|
|
44
44
|
|
|
45
45
|
## 🆕 Recent Updates
|
|
46
46
|
|
|
47
|
+
### v2.0.12 - Custom Text widget now supports emojis
|
|
48
|
+
|
|
49
|
+
- **👾 Emoji Support** - You can now paste emoji into the custom text widget. You can also turn on the merge option to get emoji labels for your widgets like this:
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
47
53
|
### v2.0.11 - Unlimited Status Lines
|
|
48
54
|
|
|
49
55
|
- **🚀 No Line Limit** - Configure as many status lines as you need - the 3-line limitation has been removed
|
package/dist/ccstatusline.js
CHANGED
|
@@ -51374,7 +51374,7 @@ import { execSync as execSync3 } from "child_process";
|
|
|
51374
51374
|
import * as fs5 from "fs";
|
|
51375
51375
|
import * as path4 from "path";
|
|
51376
51376
|
var __dirname = "/Users/sirmalloc/Projects/Personal/ccstatusline/src/utils";
|
|
51377
|
-
var PACKAGE_VERSION = "2.0.
|
|
51377
|
+
var PACKAGE_VERSION = "2.0.12";
|
|
51378
51378
|
function getPackageVersion() {
|
|
51379
51379
|
if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
|
|
51380
51380
|
return PACKAGE_VERSION;
|
|
@@ -52619,15 +52619,35 @@ function renderPowerlineStatusLine(widgets, settings, context, lineIndex = 0, gl
|
|
|
52619
52619
|
return "";
|
|
52620
52620
|
const autoAlign = config2.autoAlign;
|
|
52621
52621
|
if (autoAlign) {
|
|
52622
|
+
let alignmentPos = 0;
|
|
52622
52623
|
for (let i = 0;i < widgetElements.length; i++) {
|
|
52623
52624
|
const element = widgetElements[i];
|
|
52624
|
-
|
|
52625
|
-
|
|
52626
|
-
|
|
52627
|
-
|
|
52628
|
-
|
|
52629
|
-
|
|
52625
|
+
if (!element)
|
|
52626
|
+
continue;
|
|
52627
|
+
const prevWidget = i > 0 ? widgetElements[i - 1] : null;
|
|
52628
|
+
const isPreviousMerged = prevWidget?.widget.merge;
|
|
52629
|
+
if (!isPreviousMerged) {
|
|
52630
|
+
const maxWidth = preCalculatedMaxWidths[alignmentPos];
|
|
52631
|
+
if (maxWidth !== undefined) {
|
|
52632
|
+
let combinedLength = stringWidth(element.content.replace(ANSI_REGEX, ""));
|
|
52633
|
+
let j = i;
|
|
52634
|
+
while (j < widgetElements.length - 1 && widgetElements[j]?.widget.merge) {
|
|
52635
|
+
j++;
|
|
52636
|
+
const nextElement = widgetElements[j];
|
|
52637
|
+
if (nextElement) {
|
|
52638
|
+
combinedLength += stringWidth(nextElement.content.replace(ANSI_REGEX, ""));
|
|
52639
|
+
}
|
|
52640
|
+
}
|
|
52641
|
+
const paddingNeeded = maxWidth - combinedLength;
|
|
52642
|
+
if (paddingNeeded > 0) {
|
|
52643
|
+
const lastElement = widgetElements[j];
|
|
52644
|
+
if (lastElement) {
|
|
52645
|
+
lastElement.content += " ".repeat(paddingNeeded);
|
|
52646
|
+
}
|
|
52647
|
+
}
|
|
52648
|
+
i = j;
|
|
52630
52649
|
}
|
|
52650
|
+
alignmentPos++;
|
|
52631
52651
|
}
|
|
52632
52652
|
}
|
|
52633
52653
|
}
|
|
@@ -52826,17 +52846,32 @@ function calculateMaxWidthsFromPreRendered(preRenderedLines, settings) {
|
|
|
52826
52846
|
const paddingLength = defaultPadding.length;
|
|
52827
52847
|
for (const preRenderedLine of preRenderedLines) {
|
|
52828
52848
|
const filteredWidgets = preRenderedLine.filter((w) => w.widget.type !== "separator" && w.widget.type !== "flex-separator" && w.content);
|
|
52829
|
-
|
|
52830
|
-
|
|
52849
|
+
let alignmentPos = 0;
|
|
52850
|
+
for (let i = 0;i < filteredWidgets.length; i++) {
|
|
52851
|
+
const widget = filteredWidgets[i];
|
|
52831
52852
|
if (!widget)
|
|
52832
52853
|
continue;
|
|
52833
|
-
|
|
52834
|
-
|
|
52854
|
+
let totalWidth = widget.plainLength + paddingLength * 2;
|
|
52855
|
+
let j = i;
|
|
52856
|
+
while (j < filteredWidgets.length - 1 && filteredWidgets[j]?.widget.merge) {
|
|
52857
|
+
j++;
|
|
52858
|
+
const nextWidget = filteredWidgets[j];
|
|
52859
|
+
if (nextWidget) {
|
|
52860
|
+
if (filteredWidgets[j - 1]?.widget.merge === "no-padding") {
|
|
52861
|
+
totalWidth += nextWidget.plainLength;
|
|
52862
|
+
} else {
|
|
52863
|
+
totalWidth += nextWidget.plainLength + paddingLength * 2;
|
|
52864
|
+
}
|
|
52865
|
+
}
|
|
52866
|
+
}
|
|
52867
|
+
const currentMax = maxWidths[alignmentPos];
|
|
52835
52868
|
if (currentMax === undefined) {
|
|
52836
|
-
maxWidths[
|
|
52869
|
+
maxWidths[alignmentPos] = totalWidth;
|
|
52837
52870
|
} else {
|
|
52838
|
-
maxWidths[
|
|
52871
|
+
maxWidths[alignmentPos] = Math.max(currentMax, totalWidth);
|
|
52839
52872
|
}
|
|
52873
|
+
i = j;
|
|
52874
|
+
alignmentPos++;
|
|
52840
52875
|
}
|
|
52841
52876
|
}
|
|
52842
52877
|
return maxWidths;
|
|
@@ -53481,49 +53516,107 @@ class CustomTextWidget {
|
|
|
53481
53516
|
var CustomTextEditor = ({ widget, onComplete, onCancel }) => {
|
|
53482
53517
|
const [text, setText] = import_react29.useState(widget.customText ?? "");
|
|
53483
53518
|
const [cursorPos, setCursorPos] = import_react29.useState(text.length);
|
|
53519
|
+
const getGraphemes = (str) => {
|
|
53520
|
+
if ("Segmenter" in Intl) {
|
|
53521
|
+
const segmenter2 = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
53522
|
+
return Array.from(segmenter2.segment(str), (seg) => seg.segment);
|
|
53523
|
+
}
|
|
53524
|
+
return Array.from(str);
|
|
53525
|
+
};
|
|
53526
|
+
const graphemeToStringIndex = (str, graphemeIndex) => {
|
|
53527
|
+
const graphemes2 = getGraphemes(str);
|
|
53528
|
+
let stringIndex = 0;
|
|
53529
|
+
for (let i = 0;i < Math.min(graphemeIndex, graphemes2.length); i++) {
|
|
53530
|
+
const grapheme = graphemes2[i];
|
|
53531
|
+
if (grapheme) {
|
|
53532
|
+
stringIndex += grapheme.length;
|
|
53533
|
+
}
|
|
53534
|
+
}
|
|
53535
|
+
return stringIndex;
|
|
53536
|
+
};
|
|
53537
|
+
const stringToGraphemeIndex = (str, stringIndex) => {
|
|
53538
|
+
const graphemes2 = getGraphemes(str);
|
|
53539
|
+
let currentStringIndex = 0;
|
|
53540
|
+
for (let i = 0;i < graphemes2.length; i++) {
|
|
53541
|
+
if (currentStringIndex >= stringIndex)
|
|
53542
|
+
return i;
|
|
53543
|
+
const grapheme = graphemes2[i];
|
|
53544
|
+
if (grapheme) {
|
|
53545
|
+
currentStringIndex += grapheme.length;
|
|
53546
|
+
}
|
|
53547
|
+
}
|
|
53548
|
+
return graphemes2.length;
|
|
53549
|
+
};
|
|
53484
53550
|
use_input_default((input, key) => {
|
|
53485
53551
|
if (key.return) {
|
|
53486
53552
|
onComplete({ ...widget, customText: text });
|
|
53487
53553
|
} else if (key.escape) {
|
|
53488
53554
|
onCancel();
|
|
53489
53555
|
} else if (key.leftArrow) {
|
|
53490
|
-
|
|
53556
|
+
const currentGraphemeIndex2 = stringToGraphemeIndex(text, cursorPos);
|
|
53557
|
+
if (currentGraphemeIndex2 > 0) {
|
|
53558
|
+
const newStringIndex = graphemeToStringIndex(text, currentGraphemeIndex2 - 1);
|
|
53559
|
+
setCursorPos(newStringIndex);
|
|
53560
|
+
}
|
|
53491
53561
|
} else if (key.rightArrow) {
|
|
53492
|
-
|
|
53562
|
+
const currentGraphemeIndex2 = stringToGraphemeIndex(text, cursorPos);
|
|
53563
|
+
const graphemeCount = getGraphemes(text).length;
|
|
53564
|
+
if (currentGraphemeIndex2 < graphemeCount) {
|
|
53565
|
+
const newStringIndex = graphemeToStringIndex(text, currentGraphemeIndex2 + 1);
|
|
53566
|
+
setCursorPos(newStringIndex);
|
|
53567
|
+
}
|
|
53493
53568
|
} else if (key.ctrl && input === "ArrowLeft") {
|
|
53494
53569
|
setCursorPos(0);
|
|
53495
53570
|
} else if (key.ctrl && input === "ArrowRight") {
|
|
53496
53571
|
setCursorPos(text.length);
|
|
53497
53572
|
} else if (key.backspace) {
|
|
53498
53573
|
if (cursorPos > 0) {
|
|
53499
|
-
|
|
53500
|
-
|
|
53574
|
+
const currentGraphemeIndex2 = stringToGraphemeIndex(text, cursorPos);
|
|
53575
|
+
if (currentGraphemeIndex2 > 0) {
|
|
53576
|
+
const deleteFromIndex = graphemeToStringIndex(text, currentGraphemeIndex2 - 1);
|
|
53577
|
+
const deleteToIndex = graphemeToStringIndex(text, currentGraphemeIndex2);
|
|
53578
|
+
setText(text.slice(0, deleteFromIndex) + text.slice(deleteToIndex));
|
|
53579
|
+
setCursorPos(deleteFromIndex);
|
|
53580
|
+
}
|
|
53501
53581
|
}
|
|
53502
53582
|
} else if (key.delete) {
|
|
53503
53583
|
if (cursorPos < text.length) {
|
|
53504
|
-
|
|
53584
|
+
const currentGraphemeIndex2 = stringToGraphemeIndex(text, cursorPos);
|
|
53585
|
+
const graphemeCount = getGraphemes(text).length;
|
|
53586
|
+
if (currentGraphemeIndex2 < graphemeCount) {
|
|
53587
|
+
const deleteFromIndex = graphemeToStringIndex(text, currentGraphemeIndex2);
|
|
53588
|
+
const deleteToIndex = graphemeToStringIndex(text, currentGraphemeIndex2 + 1);
|
|
53589
|
+
setText(text.slice(0, deleteFromIndex) + text.slice(deleteToIndex));
|
|
53590
|
+
}
|
|
53505
53591
|
}
|
|
53506
|
-
} else if (input &&
|
|
53507
|
-
|
|
53508
|
-
|
|
53592
|
+
} else if (input && !key.ctrl && !key.meta) {
|
|
53593
|
+
const newText = text.slice(0, cursorPos) + input + text.slice(cursorPos);
|
|
53594
|
+
setText(newText);
|
|
53595
|
+
setCursorPos(cursorPos + input.length);
|
|
53509
53596
|
}
|
|
53510
53597
|
});
|
|
53598
|
+
const graphemes = getGraphemes(text);
|
|
53599
|
+
const currentGraphemeIndex = stringToGraphemeIndex(text, cursorPos);
|
|
53600
|
+
let display = "Enter custom text: ";
|
|
53601
|
+
for (let i = 0;i < graphemes.length; i++) {
|
|
53602
|
+
const grapheme = graphemes[i];
|
|
53603
|
+
if (grapheme) {
|
|
53604
|
+
if (i === currentGraphemeIndex) {
|
|
53605
|
+
display += `\x1B[7m${grapheme}\x1B[0m`;
|
|
53606
|
+
} else {
|
|
53607
|
+
display += grapheme;
|
|
53608
|
+
}
|
|
53609
|
+
}
|
|
53610
|
+
}
|
|
53611
|
+
if (currentGraphemeIndex >= graphemes.length) {
|
|
53612
|
+
display += "\x1B[7m \x1B[0m";
|
|
53613
|
+
}
|
|
53511
53614
|
return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
53512
53615
|
flexDirection: "column",
|
|
53513
53616
|
children: [
|
|
53514
53617
|
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
53515
|
-
children:
|
|
53516
|
-
|
|
53517
|
-
" ",
|
|
53518
|
-
text.slice(0, cursorPos),
|
|
53519
|
-
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
53520
|
-
backgroundColor: "gray",
|
|
53521
|
-
color: "black",
|
|
53522
|
-
children: text[cursorPos] ?? " "
|
|
53523
|
-
}, undefined, false, undefined, this),
|
|
53524
|
-
text.slice(cursorPos + 1)
|
|
53525
|
-
]
|
|
53526
|
-
}, undefined, true, undefined, this),
|
|
53618
|
+
children: display
|
|
53619
|
+
}, undefined, false, undefined, this),
|
|
53527
53620
|
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
53528
53621
|
dimColor: true,
|
|
53529
53622
|
children: "←→ move cursor, Ctrl+←→ jump to start/end, Enter save, ESC cancel"
|