diff --git a/cptr/frontend/src/lib/components/FileBrowser.svelte b/cptr/frontend/src/lib/components/FileBrowser.svelte index 50d0c97..04277e7 100644 --- a/cptr/frontend/src/lib/components/FileBrowser.svelte +++ b/cptr/frontend/src/lib/components/FileBrowser.svelte @@ -1231,10 +1231,15 @@ class="flex shrink-0 items-center gap-1 text-[0.625rem] font-mono font-medium" use:tooltip={gitStatusTooltip(fileGitStatus, entry)} > - +{fileGitStatus.additions ?? 0} - -{fileGitStatus.deletions ?? 0} + {#if fileGitStatus.binary} + {entryGitDecoration.char} + {:else} + +{fileGitStatus.additions ?? 0} + -{fileGitStatus.deletions ?? 0} + {/if} {/if} {#if entry.type !== 'directory' && entry.size !== null} diff --git a/cptr/frontend/src/lib/components/FileEditor.svelte b/cptr/frontend/src/lib/components/FileEditor.svelte index eddc75d..87935da 100644 --- a/cptr/frontend/src/lib/components/FileEditor.svelte +++ b/cptr/frontend/src/lib/components/FileEditor.svelte @@ -1026,6 +1026,17 @@ return `${(bytes / 1048576).toFixed(1)} MB`; } + function gitStatusChar(status: string): string { + const chars: Record = { + added: 'A', + untracked: 'U', + modified: 'M', + deleted: 'D', + renamed: 'R' + }; + return chars[status] ?? '?'; + } + onDestroy(() => { destroyEditor(); revokeBinaryUrl(); @@ -1041,8 +1052,12 @@ {fileData.name} {#if currentFileStatus} - +{currentFileStatus.additions ?? 0} - -{currentFileStatus.deletions ?? 0} + {#if currentFileStatus.binary} + {gitStatusChar(currentFileStatus.status)} + {:else} + +{currentFileStatus.additions ?? 0} + -{currentFileStatus.deletions ?? 0} + {/if} {/if} @@ -1325,6 +1340,10 @@ color: #ef4444; } + .file-git-status { + color: var(--color-gray-500); + } + :global(.dark) .file-git-additions { color: #4ade80; } diff --git a/cptr/frontend/src/lib/components/GitBar.svelte b/cptr/frontend/src/lib/components/GitBar.svelte index 94cf2a0..3bb355c 100644 --- a/cptr/frontend/src/lib/components/GitBar.svelte +++ b/cptr/frontend/src/lib/components/GitBar.svelte @@ -44,6 +44,7 @@ unstaged?: boolean; staged_status?: string; unstaged_status?: string; + binary?: boolean; additions?: number; deletions?: number; }; @@ -673,6 +674,25 @@ return `${Math.floor(s / 86400)}d`; } + function statusChar(status: string): { char: string; color: string } { + switch (status) { + case 'added': + return { char: 'A', color: 'text-green-500' }; + case 'untracked': + return { char: 'U', color: 'text-green-500' }; + case 'modified': + return { char: 'M', color: 'text-amber-500' }; + case 'deleted': + return { char: 'D', color: 'text-red-400' }; + case 'renamed': + return { char: 'R', color: 'text-blue-400' }; + case 'conflict': + return { char: '!', color: 'text-orange-500' }; + default: + return { char: '?', color: 'text-gray-400' }; + } + } + const syncAction = $derived.by(() => { if (!gitStatus) return { label: $t('git.fetch'), icon: 'refresh', action: doFetch }; if (gitStatus.behind > 0) @@ -799,9 +819,11 @@ {#if totalChanges > 0}{$t('git.changedCount', { count: totalChanges })}+{totalAdditions} - -{totalDeletions}{#if totalAdditions || totalDeletions}+{totalAdditions} + -{totalDeletions}{/if} >{/if} {#if actionMsg} {#each gitStatus?.files ?? [] as file (file.path)} {@const fp = fPath(file.path)} + {@const sc = statusChar(file.status)}