Side-by-side semantic diff tool with theme support and hookable integration
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: fullscreen new when no old

+70 -4
+1 -1
VERSION
··· 1 - 0.3.1 1 + 0.4.0
docs/screenshot.png

This is a binary file and will not be displayed.

+69 -3
main.go
··· 359 359 st := m.styles 360 360 var sb strings.Builder 361 361 362 - // Row layout: 2(prefix) + 4(lNum) + 1 + cellInner + 3(" │ ") + 4(rNum) + 1 + cellInner = 15 + 2·cellInner. 363 - // For this to fit in m.width: colWidth (half) = (m.width-3)/2 so that cellInner = colWidth-6 = (m.width-15)/2. 364 - colWidth := (m.width - 3) / 2 362 + // Full-screen mode: when old is empty, show only the new file at full width. 363 + if m.oldText == "" { 364 + cellWidth := m.width - 7 // prefix(2) + linenum(4) + space(1) 365 + if cellWidth < 10 { 366 + cellWidth = 10 367 + } 368 + rh := fitName(m.newFile, m.width-2) 369 + sb.WriteString(st.HeaderSt.Render(" " + rh)) 370 + sb.WriteString("\n\n") 371 + 372 + start := m.offset 373 + end := start + m.height 374 + if end > len(m.lines) { 375 + end = len(m.lines) 376 + } 377 + if start > len(m.lines) { 378 + start = len(m.lines) 379 + } 380 + for i := start; i < end; i++ { 381 + dl := m.lines[i] 382 + selected := i == m.cursor 383 + prefix := " " 384 + if selected { 385 + prefix = st.CursorSymbol + " " 386 + } 387 + rNum := " " 388 + if dl.NewLine > 0 { 389 + rNum = st.LineSt.Render(fmt.Sprintf("%4d", dl.NewLine)) 390 + } 391 + rightLine := m.getHighlightedLine(m.newHL, dl.NewLine-1) 392 + rightCell := adiff.RenderCell(rightLine, cellWidth, st.AddedBgHex, true, m.hOffset) 393 + sb.WriteString(prefix + rNum + " " + rightCell + "\n") 394 + } 395 + 396 + total := len(m.lines) 397 + status := fmt.Sprintf(" line %d/%d mode:%s theme:%s", m.cursor+1, total, m.diffMode, st.ChromaStyle) 398 + if m.message != "" { 399 + status += " [" + m.message + "]" 400 + } 401 + help := " j/k:move e:edit g/G:top/bot q:quit" 402 + sb.WriteString(st.StatusSt.Render(status)) 403 + sb.WriteString("\n") 404 + sb.WriteString(st.HelpSt.Render(help)) 405 + return sb.String() 406 + } 407 + 408 + colWidth := m.width / 2 365 409 if colWidth < 10 { 366 410 colWidth = 10 367 411 } ··· 490 534 } 491 535 492 536 st := m.styles 537 + 538 + // Full-screen mode: when old is empty, show only the new file at full width. 539 + if m.oldText == "" { 540 + cellWidth := width - 7 // " "(2) + linenum(4) + " "(1) 541 + if cellWidth < 10 { 542 + cellWidth = 10 543 + } 544 + fmt.Println(st.HeaderSt.Render(" " + fitName(m.newFile, width-2))) 545 + fmt.Println() 546 + for _, dl := range m.lines { 547 + rNum := " " 548 + if dl.NewLine > 0 { 549 + rNum = st.LineSt.Render(fmt.Sprintf("%4d", dl.NewLine)) 550 + } 551 + rightLine := m.getHighlightedLine(m.newHL, dl.NewLine-1) 552 + rightCell := adiff.RenderCell(rightLine, cellWidth, st.AddedBgHex, true, 0) 553 + fmt.Println(" " + rNum + " " + rightCell) 554 + } 555 + fmt.Println(st.StatusSt.Render(fmt.Sprintf(" %d lines mode:%s", len(m.lines), m.diffMode))) 556 + return 557 + } 558 + 493 559 // Row layout: " "(2) + lNum(4) + " "(1) + leftCell + " │ "(3) + rNum(4) + " "(1) + rightCell 494 560 // Total visible width = 3 + 2*colWidth, so colWidth = (width-3)/2 to fit exactly. 495 561 colWidth := (width - 3) / 2