︙ | | |
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
|
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
|
-
-
-
-
-
+
-
-
-
|
# Turn off ignore
set ::Pref(ignore) " "
set ::Pref(nocase) 0
set ::Pref(noempty) 0
# Try to autodetect line endings in file
set ch [open $file rb]
set data [read $ch 10000]
close $ch
if {[string first \r\n $data] >= 0} {
set ::eskil($top,mergetranslation) crlf
detectLineEnd $top $file mergetranslation lf
} else {
set ::eskil($top,mergetranslation) lf
}
}
# Read a conflict file and extract the two versions.
proc prepareConflict {top} {
disallowEdit $top
set ::eskil($top,leftFile) [tmpFile]
set ::eskil($top,rightFile) [tmpFile]
|
︙ | | |
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
|
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
|
+
+
+
|
if {$::eskil($top,mode) eq "rev"} {
prepareRev $top
lappend ::eskil($top,cleanup) "rev"
} elseif {$::eskil($top,mode) eq "conflict"} {
prepareConflict $top
lappend ::eskil($top,cleanup) "conflict"
}
# Try to autodetect line endings in files
detectLineEnd $top $::eskil($top,rightFile) righttranslation
detectLineEnd $top $::eskil($top,leftFile) lefttranslation
# Prepare Separator
set ::eskil($top,separator) \
[subst -nocommands -novariables $::eskil($top,separatorview)]
# Autodetect separator before any plugin processing
if {$::eskil($top,view) eq "table" && $::eskil($top,separator) eq ""} {
set ch1 [open $::eskil($top,leftFile)]
gets $ch1 line1
|
︙ | | |
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
|
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
#####################################
# Editing
#####################################
# FIXA: Use snit to adapt text widget instead of using wcb
# include seeText in such a snidget.
# Try to autodetect line endings in file
proc detectLineEnd {top file field {def {}}} {
set ch [open $file rb]
set data [read $ch 1000]
close $ch
if {[string first \r\n $data] >= 0} {
set ::eskil($top,$field) crlf
} elseif {[string first \n $data] >= 0} {
set ::eskil($top,$field) lf
} else {
set ::eskil($top,$field) $def
}
}
# Clear Editing state
proc resetEdit {top} {
set ::eskil($top,leftEdit) 0
set ::eskil($top,rightEdit) 0
$top.m.mt entryconfigure "Edit Mode" -state normal
|
︙ | | |
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
|
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
|
+
+
|
return 0
}
proc saveFile {top side} {
if {$side == 1} {
if {!$::eskil($top,leftEdit)} return
set fileName $::eskil($top,leftFile)
set trans $::eskil($top,lefttranslation)
} else {
if {!$::eskil($top,rightEdit)} return
set fileName $::eskil($top,rightFile)
set trans $::eskil($top,righttranslation)
}
set w $::widgets($top,wDiff$side)
# Confirm dialog
set apa [tk_messageBox -parent $top -icon question \
-title "Overwrite file" -type yesnocancel -message \
|
︙ | | |
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
|
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
|
+
+
+
|
return
}
} elseif {$apa ne "no"} {
return
}
set ch [open $fileName "w"]
if {$trans ne ""} {
fconfigure $ch -translation $trans
}
set save 1
foreach {key value index} [$w dump -all 1.0 end-1c] {
switch -- $key {
text {
if {$save} {
puts -nonewline $ch $value
}
|
︙ | | |