mirror of https://github.com/openclaw/openclaw.git
refactor: share terminal note wrapping
This commit is contained in:
parent
827b166bbc
commit
f7f5c24786
|
|
@ -54,6 +54,21 @@ function isCopySensitiveToken(word: string): boolean {
|
||||||
return word.includes("_") && FILE_LIKE_RE.test(word);
|
return word.includes("_") && FILE_LIKE_RE.test(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pushWrappedWordSegments(params: {
|
||||||
|
word: string;
|
||||||
|
available: number;
|
||||||
|
firstPrefix: string;
|
||||||
|
continuationPrefix: string;
|
||||||
|
lines: string[];
|
||||||
|
}) {
|
||||||
|
const parts = splitLongWord(params.word, params.available);
|
||||||
|
const first = parts.shift() ?? "";
|
||||||
|
params.lines.push(params.firstPrefix + first);
|
||||||
|
for (const part of parts) {
|
||||||
|
params.lines.push(params.continuationPrefix + part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function wrapLine(line: string, maxWidth: number): string[] {
|
function wrapLine(line: string, maxWidth: number): string[] {
|
||||||
if (line.trim().length === 0) {
|
if (line.trim().length === 0) {
|
||||||
return [line];
|
return [line];
|
||||||
|
|
@ -80,14 +95,15 @@ function wrapLine(line: string, maxWidth: number): string[] {
|
||||||
current = word;
|
current = word;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const parts = splitLongWord(word, available);
|
pushWrappedWordSegments({
|
||||||
const first = parts.shift() ?? "";
|
word,
|
||||||
lines.push(prefix + first);
|
available,
|
||||||
|
firstPrefix: prefix,
|
||||||
|
continuationPrefix: nextPrefix,
|
||||||
|
lines,
|
||||||
|
});
|
||||||
prefix = nextPrefix;
|
prefix = nextPrefix;
|
||||||
available = nextWidth;
|
available = nextWidth;
|
||||||
for (const part of parts) {
|
|
||||||
lines.push(prefix + part);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
current = word;
|
current = word;
|
||||||
|
|
@ -109,12 +125,13 @@ function wrapLine(line: string, maxWidth: number): string[] {
|
||||||
current = word;
|
current = word;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const parts = splitLongWord(word, available);
|
pushWrappedWordSegments({
|
||||||
const first = parts.shift() ?? "";
|
word,
|
||||||
lines.push(prefix + first);
|
available,
|
||||||
for (const part of parts) {
|
firstPrefix: prefix,
|
||||||
lines.push(prefix + part);
|
continuationPrefix: prefix,
|
||||||
}
|
lines,
|
||||||
|
});
|
||||||
current = "";
|
current = "";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue