ccstatusline-zh 2.2.32 → 2.2.33
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 +11 -9
- package/dist/{ccstatusline-xsgtxzjt.js → ccstatusline-3tcnryv5.js} +18547 -17878
- package/dist/{ccstatusline-s1q4ap7d.js → ccstatusline-rdsx5ab1.js} +16 -12
- package/dist/ccstatusline.js +38 -21
- package/dist/{hooks-z0173m0m.js → hooks-q322knq1.js} +2 -2
- package/dist/{index-3881ds5x.js → index-d0c2je2n.js} +241 -126
- package/package.json +1 -1
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
Transform,
|
|
42
42
|
use_input_default,
|
|
43
43
|
use_app_default,
|
|
44
|
+
getPlainInput,
|
|
44
45
|
shouldInsertInput,
|
|
45
46
|
require_jsx_runtime,
|
|
46
47
|
useTextCursor,
|
|
@@ -81,11 +82,12 @@ import {
|
|
|
81
82
|
validateImportFile,
|
|
82
83
|
applyImport,
|
|
83
84
|
saveInstallationMetadata
|
|
84
|
-
} from "./ccstatusline-
|
|
85
|
+
} from "./ccstatusline-3tcnryv5.js";
|
|
85
86
|
import {
|
|
87
|
+
assignPowerlineThemeSlots,
|
|
86
88
|
advanceGlobalPowerlineThemeIndex,
|
|
87
89
|
advanceGlobalSeparatorIndex
|
|
88
|
-
} from "./ccstatusline-
|
|
90
|
+
} from "./ccstatusline-rdsx5ab1.js";
|
|
89
91
|
import {
|
|
90
92
|
__toESM,
|
|
91
93
|
__commonJS
|
|
@@ -2542,7 +2544,10 @@ function openExternalUrl(url) {
|
|
|
2542
2544
|
}
|
|
2543
2545
|
|
|
2544
2546
|
// src/utils/powerline.ts
|
|
2545
|
-
import {
|
|
2547
|
+
import {
|
|
2548
|
+
execFileSync as execFileSync3,
|
|
2549
|
+
execSync
|
|
2550
|
+
} from "node:child_process";
|
|
2546
2551
|
import * as fs2 from "node:fs";
|
|
2547
2552
|
import * as os3 from "node:os";
|
|
2548
2553
|
import * as path2 from "node:path";
|
|
@@ -2674,12 +2679,9 @@ async function installPowerlineFonts() {
|
|
|
2674
2679
|
if (!fs2.existsSync(fontDir)) {
|
|
2675
2680
|
fs2.mkdirSync(fontDir, { recursive: true });
|
|
2676
2681
|
}
|
|
2677
|
-
const tempDir = path2.join(os3.tmpdir(),
|
|
2682
|
+
const tempDir = fs2.mkdtempSync(path2.join(os3.tmpdir(), "ccstatusline-powerline-fonts-"));
|
|
2678
2683
|
try {
|
|
2679
|
-
|
|
2680
|
-
fs2.rmSync(tempDir, { recursive: true, force: true });
|
|
2681
|
-
}
|
|
2682
|
-
execSync(`git clone --depth=1 https://github.com/powerline/fonts.git "${tempDir}"`, {
|
|
2684
|
+
execFileSync3("git", ["clone", "--depth=1", "https://github.com/powerline/fonts.git", tempDir], {
|
|
2683
2685
|
stdio: "pipe",
|
|
2684
2686
|
encoding: "utf8",
|
|
2685
2687
|
windowsHide: true
|
|
@@ -2688,10 +2690,10 @@ async function installPowerlineFonts() {
|
|
|
2688
2690
|
const installScript = path2.join(tempDir, "install.sh");
|
|
2689
2691
|
if (fs2.existsSync(installScript)) {
|
|
2690
2692
|
fs2.chmodSync(installScript, 493);
|
|
2691
|
-
|
|
2693
|
+
execFileSync3(installScript, [], {
|
|
2694
|
+
cwd: tempDir,
|
|
2692
2695
|
stdio: "pipe",
|
|
2693
2696
|
encoding: "utf8",
|
|
2694
|
-
shell: "/bin/bash",
|
|
2695
2697
|
windowsHide: true
|
|
2696
2698
|
});
|
|
2697
2699
|
if (platform === "linux") {
|
|
@@ -2780,6 +2782,10 @@ import * as https from "node:https";
|
|
|
2780
2782
|
var NPM_REGISTRY_LATEST_URL = "https://registry.npmjs.org/ccstatusline-zh/latest";
|
|
2781
2783
|
var DEFAULT_REGISTRY_TIMEOUT_MS = 5000;
|
|
2782
2784
|
var GLOBAL_UPDATE_TIMEOUT_MS = 120000;
|
|
2785
|
+
var RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
2786
|
+
function isReleaseVersion(version) {
|
|
2787
|
+
return RELEASE_VERSION.test(version);
|
|
2788
|
+
}
|
|
2783
2789
|
function parseVersion(version) {
|
|
2784
2790
|
return version.split(/[.-]/).map((part) => {
|
|
2785
2791
|
const parsed = Number.parseInt(part, 10);
|
|
@@ -2900,6 +2906,9 @@ async function checkForUpdates({
|
|
|
2900
2906
|
}) {
|
|
2901
2907
|
try {
|
|
2902
2908
|
const latestVersion = await latestVersionFetcher(timeoutMs);
|
|
2909
|
+
if (!isReleaseVersion(latestVersion)) {
|
|
2910
|
+
throw new Error("npm 仓库返回了无效的版本号");
|
|
2911
|
+
}
|
|
2903
2912
|
return buildUpdateCheckResult({
|
|
2904
2913
|
currentVersion,
|
|
2905
2914
|
latestVersion,
|
|
@@ -2955,6 +2964,9 @@ function fetchLatestNpmVersion(timeoutMs = DEFAULT_REGISTRY_TIMEOUT_MS) {
|
|
|
2955
2964
|
});
|
|
2956
2965
|
}
|
|
2957
2966
|
function runGlobalPackageInstall(packageManager, version, { platform = process.platform } = {}) {
|
|
2967
|
+
if (!isReleaseVersion(version)) {
|
|
2968
|
+
return Promise.reject(new Error("不是有效的 ccstatusline-zh 发布版本"));
|
|
2969
|
+
}
|
|
2958
2970
|
const executable = getPackageManagerExecutable(packageManager, platform);
|
|
2959
2971
|
const args = packageManager === "npm" ? ["install", "-g", `ccstatusline-zh@${version}`] : ["add", "-g", `ccstatusline-zh@${version}`];
|
|
2960
2972
|
return new Promise((resolve, reject) => {
|
|
@@ -3531,9 +3543,9 @@ var CONFIRM_OPTIONS = [
|
|
|
3531
3543
|
value: false
|
|
3532
3544
|
}
|
|
3533
3545
|
];
|
|
3534
|
-
var ConfirmDialog = ({ message, onConfirm, onCancel, inline = false }) => {
|
|
3546
|
+
var ConfirmDialog = ({ message, onConfirm, onCancel, inline = false, busy = false }) => {
|
|
3535
3547
|
use_input_default((_, key) => {
|
|
3536
|
-
if (key.escape) {
|
|
3548
|
+
if (key.escape && !busy) {
|
|
3537
3549
|
onCancel();
|
|
3538
3550
|
}
|
|
3539
3551
|
});
|
|
@@ -3558,7 +3570,10 @@ var ConfirmDialog = ({ message, onConfirm, onCancel, inline = false }) => {
|
|
|
3558
3570
|
}),
|
|
3559
3571
|
/* @__PURE__ */ jsx_runtime2.jsx(Box_default, {
|
|
3560
3572
|
marginTop: 1,
|
|
3561
|
-
children: /* @__PURE__ */ jsx_runtime2.jsx(
|
|
3573
|
+
children: busy ? /* @__PURE__ */ jsx_runtime2.jsx(Text, {
|
|
3574
|
+
color: "yellow",
|
|
3575
|
+
children: "正在处理,请稍候..."
|
|
3576
|
+
}) : /* @__PURE__ */ jsx_runtime2.jsx(List, {
|
|
3562
3577
|
items: CONFIRM_OPTIONS,
|
|
3563
3578
|
onSelect: (confirmed) => {
|
|
3564
3579
|
if (confirmed) {
|
|
@@ -3623,7 +3638,6 @@ function resetWidgetStyling(widgets, widgetId) {
|
|
|
3623
3638
|
backgroundColor,
|
|
3624
3639
|
bold,
|
|
3625
3640
|
dim,
|
|
3626
|
-
numberFormat,
|
|
3627
3641
|
...restWidget
|
|
3628
3642
|
} = widget;
|
|
3629
3643
|
return restWidget;
|
|
@@ -3636,7 +3650,6 @@ function clearAllWidgetStyling(widgets) {
|
|
|
3636
3650
|
backgroundColor,
|
|
3637
3651
|
bold,
|
|
3638
3652
|
dim,
|
|
3639
|
-
numberFormat,
|
|
3640
3653
|
...restWidget
|
|
3641
3654
|
} = widget;
|
|
3642
3655
|
return restWidget;
|
|
@@ -3727,6 +3740,7 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3727
3740
|
const [editingBackground, setEditingBackground] = import_react5.useState(false);
|
|
3728
3741
|
const hasNoItems = colorableWidgets.length === 0;
|
|
3729
3742
|
use_input_default((input, key) => {
|
|
3743
|
+
const shortcut = getPlainInput(input, key);
|
|
3730
3744
|
if (hasNoItems) {
|
|
3731
3745
|
onBack();
|
|
3732
3746
|
return;
|
|
@@ -3859,17 +3873,21 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3859
3873
|
} else {
|
|
3860
3874
|
onBack();
|
|
3861
3875
|
}
|
|
3862
|
-
} else if (
|
|
3876
|
+
} else if (key.return) {
|
|
3877
|
+
if (highlightedItemId === "back") {
|
|
3878
|
+
onBack();
|
|
3879
|
+
}
|
|
3880
|
+
} else if (shortcut === "h" || shortcut === "H") {
|
|
3863
3881
|
if (highlightedItemId && highlightedItemId !== "back" && settings.colorLevel === 3) {
|
|
3864
3882
|
setHexInputMode(true);
|
|
3865
3883
|
setHexInput("");
|
|
3866
3884
|
}
|
|
3867
|
-
} else if (
|
|
3885
|
+
} else if (shortcut === "a" || shortcut === "A") {
|
|
3868
3886
|
if (highlightedItemId && highlightedItemId !== "back" && settings.colorLevel === 2) {
|
|
3869
3887
|
setAnsi256InputMode(true);
|
|
3870
3888
|
setAnsi256Input("");
|
|
3871
3889
|
}
|
|
3872
|
-
} else if (
|
|
3890
|
+
} else if (shortcut === "g" || shortcut === "G") {
|
|
3873
3891
|
if (highlightedItemId && highlightedItemId !== "back" && !editingBackground && settings.colorLevel >= 2) {
|
|
3874
3892
|
setGradientMode(true);
|
|
3875
3893
|
setGradientIndex(0);
|
|
@@ -3877,15 +3895,19 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3877
3895
|
setGradientStartHex("");
|
|
3878
3896
|
setGradientHexInput("");
|
|
3879
3897
|
}
|
|
3880
|
-
} else if (
|
|
3898
|
+
} else if (shortcut === "s" || shortcut === "S") {
|
|
3881
3899
|
if (!settings.powerline.enabled && !settings.defaultSeparator) {
|
|
3882
3900
|
setShowSeparators(!showSeparators);
|
|
3901
|
+
const highlightedWidget = colorableWidgets.find((widget) => widget.id === highlightedItemId);
|
|
3902
|
+
if (showSeparators && highlightedWidget?.type === "separator") {
|
|
3903
|
+
setHighlightedItemId(colorableWidgets.find((widget) => widget.type !== "separator")?.id ?? null);
|
|
3904
|
+
}
|
|
3883
3905
|
}
|
|
3884
|
-
} else if (
|
|
3906
|
+
} else if (shortcut === "f" || shortcut === "F") {
|
|
3885
3907
|
if (colorableWidgets.length > 0) {
|
|
3886
3908
|
setEditingBackground(!editingBackground);
|
|
3887
3909
|
}
|
|
3888
|
-
} else if (
|
|
3910
|
+
} else if (shortcut === "b" || shortcut === "B") {
|
|
3889
3911
|
if (highlightedItemId && highlightedItemId !== "back") {
|
|
3890
3912
|
const selectedWidget = colorableWidgets.find((widget) => widget.id === highlightedItemId);
|
|
3891
3913
|
if (selectedWidget) {
|
|
@@ -3893,7 +3915,7 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3893
3915
|
onUpdate(newItems);
|
|
3894
3916
|
}
|
|
3895
3917
|
}
|
|
3896
|
-
} else if (
|
|
3918
|
+
} else if (shortcut === "d" || shortcut === "D") {
|
|
3897
3919
|
if (highlightedItemId && highlightedItemId !== "back") {
|
|
3898
3920
|
const selectedWidget = colorableWidgets.find((widget) => widget.id === highlightedItemId);
|
|
3899
3921
|
if (selectedWidget) {
|
|
@@ -3901,7 +3923,7 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3901
3923
|
onUpdate(newItems);
|
|
3902
3924
|
}
|
|
3903
3925
|
}
|
|
3904
|
-
} else if (
|
|
3926
|
+
} else if (shortcut === "r" || shortcut === "R") {
|
|
3905
3927
|
if (highlightedItemId && highlightedItemId !== "back") {
|
|
3906
3928
|
const selectedWidget = colorableWidgets.find((widget) => widget.id === highlightedItemId);
|
|
3907
3929
|
if (selectedWidget) {
|
|
@@ -3909,7 +3931,7 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3909
3931
|
onUpdate(newItems);
|
|
3910
3932
|
}
|
|
3911
3933
|
}
|
|
3912
|
-
} else if (
|
|
3934
|
+
} else if (shortcut === "c" || shortcut === "C") {
|
|
3913
3935
|
setShowClearConfirm(true);
|
|
3914
3936
|
} else if (key.leftArrow || key.rightArrow) {
|
|
3915
3937
|
if (highlightedItemId && highlightedItemId !== "back") {
|
|
@@ -3991,11 +4013,6 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3991
4013
|
};
|
|
3992
4014
|
});
|
|
3993
4015
|
menuItems.push({ label: "← 返回", value: "back" });
|
|
3994
|
-
const handleSelect = (selected) => {
|
|
3995
|
-
if (selected.value === "back") {
|
|
3996
|
-
onBack();
|
|
3997
|
-
}
|
|
3998
|
-
};
|
|
3999
4016
|
const handleHighlight = (item) => {
|
|
4000
4017
|
setHighlightedItemId(item.value);
|
|
4001
4018
|
};
|
|
@@ -4322,7 +4339,6 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
4322
4339
|
}, item.value))
|
|
4323
4340
|
}) : /* @__PURE__ */ jsx_runtime3.jsx(SelectInput_default, {
|
|
4324
4341
|
items: menuItems,
|
|
4325
|
-
onSelect: handleSelect,
|
|
4326
4342
|
onHighlight: handleHighlight,
|
|
4327
4343
|
initialIndex: Math.max(0, menuItems.findIndex((item) => item.value === highlightedItemId)),
|
|
4328
4344
|
indicatorComponent: ({ isSelected }) => /* @__PURE__ */ jsx_runtime3.jsx(Text, {
|
|
@@ -4472,6 +4488,9 @@ function getImportPreviewKeys(current, imported) {
|
|
|
4472
4488
|
function getImportPreviewSettings(current, validation, mode) {
|
|
4473
4489
|
return applyImport(current, validation.data, mode, validation.presentKeys);
|
|
4474
4490
|
}
|
|
4491
|
+
function escapeControlCharacters(text) {
|
|
4492
|
+
return text.replace(/[\x00-\x1f\x7f-\x9f]/g, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
4493
|
+
}
|
|
4475
4494
|
function formatScalar(value) {
|
|
4476
4495
|
if (value === null || value === undefined) {
|
|
4477
4496
|
return "无";
|
|
@@ -4480,9 +4499,16 @@ function formatScalar(value) {
|
|
|
4480
4499
|
return String(value);
|
|
4481
4500
|
}
|
|
4482
4501
|
if (typeof value === "string") {
|
|
4483
|
-
return value || "(空)";
|
|
4502
|
+
return escapeControlCharacters(value) || "(空)";
|
|
4484
4503
|
}
|
|
4485
|
-
return JSON.stringify(value);
|
|
4504
|
+
return escapeControlCharacters(JSON.stringify(value));
|
|
4505
|
+
}
|
|
4506
|
+
function getCustomCommands(settings) {
|
|
4507
|
+
return settings.lines.flat().filter((widget) => widget.type === "custom-command" && widget.commandPath).map((widget) => widget.commandPath ?? "");
|
|
4508
|
+
}
|
|
4509
|
+
function getImportedCommands(current, preview) {
|
|
4510
|
+
const existing = new Set(getCustomCommands(current));
|
|
4511
|
+
return [...new Set(getCustomCommands(preview).filter((command) => !existing.has(command)))];
|
|
4486
4512
|
}
|
|
4487
4513
|
function diffObject(current, imported, prefix) {
|
|
4488
4514
|
const keys = new Set([...Object.keys(current), ...Object.keys(imported)]);
|
|
@@ -4547,8 +4573,10 @@ function ImportPreviewDialog({
|
|
|
4547
4573
|
onCancel
|
|
4548
4574
|
}) {
|
|
4549
4575
|
const [previewMode, setPreviewMode] = import_react8.useState("replace");
|
|
4576
|
+
const [pendingMode, setPendingMode] = import_react8.useState(null);
|
|
4550
4577
|
const previewSettings = getImportPreviewSettings(currentSettings, validation, previewMode);
|
|
4551
4578
|
const topLevelKeys = getImportPreviewKeys(currentSettings, previewSettings);
|
|
4579
|
+
const importedCommands = getImportedCommands(currentSettings, previewSettings);
|
|
4552
4580
|
const items = [
|
|
4553
4581
|
{ label: "全部替换", value: "replace", description: "使用导入的配置覆盖所有设置" },
|
|
4554
4582
|
{ label: "合并", value: "merge", description: "将导入的设置覆盖到当前设置之上" },
|
|
@@ -4558,9 +4586,51 @@ function ImportPreviewDialog({
|
|
|
4558
4586
|
function handleSelect(value) {
|
|
4559
4587
|
if (value === "cancel" || value === "back") {
|
|
4560
4588
|
onCancel();
|
|
4561
|
-
|
|
4562
|
-
onApply(value);
|
|
4589
|
+
return;
|
|
4563
4590
|
}
|
|
4591
|
+
const commands = getImportedCommands(currentSettings, getImportPreviewSettings(currentSettings, validation, value));
|
|
4592
|
+
if (commands.length > 0) {
|
|
4593
|
+
setPendingMode(value);
|
|
4594
|
+
return;
|
|
4595
|
+
}
|
|
4596
|
+
onApply(value);
|
|
4597
|
+
}
|
|
4598
|
+
if (pendingMode) {
|
|
4599
|
+
const commands = getImportedCommands(currentSettings, getImportPreviewSettings(currentSettings, validation, pendingMode));
|
|
4600
|
+
const confirmItems = [
|
|
4601
|
+
{ label: "取消", value: "cancel", description: "返回预览,不导入配置" },
|
|
4602
|
+
{ label: "应用并运行这些命令", value: "confirm", description: "导入配置,包括上述命令" }
|
|
4603
|
+
];
|
|
4604
|
+
return /* @__PURE__ */ jsx_runtime6.jsxs(Box_default, {
|
|
4605
|
+
flexDirection: "column",
|
|
4606
|
+
children: [
|
|
4607
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4608
|
+
bold: true,
|
|
4609
|
+
children: "导入预览"
|
|
4610
|
+
}),
|
|
4611
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4612
|
+
color: "yellow",
|
|
4613
|
+
children: `是否应用此次导入?它将新增 ${commands.length} 条 Shell 命令,每次渲染状态行时都会运行:`
|
|
4614
|
+
}),
|
|
4615
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Box_default, {
|
|
4616
|
+
flexDirection: "column",
|
|
4617
|
+
marginLeft: 4,
|
|
4618
|
+
children: commands.map((command, index) => /* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4619
|
+
children: `$ ${escapeControlCharacters(command)}`
|
|
4620
|
+
}, index))
|
|
4621
|
+
}),
|
|
4622
|
+
/* @__PURE__ */ jsx_runtime6.jsx(List, {
|
|
4623
|
+
items: confirmItems,
|
|
4624
|
+
onSelect: (choice) => {
|
|
4625
|
+
if (choice === "confirm") {
|
|
4626
|
+
onApply(pendingMode);
|
|
4627
|
+
return;
|
|
4628
|
+
}
|
|
4629
|
+
setPendingMode(null);
|
|
4630
|
+
}
|
|
4631
|
+
})
|
|
4632
|
+
]
|
|
4633
|
+
});
|
|
4564
4634
|
}
|
|
4565
4635
|
function handleSelectionChange(value) {
|
|
4566
4636
|
if (value === "replace" || value === "merge") {
|
|
@@ -4593,7 +4663,7 @@ function ImportPreviewDialog({
|
|
|
4593
4663
|
marginLeft: 4,
|
|
4594
4664
|
children: [
|
|
4595
4665
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4596
|
-
children: `${e.path}: `
|
|
4666
|
+
children: `${escapeControlCharacters(e.path)}: `
|
|
4597
4667
|
}),
|
|
4598
4668
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4599
4669
|
color: "red",
|
|
@@ -4624,7 +4694,7 @@ function ImportPreviewDialog({
|
|
|
4624
4694
|
marginLeft: 4,
|
|
4625
4695
|
children: [
|
|
4626
4696
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4627
|
-
children: `${e.path}: `
|
|
4697
|
+
children: `${escapeControlCharacters(e.path)}: `
|
|
4628
4698
|
}),
|
|
4629
4699
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4630
4700
|
color: "red",
|
|
@@ -4646,7 +4716,7 @@ function ImportPreviewDialog({
|
|
|
4646
4716
|
diffRows.push(/* @__PURE__ */ jsx_runtime6.jsxs(Box_default, {
|
|
4647
4717
|
children: [
|
|
4648
4718
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4649
|
-
children: ` ${key}: `
|
|
4719
|
+
children: ` ${escapeControlCharacters(key)}: `
|
|
4650
4720
|
}),
|
|
4651
4721
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4652
4722
|
color: "red",
|
|
@@ -4677,6 +4747,23 @@ function ImportPreviewDialog({
|
|
|
4677
4747
|
flexDirection: "column",
|
|
4678
4748
|
children: diffRows
|
|
4679
4749
|
}),
|
|
4750
|
+
importedCommands.length > 0 && /* @__PURE__ */ jsx_runtime6.jsxs(Box_default, {
|
|
4751
|
+
flexDirection: "column",
|
|
4752
|
+
marginTop: 1,
|
|
4753
|
+
children: [
|
|
4754
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4755
|
+
color: "yellow",
|
|
4756
|
+
children: "此次导入新增的 Shell 命令将在每次渲染状态行时运行:"
|
|
4757
|
+
}),
|
|
4758
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Box_default, {
|
|
4759
|
+
flexDirection: "column",
|
|
4760
|
+
marginLeft: 4,
|
|
4761
|
+
children: importedCommands.map((command, index) => /* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4762
|
+
children: `$ ${escapeControlCharacters(command)}`
|
|
4763
|
+
}, index))
|
|
4764
|
+
})
|
|
4765
|
+
]
|
|
4766
|
+
}),
|
|
4680
4767
|
/* @__PURE__ */ jsx_runtime6.jsx(List, {
|
|
4681
4768
|
items,
|
|
4682
4769
|
onSelect: handleSelect,
|
|
@@ -4735,6 +4822,7 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4735
4822
|
const currentBgIndex = bgColors.indexOf(settings.overrideBackgroundColor ?? "none");
|
|
4736
4823
|
const currentFgIndex = fgColors.indexOf(settings.overrideForegroundColor ?? "none");
|
|
4737
4824
|
use_input_default((input, key) => {
|
|
4825
|
+
const shortcut = getPlainInput(input, key);
|
|
4738
4826
|
if (editingPadding) {
|
|
4739
4827
|
if (key.return) {
|
|
4740
4828
|
const updatedSettings = {
|
|
@@ -4845,11 +4933,11 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4845
4933
|
} else {
|
|
4846
4934
|
if (key.escape) {
|
|
4847
4935
|
onBack();
|
|
4848
|
-
} else if (
|
|
4936
|
+
} else if (shortcut === "p" || shortcut === "P") {
|
|
4849
4937
|
setEditingPadding(true);
|
|
4850
|
-
} else if ((
|
|
4938
|
+
} else if ((shortcut === "s" || shortcut === "S") && !isPowerlineEnabled) {
|
|
4851
4939
|
setEditingSeparator(true);
|
|
4852
|
-
} else if ((
|
|
4940
|
+
} else if ((shortcut === "i" || shortcut === "I") && !isPowerlineEnabled) {
|
|
4853
4941
|
const newInheritColors = !inheritColors;
|
|
4854
4942
|
setInheritColors(newInheritColors);
|
|
4855
4943
|
const updatedSettings = {
|
|
@@ -4857,7 +4945,7 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4857
4945
|
inheritSeparatorColors: newInheritColors
|
|
4858
4946
|
};
|
|
4859
4947
|
onUpdate(updatedSettings);
|
|
4860
|
-
} else if ((
|
|
4948
|
+
} else if ((shortcut === "b" || shortcut === "B") && !isPowerlineEnabled) {
|
|
4861
4949
|
const nextIndex = (currentBgIndex + 1) % bgColors.length;
|
|
4862
4950
|
const nextBgColor = bgColors[nextIndex];
|
|
4863
4951
|
const updatedSettings = {
|
|
@@ -4865,13 +4953,13 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4865
4953
|
overrideBackgroundColor: nextBgColor === "none" ? undefined : nextBgColor
|
|
4866
4954
|
};
|
|
4867
4955
|
onUpdate(updatedSettings);
|
|
4868
|
-
} else if ((
|
|
4956
|
+
} else if ((shortcut === "c" || shortcut === "C") && !isPowerlineEnabled) {
|
|
4869
4957
|
const updatedSettings = {
|
|
4870
4958
|
...settings,
|
|
4871
4959
|
overrideBackgroundColor: undefined
|
|
4872
4960
|
};
|
|
4873
4961
|
onUpdate(updatedSettings);
|
|
4874
|
-
} else if (
|
|
4962
|
+
} else if (shortcut === "o" || shortcut === "O") {
|
|
4875
4963
|
const newGlobalBold = !globalBold;
|
|
4876
4964
|
setGlobalBold(newGlobalBold);
|
|
4877
4965
|
const updatedSettings = {
|
|
@@ -4879,7 +4967,7 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4879
4967
|
globalBold: newGlobalBold
|
|
4880
4968
|
};
|
|
4881
4969
|
onUpdate(updatedSettings);
|
|
4882
|
-
} else if (
|
|
4970
|
+
} else if (shortcut === "m" || shortcut === "M") {
|
|
4883
4971
|
const newMinimalistMode = !minimalistMode;
|
|
4884
4972
|
setMinimalistMode(newMinimalistMode);
|
|
4885
4973
|
const updatedSettings = {
|
|
@@ -4887,10 +4975,10 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4887
4975
|
minimalistMode: newMinimalistMode
|
|
4888
4976
|
};
|
|
4889
4977
|
onUpdate(updatedSettings);
|
|
4890
|
-
} else if (
|
|
4978
|
+
} else if (shortcut === "n" || shortcut === "N") {
|
|
4891
4979
|
setNumberFormatMode(true);
|
|
4892
4980
|
setNumberFormatKindIndex(0);
|
|
4893
|
-
} else if (
|
|
4981
|
+
} else if (shortcut === "f" || shortcut === "F") {
|
|
4894
4982
|
const nextIndex = (currentFgIndex + 1) % fgColors.length;
|
|
4895
4983
|
const nextFgColor = fgColors[nextIndex];
|
|
4896
4984
|
const updatedSettings = {
|
|
@@ -4898,19 +4986,19 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4898
4986
|
overrideForegroundColor: nextFgColor === "none" ? undefined : nextFgColor
|
|
4899
4987
|
};
|
|
4900
4988
|
onUpdate(updatedSettings);
|
|
4901
|
-
} else if (
|
|
4989
|
+
} else if (shortcut === "g" || shortcut === "G") {
|
|
4902
4990
|
setGradientMode(true);
|
|
4903
4991
|
setGradientIndex(0);
|
|
4904
4992
|
setGradientCustomStep(null);
|
|
4905
4993
|
setGradientStartHex("");
|
|
4906
4994
|
setGradientHexInput("");
|
|
4907
|
-
} else if (
|
|
4995
|
+
} else if (shortcut === "x" || shortcut === "X") {
|
|
4908
4996
|
const updatedSettings = {
|
|
4909
4997
|
...settings,
|
|
4910
4998
|
overrideForegroundColor: undefined
|
|
4911
4999
|
};
|
|
4912
5000
|
onUpdate(updatedSettings);
|
|
4913
|
-
} else if (
|
|
5001
|
+
} else if (shortcut === "d" || shortcut === "D") {
|
|
4914
5002
|
const paddingSides = DefaultPaddingSideSchema.options;
|
|
4915
5003
|
const currentIndex = paddingSides.indexOf(settings.defaultPaddingSide);
|
|
4916
5004
|
const nextSide = paddingSides[(currentIndex + 1) % paddingSides.length] ?? "both";
|
|
@@ -5401,6 +5489,7 @@ var HideStatesEditor = ({ widget, states, onComplete, onCancel }) => {
|
|
|
5401
5489
|
const [selectedIndex, setSelectedIndex] = import_react10.useState(0);
|
|
5402
5490
|
const [enabledKeys, setEnabledKeys] = import_react10.useState(() => getEnabledHideStates(widget, states));
|
|
5403
5491
|
use_input_default((input, key) => {
|
|
5492
|
+
const shortcut = getPlainInput(input, key);
|
|
5404
5493
|
if (key.return) {
|
|
5405
5494
|
onComplete(setEnabledHideStates(widget, states, enabledKeys));
|
|
5406
5495
|
} else if (key.escape) {
|
|
@@ -5409,7 +5498,7 @@ var HideStatesEditor = ({ widget, states, onComplete, onCancel }) => {
|
|
|
5409
5498
|
setSelectedIndex(selectedIndex - 1 < 0 ? states.length - 1 : selectedIndex - 1);
|
|
5410
5499
|
} else if (key.downArrow && states.length > 0) {
|
|
5411
5500
|
setSelectedIndex(selectedIndex + 1 > states.length - 1 ? 0 : selectedIndex + 1);
|
|
5412
|
-
} else if (
|
|
5501
|
+
} else if (shortcut === " ") {
|
|
5413
5502
|
const state = states[selectedIndex];
|
|
5414
5503
|
if (state) {
|
|
5415
5504
|
setEnabledKeys(enabledKeys.includes(state.key) ? enabledKeys.filter((enabledKey) => enabledKey !== state.key) : [...enabledKeys, state.key]);
|
|
@@ -5689,6 +5778,16 @@ var LabelEditor = ({ widget, defaultLabel, onComplete, onCancel }) => {
|
|
|
5689
5778
|
});
|
|
5690
5779
|
};
|
|
5691
5780
|
|
|
5781
|
+
// src/utils/move-item.ts
|
|
5782
|
+
function moveItem(items, fromIndex, toIndex) {
|
|
5783
|
+
const moved = [...items];
|
|
5784
|
+
const [item] = moved.splice(fromIndex, 1);
|
|
5785
|
+
if (item !== undefined) {
|
|
5786
|
+
moved.splice(toIndex, 0, item);
|
|
5787
|
+
}
|
|
5788
|
+
return moved;
|
|
5789
|
+
}
|
|
5790
|
+
|
|
5692
5791
|
// src/tui/components/items-editor/input-handlers.ts
|
|
5693
5792
|
function setPickerState(setWidgetPicker, normalizeState, updater) {
|
|
5694
5793
|
setWidgetPicker((prev) => {
|
|
@@ -5872,24 +5971,12 @@ function handleMoveInputMode({
|
|
|
5872
5971
|
setMoveMode
|
|
5873
5972
|
}) {
|
|
5874
5973
|
if (key.upArrow && widgets.length > 1) {
|
|
5875
|
-
const newWidgets = [...widgets];
|
|
5876
5974
|
const targetIndex = selectedIndex - 1 < 0 ? widgets.length - 1 : selectedIndex - 1;
|
|
5877
|
-
|
|
5878
|
-
const prev = newWidgets[targetIndex];
|
|
5879
|
-
if (temp && prev) {
|
|
5880
|
-
[newWidgets[selectedIndex], newWidgets[targetIndex]] = [prev, temp];
|
|
5881
|
-
}
|
|
5882
|
-
onUpdate(newWidgets);
|
|
5975
|
+
onUpdate(moveItem(widgets, selectedIndex, targetIndex));
|
|
5883
5976
|
setSelectedIndex(targetIndex);
|
|
5884
5977
|
} else if (key.downArrow && widgets.length > 1) {
|
|
5885
|
-
const newWidgets = [...widgets];
|
|
5886
5978
|
const targetIndex = selectedIndex + 1 > widgets.length - 1 ? 0 : selectedIndex + 1;
|
|
5887
|
-
|
|
5888
|
-
const next = newWidgets[targetIndex];
|
|
5889
|
-
if (temp && next) {
|
|
5890
|
-
[newWidgets[selectedIndex], newWidgets[targetIndex]] = [next, temp];
|
|
5891
|
-
}
|
|
5892
|
-
onUpdate(newWidgets);
|
|
5979
|
+
onUpdate(moveItem(widgets, selectedIndex, targetIndex));
|
|
5893
5980
|
setSelectedIndex(targetIndex);
|
|
5894
5981
|
} else if (key.escape || key.return) {
|
|
5895
5982
|
setMoveMode(false);
|
|
@@ -5912,6 +5999,7 @@ function handleNormalInputMode({
|
|
|
5912
5999
|
setCustomEditorWidget,
|
|
5913
6000
|
getUniqueBackgroundColor
|
|
5914
6001
|
}) {
|
|
6002
|
+
const shortcut = getPlainInput(input, key);
|
|
5915
6003
|
if (key.upArrow && widgets.length > 0) {
|
|
5916
6004
|
setSelectedIndex(selectedIndex - 1 < 0 ? widgets.length - 1 : selectedIndex - 1);
|
|
5917
6005
|
} else if (key.downArrow && widgets.length > 0) {
|
|
@@ -5922,17 +6010,17 @@ function handleNormalInputMode({
|
|
|
5922
6010
|
openWidgetPicker("change");
|
|
5923
6011
|
} else if (key.return && widgets.length > 0) {
|
|
5924
6012
|
setMoveMode(true);
|
|
5925
|
-
} else if (
|
|
6013
|
+
} else if (shortcut === "a") {
|
|
5926
6014
|
openWidgetPicker("add");
|
|
5927
|
-
} else if (
|
|
6015
|
+
} else if (shortcut === "i") {
|
|
5928
6016
|
openWidgetPicker("insert");
|
|
5929
|
-
} else if (
|
|
6017
|
+
} else if (shortcut === "d" && widgets.length > 0) {
|
|
5930
6018
|
const newWidgets = widgets.filter((_, i) => i !== selectedIndex);
|
|
5931
6019
|
onUpdate(newWidgets);
|
|
5932
6020
|
if (selectedIndex >= newWidgets.length && selectedIndex > 0) {
|
|
5933
6021
|
setSelectedIndex(selectedIndex - 1);
|
|
5934
6022
|
}
|
|
5935
|
-
} else if (
|
|
6023
|
+
} else if (shortcut === "k" && widgets.length > 0) {
|
|
5936
6024
|
const source = widgets[selectedIndex];
|
|
5937
6025
|
if (!source) {
|
|
5938
6026
|
return;
|
|
@@ -5952,11 +6040,11 @@ function handleNormalInputMode({
|
|
|
5952
6040
|
];
|
|
5953
6041
|
onUpdate(newWidgets);
|
|
5954
6042
|
setSelectedIndex(insertIndex);
|
|
5955
|
-
} else if (
|
|
6043
|
+
} else if (shortcut === "c") {
|
|
5956
6044
|
if (widgets.length > 0) {
|
|
5957
6045
|
setShowClearConfirm(true);
|
|
5958
6046
|
}
|
|
5959
|
-
} else if (
|
|
6047
|
+
} else if (shortcut === " " && widgets.length > 0) {
|
|
5960
6048
|
const currentWidget = widgets[selectedIndex];
|
|
5961
6049
|
if (currentWidget?.type === "separator") {
|
|
5962
6050
|
const currentChar = currentWidget.character ?? "|";
|
|
@@ -5966,7 +6054,7 @@ function handleNormalInputMode({
|
|
|
5966
6054
|
newWidgets[selectedIndex] = { ...currentWidget, character: nextChar };
|
|
5967
6055
|
onUpdate(newWidgets);
|
|
5968
6056
|
}
|
|
5969
|
-
} else if (
|
|
6057
|
+
} else if (shortcut === "r" && widgets.length > 0) {
|
|
5970
6058
|
const currentWidget = widgets[selectedIndex];
|
|
5971
6059
|
if (currentWidget && currentWidget.type !== "separator" && currentWidget.type !== "flex-separator") {
|
|
5972
6060
|
const widgetImpl = getWidget(currentWidget.type);
|
|
@@ -5977,14 +6065,15 @@ function handleNormalInputMode({
|
|
|
5977
6065
|
newWidgets[selectedIndex] = { ...currentWidget, rawValue: !currentWidget.rawValue };
|
|
5978
6066
|
onUpdate(newWidgets);
|
|
5979
6067
|
}
|
|
5980
|
-
} else if (
|
|
6068
|
+
} else if (shortcut === "m" && widgets.length > 0) {
|
|
5981
6069
|
const currentWidget = widgets[selectedIndex];
|
|
5982
|
-
|
|
6070
|
+
const isLastWidget = selectedIndex === widgets.length - 1;
|
|
6071
|
+
if (currentWidget && (!isLastWidget || currentWidget.merge) && currentWidget.type !== "separator" && currentWidget.type !== "flex-separator") {
|
|
5983
6072
|
const newWidgets = [...widgets];
|
|
5984
6073
|
let nextMergeState;
|
|
5985
6074
|
if (currentWidget.merge === undefined) {
|
|
5986
6075
|
nextMergeState = true;
|
|
5987
|
-
} else if (currentWidget.merge === true) {
|
|
6076
|
+
} else if (currentWidget.merge === true && !isLastWidget) {
|
|
5988
6077
|
nextMergeState = "no-padding";
|
|
5989
6078
|
} else {
|
|
5990
6079
|
nextMergeState = undefined;
|
|
@@ -5997,7 +6086,7 @@ function handleNormalInputMode({
|
|
|
5997
6086
|
}
|
|
5998
6087
|
onUpdate(newWidgets);
|
|
5999
6088
|
}
|
|
6000
|
-
} else if (
|
|
6089
|
+
} else if (shortcut === "x" && widgets.length > 0) {
|
|
6001
6090
|
const currentWidget = widgets[selectedIndex];
|
|
6002
6091
|
if (canExcludeAlign && currentWidget && currentWidget.type !== "separator" && currentWidget.type !== "flex-separator") {
|
|
6003
6092
|
const newWidgets = [...widgets];
|
|
@@ -6019,8 +6108,8 @@ function handleNormalInputMode({
|
|
|
6019
6108
|
return;
|
|
6020
6109
|
}
|
|
6021
6110
|
const customKeybinds = getCustomKeybindsForWidget(widgetImpl, currentWidget);
|
|
6022
|
-
const matchedKeybind = customKeybinds.find((kb) => kb.key ===
|
|
6023
|
-
if (matchedKeybind
|
|
6111
|
+
const matchedKeybind = customKeybinds.find((kb) => kb.key === shortcut);
|
|
6112
|
+
if (matchedKeybind) {
|
|
6024
6113
|
if (matchedKeybind.action === EDIT_HIDE_STATES_ACTION || matchedKeybind.action === EDIT_LABEL_ACTION) {
|
|
6025
6114
|
setCustomEditorWidget({ widget: currentWidget, impl: widgetImpl, action: matchedKeybind.action });
|
|
6026
6115
|
return;
|
|
@@ -6156,7 +6245,7 @@ var ItemsEditor = ({ widgets, onUpdate, onBack, lineNumber, settings }) => {
|
|
|
6156
6245
|
canToggleRaw = false;
|
|
6157
6246
|
}
|
|
6158
6247
|
}
|
|
6159
|
-
const canMerge = currentWidget && selectedIndex < widgets.length - 1 && !isSeparator && !isFlexSeparator;
|
|
6248
|
+
const canMerge = currentWidget && (selectedIndex < widgets.length - 1 || Boolean(currentWidget.merge)) && !isSeparator && !isFlexSeparator;
|
|
6160
6249
|
const canExcludeAlign = Boolean(currentWidget) && !isSeparator && !isFlexSeparator && settings.powerline.enabled && settings.powerline.autoAlign && !isMergedIntoPreviousWidget(widgets, selectedIndex);
|
|
6161
6250
|
const hasWidgets = widgets.length > 0;
|
|
6162
6251
|
use_input_default((input, key) => {
|
|
@@ -6708,6 +6797,7 @@ var LineSelector = ({
|
|
|
6708
6797
|
const powerlineTheme = settings ? settings.powerline.theme : undefined;
|
|
6709
6798
|
const isThemeManaged = blockIfPowerlineActive && powerlineEnabled && powerlineTheme && powerlineTheme !== "custom";
|
|
6710
6799
|
use_input_default((input, key) => {
|
|
6800
|
+
const shortcut = getPlainInput(input, key);
|
|
6711
6801
|
if (showDeleteDialog) {
|
|
6712
6802
|
return;
|
|
6713
6803
|
}
|
|
@@ -6717,24 +6807,14 @@ var LineSelector = ({
|
|
|
6717
6807
|
}
|
|
6718
6808
|
if (moveMode) {
|
|
6719
6809
|
if (key.upArrow && localLines.length > 1) {
|
|
6720
|
-
const newLines = [...localLines];
|
|
6721
6810
|
const targetIndex = selectedIndex - 1 < 0 ? localLines.length - 1 : selectedIndex - 1;
|
|
6722
|
-
const
|
|
6723
|
-
const prev = newLines[targetIndex];
|
|
6724
|
-
if (temp && prev) {
|
|
6725
|
-
[newLines[selectedIndex], newLines[targetIndex]] = [prev, temp];
|
|
6726
|
-
}
|
|
6811
|
+
const newLines = moveItem(localLines, selectedIndex, targetIndex);
|
|
6727
6812
|
setLocalLines(newLines);
|
|
6728
6813
|
onLinesUpdate(newLines);
|
|
6729
6814
|
setSelectedIndex(targetIndex);
|
|
6730
6815
|
} else if (key.downArrow && localLines.length > 1) {
|
|
6731
|
-
const newLines = [...localLines];
|
|
6732
6816
|
const targetIndex = selectedIndex + 1 > localLines.length - 1 ? 0 : selectedIndex + 1;
|
|
6733
|
-
const
|
|
6734
|
-
const next = newLines[targetIndex];
|
|
6735
|
-
if (temp && next) {
|
|
6736
|
-
[newLines[selectedIndex], newLines[targetIndex]] = [next, temp];
|
|
6737
|
-
}
|
|
6817
|
+
const newLines = moveItem(localLines, selectedIndex, targetIndex);
|
|
6738
6818
|
setLocalLines(newLines);
|
|
6739
6819
|
onLinesUpdate(newLines);
|
|
6740
6820
|
setSelectedIndex(targetIndex);
|
|
@@ -6743,7 +6823,7 @@ var LineSelector = ({
|
|
|
6743
6823
|
}
|
|
6744
6824
|
return;
|
|
6745
6825
|
}
|
|
6746
|
-
switch (
|
|
6826
|
+
switch (shortcut) {
|
|
6747
6827
|
case "a":
|
|
6748
6828
|
if (allowEditing) {
|
|
6749
6829
|
appendLine();
|
|
@@ -7335,7 +7415,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
7335
7415
|
}
|
|
7336
7416
|
};
|
|
7337
7417
|
const separators = getItems();
|
|
7338
|
-
const invertBgs = mode === "separator" ? powerlineConfig.separatorInvertBackground : [];
|
|
7418
|
+
const invertBgs = mode === "separator" ? separators.map((_, i) => powerlineConfig.separatorInvertBackground[i] ?? false) : [];
|
|
7339
7419
|
const [selectedIndex, setSelectedIndex] = import_react14.useState(0);
|
|
7340
7420
|
const [hexInputMode, setHexInputMode] = import_react14.useState(false);
|
|
7341
7421
|
const [hexInput, setHexInput] = import_react14.useState("");
|
|
@@ -7396,6 +7476,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
7396
7476
|
});
|
|
7397
7477
|
};
|
|
7398
7478
|
use_input_default((input, key) => {
|
|
7479
|
+
const shortcut = getPlainInput(input, key);
|
|
7399
7480
|
if (hexInputMode) {
|
|
7400
7481
|
if (key.escape) {
|
|
7401
7482
|
setHexInputMode(false);
|
|
@@ -7458,7 +7539,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
7458
7539
|
newInvertBgs[selectedIndex] = isLeftFacing;
|
|
7459
7540
|
}
|
|
7460
7541
|
updateSeparators(newSeparators, mode === "separator" ? newInvertBgs : undefined);
|
|
7461
|
-
} else if (
|
|
7542
|
+
} else if (shortcut === "a" || shortcut === "A") {
|
|
7462
7543
|
const newSeparators = [...separators];
|
|
7463
7544
|
const newInvertBgs = mode === "separator" ? [...invertBgs] : [];
|
|
7464
7545
|
const defaultChar = presetSeparators[0]?.char ?? "";
|
|
@@ -7478,7 +7559,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
7478
7559
|
updateSeparators(newSeparators, newInvertBgs);
|
|
7479
7560
|
setSelectedIndex(selectedIndex + 1);
|
|
7480
7561
|
}
|
|
7481
|
-
} else if (
|
|
7562
|
+
} else if (shortcut === "i" || shortcut === "I") {
|
|
7482
7563
|
const newSeparators = [...separators];
|
|
7483
7564
|
const newInvertBgs = mode === "separator" ? [...invertBgs] : [];
|
|
7484
7565
|
const defaultChar = presetSeparators[0]?.char ?? "";
|
|
@@ -7497,23 +7578,23 @@ var PowerlineSeparatorEditor = ({
|
|
|
7497
7578
|
}
|
|
7498
7579
|
updateSeparators(newSeparators, newInvertBgs);
|
|
7499
7580
|
}
|
|
7500
|
-
} else if ((
|
|
7581
|
+
} else if ((shortcut === "d" || shortcut === "D") && (mode !== "separator" || separators.length > 1)) {
|
|
7501
7582
|
const newSeparators = separators.filter((_, i) => i !== selectedIndex);
|
|
7502
7583
|
const newInvertBgs = mode === "separator" ? invertBgs.filter((_, i) => i !== selectedIndex) : [];
|
|
7503
7584
|
updateSeparators(newSeparators, newInvertBgs);
|
|
7504
7585
|
setSelectedIndex(Math.min(selectedIndex, Math.max(0, newSeparators.length - 1)));
|
|
7505
|
-
} else if (
|
|
7586
|
+
} else if (shortcut === "c" || shortcut === "C") {
|
|
7506
7587
|
if (mode === "separator") {
|
|
7507
7588
|
updateSeparators([""], [false]);
|
|
7508
7589
|
} else {
|
|
7509
7590
|
updateSeparators([]);
|
|
7510
7591
|
}
|
|
7511
7592
|
setSelectedIndex(0);
|
|
7512
|
-
} else if (
|
|
7593
|
+
} else if (shortcut === "h" || shortcut === "H") {
|
|
7513
7594
|
setHexInputMode(true);
|
|
7514
7595
|
setHexInput("");
|
|
7515
7596
|
setCursorPos(0);
|
|
7516
|
-
} else if ((
|
|
7597
|
+
} else if ((shortcut === "t" || shortcut === "T") && mode === "separator") {
|
|
7517
7598
|
const newInvertBgs = [...invertBgs];
|
|
7518
7599
|
newInvertBgs[selectedIndex] = !(newInvertBgs[selectedIndex] ?? false);
|
|
7519
7600
|
updateSeparators(separators, newInvertBgs);
|
|
@@ -7631,15 +7712,17 @@ function applyCustomPowerlineTheme(settings, themeName) {
|
|
|
7631
7712
|
if (!themeColors) {
|
|
7632
7713
|
return null;
|
|
7633
7714
|
}
|
|
7715
|
+
let nextLineSlot = 0;
|
|
7634
7716
|
const lines = settings.lines.map((line) => {
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7717
|
+
const { slots, nextSlot } = assignPowerlineThemeSlots(line, settings.powerline.continueThemeAcrossLines ? nextLineSlot : 0);
|
|
7718
|
+
nextLineSlot = nextSlot;
|
|
7719
|
+
return line.map((widget, index) => {
|
|
7720
|
+
const slot = slots[index];
|
|
7721
|
+
if (typeof slot !== "number") {
|
|
7638
7722
|
return widget;
|
|
7639
7723
|
}
|
|
7640
|
-
const fgColor = themeColors.fg[
|
|
7641
|
-
const bgColor = themeColors.bg[
|
|
7642
|
-
widgetColorIndex++;
|
|
7724
|
+
const fgColor = themeColors.fg[slot % themeColors.fg.length];
|
|
7725
|
+
const bgColor = themeColors.bg[slot % themeColors.bg.length];
|
|
7643
7726
|
return {
|
|
7644
7727
|
...widget,
|
|
7645
7728
|
color: fgColor,
|
|
@@ -7692,13 +7775,14 @@ var PowerlineThemeSelector = ({
|
|
|
7692
7775
|
});
|
|
7693
7776
|
}, [selectedIndex, themes]);
|
|
7694
7777
|
use_input_default((input, key) => {
|
|
7778
|
+
const shortcut = getPlainInput(input, key);
|
|
7695
7779
|
if (showCustomizeConfirm) {
|
|
7696
7780
|
return;
|
|
7697
7781
|
}
|
|
7698
7782
|
if (key.escape) {
|
|
7699
7783
|
onUpdate(originalSettingsRef.current);
|
|
7700
7784
|
onBack();
|
|
7701
|
-
} else if (
|
|
7785
|
+
} else if (shortcut === "c" || shortcut === "C") {
|
|
7702
7786
|
const currentThemeName = themes[selectedIndex];
|
|
7703
7787
|
if (currentThemeName && currentThemeName !== "custom") {
|
|
7704
7788
|
setShowCustomizeConfirm(true);
|
|
@@ -7926,6 +8010,7 @@ var PowerlineSetup = ({
|
|
|
7926
8010
|
const hasGlobalFgOverride = Boolean(settings.overrideForegroundColor && settings.overrideForegroundColor !== "none");
|
|
7927
8011
|
const globalOverrideMessage = hasGlobalFgOverride ? "⚠ 前景色全局覆盖已激活" : null;
|
|
7928
8012
|
use_input_default((input, key) => {
|
|
8013
|
+
const shortcut = getPlainInput(input, key);
|
|
7929
8014
|
if (fontInstallMessage || installingFonts) {
|
|
7930
8015
|
if (fontInstallMessage && !key.escape) {
|
|
7931
8016
|
onClearMessage();
|
|
@@ -7938,7 +8023,7 @@ var PowerlineSetup = ({
|
|
|
7938
8023
|
if (screen === "menu") {
|
|
7939
8024
|
if (key.escape) {
|
|
7940
8025
|
onBack();
|
|
7941
|
-
} else if (
|
|
8026
|
+
} else if (shortcut === "t" || shortcut === "T") {
|
|
7942
8027
|
if (!powerlineConfig.enabled) {
|
|
7943
8028
|
if (hasManualSeparatorItems) {
|
|
7944
8029
|
setConfirmingEnable(true);
|
|
@@ -7954,9 +8039,9 @@ var PowerlineSetup = ({
|
|
|
7954
8039
|
}
|
|
7955
8040
|
});
|
|
7956
8041
|
}
|
|
7957
|
-
} else if (
|
|
8042
|
+
} else if (shortcut === "i" || shortcut === "I") {
|
|
7958
8043
|
setConfirmingFontInstall(true);
|
|
7959
|
-
} else if ((
|
|
8044
|
+
} else if ((shortcut === "a" || shortcut === "A") && powerlineConfig.enabled) {
|
|
7960
8045
|
onUpdate({
|
|
7961
8046
|
...settings,
|
|
7962
8047
|
powerline: {
|
|
@@ -7964,7 +8049,7 @@ var PowerlineSetup = ({
|
|
|
7964
8049
|
autoAlign: !powerlineConfig.autoAlign
|
|
7965
8050
|
}
|
|
7966
8051
|
});
|
|
7967
|
-
} else if ((
|
|
8052
|
+
} else if ((shortcut === "c" || shortcut === "C") && powerlineConfig.enabled) {
|
|
7968
8053
|
onUpdate({
|
|
7969
8054
|
...settings,
|
|
7970
8055
|
powerline: {
|
|
@@ -9368,11 +9453,12 @@ function getPinnedMismatchItems(mismatch, canRunPackageManager) {
|
|
|
9368
9453
|
var PinnedVersionMismatchScreen = ({
|
|
9369
9454
|
mismatch,
|
|
9370
9455
|
canRunPackageManager,
|
|
9456
|
+
updating,
|
|
9371
9457
|
onUpdate,
|
|
9372
9458
|
onExit
|
|
9373
9459
|
}) => {
|
|
9374
9460
|
use_input_default((_, key) => {
|
|
9375
|
-
if (key.escape) {
|
|
9461
|
+
if (key.escape && !updating) {
|
|
9376
9462
|
onExit();
|
|
9377
9463
|
}
|
|
9378
9464
|
});
|
|
@@ -9415,7 +9501,13 @@ var PinnedVersionMismatchScreen = ({
|
|
|
9415
9501
|
]
|
|
9416
9502
|
})
|
|
9417
9503
|
}),
|
|
9418
|
-
/* @__PURE__ */ jsx_runtime23.jsx(
|
|
9504
|
+
updating ? /* @__PURE__ */ jsx_runtime23.jsx(Box_default, {
|
|
9505
|
+
marginTop: 1,
|
|
9506
|
+
children: /* @__PURE__ */ jsx_runtime23.jsx(Text, {
|
|
9507
|
+
color: "yellow",
|
|
9508
|
+
children: `正在将 ${mismatch.packageManager} 全局安装更新至 v${mismatch.runningVersion},请稍候...`
|
|
9509
|
+
})
|
|
9510
|
+
}) : /* @__PURE__ */ jsx_runtime23.jsx(List, {
|
|
9419
9511
|
marginTop: 1,
|
|
9420
9512
|
items: getPinnedMismatchItems(mismatch, canRunPackageManager),
|
|
9421
9513
|
onSelect: (value) => {
|
|
@@ -9481,8 +9573,8 @@ function getPinnedGlobalRelaunchCommand(packageManager) {
|
|
|
9481
9573
|
}
|
|
9482
9574
|
return "ccstatusline-zh";
|
|
9483
9575
|
}
|
|
9484
|
-
function getPinnedVersionMismatch(installation, runningVersion, relaunchCommand) {
|
|
9485
|
-
if (installation.method !== "pinned" || !installation.installedVersion || installation.packageManager === "unknown" || !runningVersion || installation.installedVersion === runningVersion) {
|
|
9576
|
+
function getPinnedVersionMismatch(installation, runningVersion, relaunchCommand, versionInstalledThisSession = null) {
|
|
9577
|
+
if (installation.method !== "pinned" || !installation.installedVersion || installation.packageManager === "unknown" || !runningVersion || installation.installedVersion === runningVersion || installation.installedVersion === versionInstalledThisSession) {
|
|
9486
9578
|
return null;
|
|
9487
9579
|
}
|
|
9488
9580
|
return {
|
|
@@ -9532,7 +9624,7 @@ function buildConfigLoadWarning(configLoadError) {
|
|
|
9532
9624
|
}
|
|
9533
9625
|
return `⚠ ${configLoadError}——当前显示默认配置;在此保存将覆盖原文件。`;
|
|
9534
9626
|
}
|
|
9535
|
-
function buildInvalidConfigSaveConfirm(configLoadError, onConfirm) {
|
|
9627
|
+
function buildInvalidConfigSaveConfirm(configLoadError, onConfirm, returnScreen = "main") {
|
|
9536
9628
|
if (!configLoadError) {
|
|
9537
9629
|
return null;
|
|
9538
9630
|
}
|
|
@@ -9542,7 +9634,7 @@ function buildInvalidConfigSaveConfirm(configLoadError, onConfirm) {
|
|
|
9542
9634
|
onConfirm();
|
|
9543
9635
|
return Promise.resolve();
|
|
9544
9636
|
},
|
|
9545
|
-
cancelScreen:
|
|
9637
|
+
cancelScreen: returnScreen
|
|
9546
9638
|
};
|
|
9547
9639
|
}
|
|
9548
9640
|
var App = () => {
|
|
@@ -9570,9 +9662,12 @@ var App = () => {
|
|
|
9570
9662
|
const [flowNotice, setFlowNotice] = import_react21.useState(null);
|
|
9571
9663
|
const [globalPackageInstallations, setGlobalPackageInstallations] = import_react21.useState([]);
|
|
9572
9664
|
const [updatesReturnScreen, setUpdatesReturnScreen] = import_react21.useState("main");
|
|
9665
|
+
const [versionInstalledThisSession, setVersionInstalledThisSession] = import_react21.useState(null);
|
|
9573
9666
|
const [hasLoadedClaudeStatus, setHasLoadedClaudeStatus] = import_react21.useState(false);
|
|
9574
9667
|
const [hasLoadedInstalledState, setHasLoadedInstalledState] = import_react21.useState(false);
|
|
9575
9668
|
const [importValidation, setImportValidation] = import_react21.useState(null);
|
|
9669
|
+
const [actionInFlight, setActionInFlight] = import_react21.useState(false);
|
|
9670
|
+
const actionInFlightRef = import_react21.useRef(false);
|
|
9576
9671
|
import_react21.useEffect(() => {
|
|
9577
9672
|
loadClaudeStatusLineState().then((statusLineState) => {
|
|
9578
9673
|
setExistingStatusLine(statusLineState.existingStatusLine);
|
|
@@ -9631,7 +9726,7 @@ var App = () => {
|
|
|
9631
9726
|
const installation = getCurrentInstallation(isClaudeInstalled, existingStatusLine, settings);
|
|
9632
9727
|
const activeCommand = installation.method === "pinned" || installation.method === "self-managed" ? inspectActiveGlobalCommand({ commandAvailability }) : null;
|
|
9633
9728
|
const effectiveInstallation = getPathInferredInstallation(installation, activeCommand);
|
|
9634
|
-
const mismatch = getPinnedVersionMismatch(effectiveInstallation, getPackageVersion(), "ccstatusline-zh");
|
|
9729
|
+
const mismatch = getPinnedVersionMismatch(effectiveInstallation, getPackageVersion(), "ccstatusline-zh", versionInstalledThisSession);
|
|
9635
9730
|
if (mismatch) {
|
|
9636
9731
|
return;
|
|
9637
9732
|
}
|
|
@@ -9654,11 +9749,12 @@ var App = () => {
|
|
|
9654
9749
|
}
|
|
9655
9750
|
})();
|
|
9656
9751
|
};
|
|
9752
|
+
const returnScreen = screen;
|
|
9657
9753
|
const saveGuard = buildInvalidConfigSaveConfirm(configLoadError, () => {
|
|
9658
9754
|
setConfirmDialog(null);
|
|
9659
|
-
setScreen(
|
|
9755
|
+
setScreen(returnScreen);
|
|
9660
9756
|
performSave();
|
|
9661
|
-
});
|
|
9757
|
+
}, returnScreen);
|
|
9662
9758
|
if (saveGuard) {
|
|
9663
9759
|
setConfirmDialog(saveGuard);
|
|
9664
9760
|
setScreen("confirm");
|
|
@@ -9741,12 +9837,15 @@ ${resolutionWarning}`,
|
|
|
9741
9837
|
color: "green"
|
|
9742
9838
|
});
|
|
9743
9839
|
}
|
|
9744
|
-
} catch {
|
|
9745
|
-
setFlashMessage(
|
|
9746
|
-
|
|
9747
|
-
|
|
9840
|
+
} catch (err) {
|
|
9841
|
+
setFlashMessage(null);
|
|
9842
|
+
setFlowNotice({
|
|
9843
|
+
title: "安装失败",
|
|
9844
|
+
message: err instanceof Error ? err.message : String(err),
|
|
9845
|
+
color: "red",
|
|
9846
|
+
continueScreen: "install"
|
|
9748
9847
|
});
|
|
9749
|
-
setScreen("
|
|
9848
|
+
setScreen("flowNotice");
|
|
9750
9849
|
}
|
|
9751
9850
|
setConfirmDialog(null);
|
|
9752
9851
|
}
|
|
@@ -9782,6 +9881,7 @@ Claude 设置不会被修改。`,
|
|
|
9782
9881
|
action: async () => {
|
|
9783
9882
|
try {
|
|
9784
9883
|
await runGlobalUpdateAction(action);
|
|
9884
|
+
setVersionInstalledThisSession(action.version);
|
|
9785
9885
|
const installation = {
|
|
9786
9886
|
method: "pinned",
|
|
9787
9887
|
installedVersion: action.version
|
|
@@ -9875,7 +9975,18 @@ ${resolutionWarning}`,
|
|
|
9875
9975
|
const currentInstallation = getCurrentInstallation(isClaudeInstalled, existingStatusLine, settings);
|
|
9876
9976
|
const activeGlobalCommand = currentInstallation.method === "pinned" || currentInstallation.method === "self-managed" ? inspectActiveGlobalCommand({ commandAvailability }) : null;
|
|
9877
9977
|
const effectiveInstallation = getPathInferredInstallation(currentInstallation, activeGlobalCommand);
|
|
9878
|
-
const pinnedVersionMismatch = effectiveInstallation.method === "pinned" && effectiveInstallation.packageManager !== "unknown" ? getPinnedVersionMismatch(effectiveInstallation, runningVersion, getPinnedGlobalRelaunchCommand(effectiveInstallation.packageManager)) : null;
|
|
9978
|
+
const pinnedVersionMismatch = effectiveInstallation.method === "pinned" && effectiveInstallation.packageManager !== "unknown" ? getPinnedVersionMismatch(effectiveInstallation, runningVersion, getPinnedGlobalRelaunchCommand(effectiveInstallation.packageManager), versionInstalledThisSession) : null;
|
|
9979
|
+
const runActionOnce = (action) => {
|
|
9980
|
+
if (actionInFlightRef.current) {
|
|
9981
|
+
return;
|
|
9982
|
+
}
|
|
9983
|
+
actionInFlightRef.current = true;
|
|
9984
|
+
setActionInFlight(true);
|
|
9985
|
+
action().finally(() => {
|
|
9986
|
+
actionInFlightRef.current = false;
|
|
9987
|
+
setActionInFlight(false);
|
|
9988
|
+
});
|
|
9989
|
+
};
|
|
9879
9990
|
const handlePinnedVersionMismatchUpdate = async (mismatch) => {
|
|
9880
9991
|
try {
|
|
9881
9992
|
await runGlobalPackageInstall(mismatch.packageManager, mismatch.runningVersion);
|
|
@@ -10108,8 +10219,9 @@ ${GITHUB_REPO_URL}`,
|
|
|
10108
10219
|
/* @__PURE__ */ jsx_runtime23.jsx(PinnedVersionMismatchScreen, {
|
|
10109
10220
|
mismatch: pinnedVersionMismatch,
|
|
10110
10221
|
canRunPackageManager: commandAvailability[pinnedVersionMismatch.packageManager],
|
|
10222
|
+
updating: actionInFlight,
|
|
10111
10223
|
onUpdate: () => {
|
|
10112
|
-
handlePinnedVersionMismatchUpdate(pinnedVersionMismatch);
|
|
10224
|
+
runActionOnce(() => handlePinnedVersionMismatchUpdate(pinnedVersionMismatch));
|
|
10113
10225
|
},
|
|
10114
10226
|
onExit: exit
|
|
10115
10227
|
})
|
|
@@ -10279,7 +10391,10 @@ ${GITHUB_REPO_URL}`,
|
|
|
10279
10391
|
}),
|
|
10280
10392
|
screen === "confirm" && confirmDialog && /* @__PURE__ */ jsx_runtime23.jsx(ConfirmDialog, {
|
|
10281
10393
|
message: confirmDialog.message,
|
|
10282
|
-
|
|
10394
|
+
busy: actionInFlight,
|
|
10395
|
+
onConfirm: () => {
|
|
10396
|
+
runActionOnce(confirmDialog.action);
|
|
10397
|
+
},
|
|
10283
10398
|
onCancel: () => {
|
|
10284
10399
|
setScreen(getConfirmCancelScreen(confirmDialog));
|
|
10285
10400
|
setConfirmDialog(null);
|