Skip to content

Commit 53d0dc3

Browse files
committed
cleanup in preparation for order patches
1 parent bbde294 commit 53d0dc3

9 files changed

+287
-110
lines changed

coopy/CellInfo.hx

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ class CellInfo {
88
public var pretty_value : String;
99
public var category : String;
1010
public var category_given_tr : String;
11+
12+
// relevant to updates, conflicts
13+
public var separator : String;
14+
public var updated : Bool;
15+
public var conflicted : Bool;
16+
public var pvalue : String;
17+
public var lvalue : String;
18+
public var rvalue : String;
1119

1220
public function new() : Void {}
21+
22+
public function toString() : String {
23+
if (!updated) return value;
24+
if (!conflicted) return lvalue + "::" + rvalue;
25+
return pvalue + "||" + lvalue + "::" + rvalue;
26+
}
1327
}

coopy/CompareFlags.hx

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ class CompareFlags {
77
public var always_show_header : Bool;
88
public var show_unchanged : Bool;
99
public var unchanged_context : Int;
10-
public var show_rc_numbers : Bool;
10+
public var always_show_order : Bool;
11+
public var never_show_order : Bool;
12+
public var ordered : Bool;
1113

1214
public function new() {
1315
always_show_header = true;
1416
show_unchanged = false;
1517
unchanged_context = 1;
16-
show_rc_numbers = false;
18+
always_show_order = false;
19+
never_show_order = true;
20+
ordered = true;
1721
}
1822
}
1923

coopy/DiffRender.hx

+20-8
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,19 @@ class DiffRender {
7272
}
7373

7474

75-
private static function examineCell(x: Int,
76-
y: Int,
77-
value : String,
78-
vcol : String,
79-
vrow : String,
80-
vcorner : String,
81-
cell : CellInfo) : Void {
75+
public static function examineCell(x: Int,
76+
y: Int,
77+
value : String,
78+
vcol : String,
79+
vrow : String,
80+
vcorner : String,
81+
cell : CellInfo) : Void {
8282
cell.category = "";
8383
cell.category_given_tr = "";
84+
cell.separator = "";
85+
cell.conflicted = false;
86+
cell.updated = false;
87+
cell.pvalue = cell.lvalue = cell.rvalue = null;
8488
cell.value = value;
8589
if (cell.value==null) cell.value = "";
8690
cell.pretty_value = cell.value;
@@ -117,10 +121,18 @@ class DiffRender {
117121
if (cell.value.indexOf(full)>=0) {
118122
div = full;
119123
cat = "conflict";
124+
cell.conflicted = true;
120125
}
121126
}
122-
cell.pretty_value = cell.pretty_value.split(div).join(String.fromCharCode(8594));
127+
cell.updated = true;
128+
cell.separator = div;
129+
tokens = cell.pretty_value.split(div);
130+
cell.pretty_value = tokens.join(String.fromCharCode(8594));
123131
cell.category_given_tr = cell.category = cat;
132+
var offset : Int = cell.conflicted?1:0;
133+
cell.lvalue = tokens[offset];
134+
cell.rvalue = tokens[offset+1];
135+
if (cell.conflicted) cell.pvalue = tokens[0];
124136
}
125137
}
126138
}

0 commit comments

Comments
 (0)