@@ -510,34 +510,42 @@ def _show_side_by_side(self, text_a, text_b):
510510
511511 html_a = []
512512 html_b = []
513+ line_num_a = 1
514+ line_num_b = 1
513515
514516 for tag , i1 , i2 , j1 , j2 in matcher .get_opcodes ():
515517 if tag == 'equal' :
516518 # Lines are the same
517519 for i in range (i1 , i2 ):
518- html_a .append (f'<div style="background-color: #1e1e1e;">{ self ._escape_html (lines_a [i ])} </div>' )
520+ html_a .append (f'<div style="background-color: #1e1e1e;"><span style="color: #858585; user-select: none;">{ line_num_a :4d} </span> { self ._escape_html (lines_a [i ])} </div>' )
521+ line_num_a += 1
519522 for j in range (j1 , j2 ):
520- html_b .append (f'<div style="background-color: #1e1e1e;">{ self ._escape_html (lines_b [j ])} </div>' )
523+ html_b .append (f'<div style="background-color: #1e1e1e;"><span style="color: #858585; user-select: none;">{ line_num_b :4d} </span> { self ._escape_html (lines_b [j ])} </div>' )
524+ line_num_b += 1
521525 elif tag == 'replace' :
522526 # Lines are different
523527 for i in range (i1 , i2 ):
524- html_a .append (f'<div style="background-color: #4a1f1f; color: #ff6b6b;">{ self ._escape_html (lines_a [i ])} </div>' )
528+ html_a .append (f'<div style="background-color: #4a1f1f; color: #ff6b6b;"><span style="color: #ff9999; user-select: none;">{ line_num_a :4d} </span> { self ._escape_html (lines_a [i ])} </div>' )
529+ line_num_a += 1
525530 for j in range (j1 , j2 ):
526- html_b .append (f'<div style="background-color: #1f4a1f; color: #6bff6b;">{ self ._escape_html (lines_b [j ])} </div>' )
531+ html_b .append (f'<div style="background-color: #1f4a1f; color: #6bff6b;"><span style="color: #99ff99; user-select: none;">{ line_num_b :4d} </span> { self ._escape_html (lines_b [j ])} </div>' )
532+ line_num_b += 1
527533 elif tag == 'delete' :
528534 # Line only in A
529535 for i in range (i1 , i2 ):
530- html_a .append (f'<div style="background-color: #4a1f1f; color: #ff6b6b;">{ self ._escape_html (lines_a [i ])} </div>' )
536+ html_a .append (f'<div style="background-color: #4a1f1f; color: #ff6b6b;"><span style="color: #ff9999; user-select: none;">{ line_num_a :4d} </span> { self ._escape_html (lines_a [i ])} </div>' )
537+ line_num_a += 1
531538 # Add empty lines to B for alignment
532539 for _ in range (i1 , i2 ):
533- html_b .append (f'<div style="background-color: #2a2a2a; color: #666;">{ " " * 50 } </div>' )
540+ html_b .append (f'<div style="background-color: #2a2a2a; color: #666;"><span style="color: #555; user-select: none;"> </span> { " " * 50 } </div>' )
534541 elif tag == 'insert' :
535542 # Line only in B
536543 for j in range (j1 , j2 ):
537- html_b .append (f'<div style="background-color: #1f4a1f; color: #6bff6b;">{ self ._escape_html (lines_b [j ])} </div>' )
544+ html_b .append (f'<div style="background-color: #1f4a1f; color: #6bff6b;"><span style="color: #99ff99; user-select: none;">{ line_num_b :4d} </span> { self ._escape_html (lines_b [j ])} </div>' )
545+ line_num_b += 1
538546 # Add empty lines to A for alignment
539547 for _ in range (j1 , j2 ):
540- html_a .append (f'<div style="background-color: #2a2a2a; color: #666;">{ " " * 50 } </div>' )
548+ html_a .append (f'<div style="background-color: #2a2a2a; color: #666;"><span style="color: #555; user-select: none;"> </span> { " " * 50 } </div>' )
541549
542550 self .text_a .setHtml ('<pre style="font-family: Courier; font-size: 18pt; margin: 0; padding: 0;">' + '' .join (html_a ) + '</pre>' )
543551 self .text_b .setHtml ('<pre style="font-family: Courier; font-size: 18pt; margin: 0; padding: 0;">' + '' .join (html_b ) + '</pre>' )
0 commit comments