Compare commits

...

1 Commits

Author SHA1 Message Date
VALLONGOL
11f86972c5 aggiunto highlight parziale codice modificato 2025-12-23 15:17:46 +01:00
2 changed files with 92 additions and 0 deletions

View File

@ -110,8 +110,11 @@ class DiffViewer(tk.Toplevel):
# Colors for diff (left: source, right: destination)
self.left_text.tag_config("added", background="#d6ffd6")
self.left_text.tag_config("changed", background="#fff3bf")
# inline changed region (more accentuated)
self.left_text.tag_config("changed_inline", background="#ffb366")
self.right_text.tag_config("removed", background="#ffd6d6")
self.right_text.tag_config("changed", background="#fff3bf")
self.right_text.tag_config("changed_inline", background="#ffb366")
# Bind mousewheel to synchronize scrolling between both panes
self.left_text.bind("<MouseWheel>", self._on_mousewheel)
self.right_text.bind("<MouseWheel>", self._on_mousewheel)
@ -347,6 +350,50 @@ class DiffViewer(tk.Toplevel):
self.right_text.tag_add('changed', start, end)
for k in range(i1, i2):
right_lines[k] = 'changed'
# Attempt intraline/highlight of exact differing character ranges
try:
# pair up lines in the replace block where possible
left_block_len = j2 - j1
right_block_len = i2 - i1
pairs = min(left_block_len, right_block_len)
for offset in range(pairs):
lidx = j1 + offset
ridx = i1 + offset
# get raw line text without trailing newline for character offsets
try:
left_line = src_lines[lidx].rstrip('\n')
except Exception:
left_line = ''
try:
right_line = dest_lines[ridx].rstrip('\n')
except Exception:
right_line = ''
# if either line is empty, skip detailed matching
if not left_line and not right_line:
continue
sm = difflib.SequenceMatcher(None, left_line, right_line)
for ctag, a1, a2, b1, b2 in sm.get_opcodes():
if ctag == 'equal':
continue
# apply inline tags: left side chars a1..a2, right side b1..b2
# left
if a2 > a1:
try:
start_idx = f"{lidx+1}.{a1}"
end_idx = f"{lidx+1}.{a2}"
self.left_text.tag_add('changed_inline', start_idx, end_idx)
except Exception:
pass
# right
if b2 > b1:
try:
start_idx = f"{ridx+1}.{b1}"
end_idx = f"{ridx+1}.{b2}"
self.right_text.tag_add('changed_inline', start_idx, end_idx)
except Exception:
pass
except Exception:
pass
elif tag == 'delete':
# lines present in dest (right) but deleted from source -> removed on right
if i2 > i1:

View File

@ -43,5 +43,50 @@
".mk",
".bak"
]
},
"DevEnv da server svn": {
"description": "DevEnv Grifo E",
"source": "//tsclient/D/__BACKUP/GrifoE/GRIFO-E_svn/DevEnv",
"destination": "C:/src/GRIFO-E - Copia/DevEnv",
"ignore_extensions": [
".o",
".d",
".obj",
".class",
".pyc",
".pyo",
".log",
".tmp",
".swp",
".DS_Store",
".exe",
".a",
".mk",
".bak",
".defs",
".txt",
".pdom"
]
},
"REP da server svn": {
"description": "REP Grifo E code base",
"source": "//tsclient/D/__BACKUP/GrifoE/GRIFO-E_svn/REP",
"destination": "C:/src/GRIFO-E - Copia/REP",
"ignore_extensions": [
".o",
".d",
".obj",
".class",
".pyc",
".pyo",
".log",
".tmp",
".swp",
".DS_Store",
".exe",
".a",
".mk",
".bak"
]
}
}