RenderDiff renders parsed diff lines into a styled string.
(parsed ParsedDiff, filename string, styles Styles, t theme.Theme, width int)
| 147 | |
| 148 | // RenderDiff renders parsed diff lines into a styled string. |
| 149 | func RenderDiff(parsed ParsedDiff, filename string, styles Styles, t theme.Theme, width int) string { |
| 150 | if parsed.Binary { |
| 151 | return RenderBinaryFile(styles, width) |
| 152 | } |
| 153 | initChromaStyle(t.ChromaStyle) |
| 154 | |
| 155 | var b strings.Builder |
| 156 | for _, dl := range parsed.Lines { |
| 157 | b.WriteString(renderDiffLine(dl, filename, styles, t, width)) |
| 158 | b.WriteByte('\n') |
| 159 | } |
| 160 | return b.String() |
| 161 | } |
| 162 | |
| 163 | func renderDiffLine(dl DiffLine, filename string, styles Styles, t theme.Theme, width int) string { |
| 164 | switch dl.Type { |