diff --git a/src/lib/stores/bash/commands/ls.ts b/src/lib/stores/bash/commands/ls.ts index e3e60e0..28810da 100755 --- a/src/lib/stores/bash/commands/ls.ts +++ b/src/lib/stores/bash/commands/ls.ts @@ -225,7 +225,7 @@ function result_ls(this: Bash, data: any, args: CommandArgs): HTMLElement { colWidths.push(Math.max(...columns[i].map((name) => name.length))); } - const calcWidth: number = colWidths.reduce((prev, curr) => prev + curr) + ((c-1) * 2); + const calcWidth: number = colWidths.reduce((prev, curr) => prev + curr) + ((c-1) * 3); if(calcWidth < maxWidth) lowBound = c + 1; else if(calcWidth > maxWidth) highBound = c -1 @@ -234,7 +234,6 @@ function result_ls(this: Bash, data: any, args: CommandArgs): HTMLElement { const wrapper: HTMLElement = document.createElement('div'); wrapper.style.display = 'flex'; - wrapper.style.columnGap = `${this.getTerminalFontSize() * 2}px`; wrapper.style.marginBottom = `${this.getTerminalFontSize() * 2}px`; let fileIndex = 0; @@ -323,6 +322,7 @@ function formatChildren(node: TreeNode): string { if (!node.children) throw new Error('children array is null on this node'); const c = node.children.length.toString(); + console.log(c, "TEST TEST"); return c.length > 1 ? c : ` ${c}`; } @@ -362,35 +362,28 @@ function formatName(node: TreeNode, flag: any, shouldShift: boolean) { let name: string = node.name; const char: string = flag.has('Q') ? '"' : "'"; - if (/\s/.test(node.name)) { - name = `${char}${name}${char}` - } else { - //Shift non quoted names 1 char right to align if any names in group have a quote - name = `${shouldShift ? ' ' : ''}${node.name}`; + if (/\s/.test(node.name)) name = `${char}${name}${char}`; + + if(flag.has('p') && node.type === Type.Directory) name = `${name}/` + + if((flag.has('l') || flag.has('g') || flag.has('o'))) { + // Is the ls in long format + if (!(/\s/.test(node.name))) { + //Shift non quoted names 1 char right to align if any names in group have a quote + name = `${shouldShift ? ' ' : ''}${name}`; + } + } + else { + if (!(/\s/.test(node.name))) { + name = ` ${name}`; + } + + name = `${name} `; } - return flag.has('p') && node.type === Type.Directory ? `${name}/` : name; + return name } -/* function formatOutputShort(node: TreeNode, flag: any) { - let output: string = node.name; - const char: string = flag.has('Q') ? '"' : "'"; - - if (/\s/.test(node.name)) { - if(flag.has('i')) { - - } - else { - output = `${char}${node.name}${char}`; - } - - if(flag.has('i')) { - output = `${node.inode} ${output}` - } - - return flag.has('p') && node.type === Type.Directory ? ` ${output}/ ` : output; -} */ - const checkFlags = (pFlags: string[]) => { const flagSet = new Set(pFlags); diff --git a/src/modules/Terminal.svelte b/src/modules/Terminal.svelte index fbe15b3..5895f19 100755 --- a/src/modules/Terminal.svelte +++ b/src/modules/Terminal.svelte @@ -26,7 +26,8 @@ } function getFontSize() { - const e = document.getElementById('cout'); + return 10; + /* const e = document.getElementById('cout'); if(!e) { throw new Error('cant get font size of the terminal element. its null'); } @@ -34,7 +35,7 @@ const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d')!; ctx.font = `${window.getComputedStyle(e, null).getPropertyValue('font-size')} 'JetBrains Mono', monospace;`; - return ctx.measureText('M').width; + return ctx.measureText(' ').width; */ } function handleInput(event: KeyboardEvent) {