Tabelize linked output of ls

This commit is contained in:
Master-Guy 2022-03-17 17:50:39 +01:00
parent 93f4c499d4
commit a575c0cfe3

@ -139,10 +139,12 @@ export function ls(
}), }),
)(); )();
const rowSplit = row console.log(row);
.split(" ")
.map((x) => x.trim()) const rowSplit = row.split("~");
.filter((x) => !!x); let rowSplitArray = rowSplit.map((x) => [x.trim(), x.replace(x.trim(), "")]);
console.log(rowSplitArray);
rowSplitArray = rowSplitArray.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 +158,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,6 +181,9 @@ 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--;