mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-24 06:51:27 +01:00
Merge pull request #3158 from Master-Guy/features/2462
Tabelize linked output of `ls`
This commit is contained in:
commit
8faacfc4ef
@ -139,10 +139,9 @@ export function ls(
|
|||||||
}),
|
}),
|
||||||
)();
|
)();
|
||||||
|
|
||||||
const rowSplit = row
|
const rowSplit = row.split("~");
|
||||||
.split(" ")
|
let rowSplitArray = rowSplit.map((x) => [x.trim(), x.replace(x.trim(), "")]);
|
||||||
.map((x) => x.trim())
|
rowSplitArray = rowSplitArray.filter((x) => !!x[0]);
|
||||||
.filter((x) => !!x);
|
|
||||||
|
|
||||||
function onScriptLinkClick(filename: string): void {
|
function onScriptLinkClick(filename: string): void {
|
||||||
if (player.getCurrentServer().hostname !== hostname) {
|
if (player.getCurrentServer().hostname !== hostname) {
|
||||||
@ -156,9 +155,14 @@ export function ls(
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={classes.scriptLinksWrap}>
|
<span className={classes.scriptLinksWrap}>
|
||||||
{rowSplit.map((rowItem) => (
|
{rowSplitArray.map((rowItem) => (
|
||||||
<span key={rowItem} className={classes.scriptLink} onClick={() => onScriptLinkClick(rowItem)}>
|
<span>
|
||||||
{rowItem}
|
<span key={rowItem[0]} className={classes.scriptLink} onClick={() => onScriptLinkClick(rowItem[0])}>
|
||||||
|
{rowItem[0]}
|
||||||
|
</span>
|
||||||
|
<span key={'s'+rowItem[0]}>
|
||||||
|
{rowItem[1]}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</span>
|
</span>
|
||||||
@ -174,16 +178,19 @@ export function ls(
|
|||||||
if (!(i < segments.length)) break;
|
if (!(i < segments.length)) break;
|
||||||
row += segments[i];
|
row += segments[i];
|
||||||
row += " ".repeat(maxLength * (col + 1) - row.length);
|
row += " ".repeat(maxLength * (col + 1) - row.length);
|
||||||
|
if(linked) {
|
||||||
|
row += "~";
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
if (!style) {
|
if (!style) {
|
||||||
terminal.print(row);
|
terminal.print(row);
|
||||||
} else if (linked) {
|
} else if (linked) {
|
||||||
terminal.printRaw(<ClickableScriptRow row={row} prefix={prefix} hostname={server.hostname} />);
|
terminal.printRaw(<ClickableScriptRow row={row} prefix={prefix} hostname={server.hostname} />);
|
||||||
} else {
|
} else {
|
||||||
terminal.printRaw(<span style={style}>{row}</span>);
|
terminal.printRaw(<span style={style}>{row}</span>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user