everypolitician-daff 1.3.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +252 -0
- data/bin/daff.rb +3 -0
- data/lib/daff.rb +150 -0
- data/lib/lib/coopy/alignment.rb +307 -0
- data/lib/lib/coopy/cell_builder.rb +17 -0
- data/lib/lib/coopy/cell_info.rb +33 -0
- data/lib/lib/coopy/column_change.rb +16 -0
- data/lib/lib/coopy/combined_table.rb +127 -0
- data/lib/lib/coopy/combined_table_body.rb +151 -0
- data/lib/lib/coopy/combined_table_head.rb +103 -0
- data/lib/lib/coopy/compare_flags.rb +127 -0
- data/lib/lib/coopy/compare_table.rb +688 -0
- data/lib/lib/coopy/conflict_info.rb +23 -0
- data/lib/lib/coopy/coopy.rb +1065 -0
- data/lib/lib/coopy/cross_match.rb +17 -0
- data/lib/lib/coopy/csv.rb +290 -0
- data/lib/lib/coopy/diff_render.rb +339 -0
- data/lib/lib/coopy/diff_summary.rb +28 -0
- data/lib/lib/coopy/flat_cell_builder.rb +75 -0
- data/lib/lib/coopy/highlight_patch.rb +977 -0
- data/lib/lib/coopy/highlight_patch_unit.rb +38 -0
- data/lib/lib/coopy/index.rb +131 -0
- data/lib/lib/coopy/index_item.rb +37 -0
- data/lib/lib/coopy/index_pair.rb +96 -0
- data/lib/lib/coopy/json_table.rb +165 -0
- data/lib/lib/coopy/json_tables.rb +129 -0
- data/lib/lib/coopy/merger.rb +197 -0
- data/lib/lib/coopy/meta.rb +20 -0
- data/lib/lib/coopy/mover.rb +197 -0
- data/lib/lib/coopy/ndjson.rb +134 -0
- data/lib/lib/coopy/nested_cell_builder.rb +74 -0
- data/lib/lib/coopy/ordering.rb +54 -0
- data/lib/lib/coopy/property_change.rb +16 -0
- data/lib/lib/coopy/row.rb +11 -0
- data/lib/lib/coopy/row_change.rb +42 -0
- data/lib/lib/coopy/row_stream.rb +11 -0
- data/lib/lib/coopy/simple_meta.rb +314 -0
- data/lib/lib/coopy/simple_table.rb +345 -0
- data/lib/lib/coopy/simple_view.rb +70 -0
- data/lib/lib/coopy/sparse_sheet.rb +51 -0
- data/lib/lib/coopy/sql_column.rb +47 -0
- data/lib/lib/coopy/sql_compare.rb +605 -0
- data/lib/lib/coopy/sql_database.rb +21 -0
- data/lib/lib/coopy/sql_helper.rb +17 -0
- data/lib/lib/coopy/sql_table.rb +335 -0
- data/lib/lib/coopy/sql_table_name.rb +23 -0
- data/lib/lib/coopy/sql_tables.rb +128 -0
- data/lib/lib/coopy/sqlite_helper.rb +316 -0
- data/lib/lib/coopy/table.rb +24 -0
- data/lib/lib/coopy/table_comparison_state.rb +50 -0
- data/lib/lib/coopy/table_diff.rb +1185 -0
- data/lib/lib/coopy/table_io.rb +72 -0
- data/lib/lib/coopy/table_modifier.rb +40 -0
- data/lib/lib/coopy/table_stream.rb +102 -0
- data/lib/lib/coopy/table_view.rb +148 -0
- data/lib/lib/coopy/tables.rb +52 -0
- data/lib/lib/coopy/terminal_diff_render.rb +213 -0
- data/lib/lib/coopy/unit.rb +93 -0
- data/lib/lib/coopy/view.rb +20 -0
- data/lib/lib/coopy/viterbi.rb +177 -0
- data/lib/lib/haxe/ds/int_map.rb +19 -0
- data/lib/lib/haxe/ds/string_map.rb +19 -0
- data/lib/lib/haxe/format/json_parser.rb +265 -0
- data/lib/lib/haxe/format/json_printer.rb +240 -0
- data/lib/lib/haxe/imap.rb +10 -0
- data/lib/lib/haxe/io/bytes.rb +34 -0
- data/lib/lib/haxe/io/eof.rb +18 -0
- data/lib/lib/haxe/io/error.rb +22 -0
- data/lib/lib/haxe/io/output.rb +41 -0
- data/lib/lib/hx_overrides.rb +19 -0
- data/lib/lib/hx_sys.rb +74 -0
- data/lib/lib/lambda.rb +37 -0
- data/lib/lib/list.rb +36 -0
- data/lib/lib/math.rb +5 -0
- data/lib/lib/rb/boot.rb +39 -0
- data/lib/lib/rb/ruby_iterator.rb +50 -0
- data/lib/lib/reflect.rb +41 -0
- data/lib/lib/std.rb +12 -0
- data/lib/lib/string_buf.rb +19 -0
- data/lib/lib/sys/io/file_handle.rb +18 -0
- data/lib/lib/sys/io/file_output.rb +36 -0
- data/lib/lib/sys/io/hx_file.rb +20 -0
- data/lib/lib/type.rb +37 -0
- data/lib/lib/value_type.rb +23 -0
- data/lib/lib/x_list/list_iterator.rb +32 -0
- metadata +235 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class TableIO
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
def valid
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_content(name)
|
15
|
+
::Sys::Io::HxFile.get_content(name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def save_content(name,txt)
|
19
|
+
::Sys::Io::HxFile.save_content(name,txt)
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
def args
|
24
|
+
HxSys.args
|
25
|
+
end
|
26
|
+
|
27
|
+
def write_stdout(txt)
|
28
|
+
HxSys.stdout.write_string(txt)
|
29
|
+
end
|
30
|
+
|
31
|
+
def write_stderr(txt)
|
32
|
+
HxSys.stderr.write_string(txt)
|
33
|
+
end
|
34
|
+
|
35
|
+
def command(cmd,args)
|
36
|
+
begin
|
37
|
+
return HxSys.command(cmd,args)
|
38
|
+
rescue => e
|
39
|
+
e = hx_rescued(e)
|
40
|
+
return 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def async
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
def exists(path)
|
49
|
+
File.exist?(path)
|
50
|
+
end
|
51
|
+
|
52
|
+
def is_tty_known
|
53
|
+
false
|
54
|
+
end
|
55
|
+
|
56
|
+
def is_tty
|
57
|
+
return true if HxSys.get_env("GIT_PAGER_IN_USE") == "true"
|
58
|
+
false
|
59
|
+
end
|
60
|
+
|
61
|
+
def open_sqlite_database(path)
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def send_to_browser(html)
|
66
|
+
puts "do not know how to send to browser in this language"
|
67
|
+
end
|
68
|
+
|
69
|
+
haxe_me ["coopy", "TableIO"]
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class TableModifier
|
6
|
+
|
7
|
+
def initialize(t)
|
8
|
+
@t = t
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
attr_accessor :t
|
14
|
+
|
15
|
+
public
|
16
|
+
|
17
|
+
def remove_column(at)
|
18
|
+
fate = []
|
19
|
+
begin
|
20
|
+
_g1 = 0
|
21
|
+
_g = @t.get_width
|
22
|
+
while(_g1 < _g)
|
23
|
+
i = _g1
|
24
|
+
_g1+=1
|
25
|
+
if i < at
|
26
|
+
fate.push(i)
|
27
|
+
elsif i > at
|
28
|
+
fate.push(i - 1)
|
29
|
+
else
|
30
|
+
fate.push(-1)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
@t.insert_or_delete_columns(fate,@t.get_width - 1)
|
35
|
+
end
|
36
|
+
|
37
|
+
haxe_me ["coopy", "TableModifier"]
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class TableStream
|
6
|
+
|
7
|
+
def initialize(t)
|
8
|
+
@t = t
|
9
|
+
@at = -1
|
10
|
+
@h = t.get_height
|
11
|
+
@src = nil
|
12
|
+
if @h < 0
|
13
|
+
meta = t.get_meta
|
14
|
+
raise hx_raise("Cannot get meta information for table") if meta == nil
|
15
|
+
@src = meta.get_row_stream
|
16
|
+
raise hx_raise("Cannot iterate table") if @src == nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
attr_accessor :t
|
23
|
+
attr_accessor :at
|
24
|
+
attr_accessor :h
|
25
|
+
attr_accessor :src
|
26
|
+
attr_accessor :columns
|
27
|
+
attr_accessor :row
|
28
|
+
|
29
|
+
public
|
30
|
+
|
31
|
+
def fetch_columns
|
32
|
+
return @columns if @columns != nil
|
33
|
+
if @src != nil
|
34
|
+
@columns = @src.fetch_columns
|
35
|
+
return @columns
|
36
|
+
end
|
37
|
+
@columns = Array.new
|
38
|
+
begin
|
39
|
+
_g1 = 0
|
40
|
+
_g = @t.get_width
|
41
|
+
while(_g1 < _g)
|
42
|
+
i = _g1
|
43
|
+
_g1+=1
|
44
|
+
@columns.push(@t.get_cell(i,0))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
@columns
|
48
|
+
end
|
49
|
+
|
50
|
+
def fetch_row
|
51
|
+
return @src.fetch_row if @src != nil
|
52
|
+
return nil if @at >= @h
|
53
|
+
row = {}
|
54
|
+
begin
|
55
|
+
_g1 = 0
|
56
|
+
_g = @columns.length
|
57
|
+
while(_g1 < _g)
|
58
|
+
i = _g1
|
59
|
+
_g1+=1
|
60
|
+
begin
|
61
|
+
v = @t.get_cell(i,@at)
|
62
|
+
begin
|
63
|
+
value = v
|
64
|
+
row[@columns[i]] = value
|
65
|
+
end
|
66
|
+
v
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
row
|
71
|
+
end
|
72
|
+
|
73
|
+
def fetch
|
74
|
+
if @at == -1
|
75
|
+
@at+=1
|
76
|
+
self.fetch_columns if @src != nil
|
77
|
+
return true
|
78
|
+
end
|
79
|
+
if @src != nil
|
80
|
+
@at = 1
|
81
|
+
@row = self.fetch_row
|
82
|
+
return @row != nil
|
83
|
+
end
|
84
|
+
@at+=1
|
85
|
+
@at < @h
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_cell(x)
|
89
|
+
return @columns[x] if @at == 0
|
90
|
+
return @row[@columns[x]] if @row != nil
|
91
|
+
@t.get_cell(x,@at)
|
92
|
+
end
|
93
|
+
|
94
|
+
def width
|
95
|
+
self.fetch_columns
|
96
|
+
@columns.length
|
97
|
+
end
|
98
|
+
|
99
|
+
haxe_me ["coopy", "TableStream"]
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
module Coopy
|
2
|
+
class TableView < ::Coopy::Table
|
3
|
+
def initialize(data)
|
4
|
+
@data = data
|
5
|
+
@height = data.length
|
6
|
+
@width = 0
|
7
|
+
@width = data[0].length if @height>0
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_width() @width end
|
11
|
+
|
12
|
+
def get_height() @height end
|
13
|
+
|
14
|
+
def get_cell(x,y)
|
15
|
+
@data[y][x]
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_cell(x,y,c)
|
19
|
+
@data[y][x] = c
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
::Coopy::SimpleTable::table_to_string(self)
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_cell_view
|
27
|
+
::Coopy::SimpleView.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_resizable
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def resize(w,h)
|
35
|
+
@width = w
|
36
|
+
@height = h
|
37
|
+
@data.length.times do |i|
|
38
|
+
row = @data[i]
|
39
|
+
row = @data[i] = [] if row.nil?
|
40
|
+
while row.length<w
|
41
|
+
row << nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
while @data.length<h
|
45
|
+
row = []
|
46
|
+
w.times do |i|
|
47
|
+
row << nil
|
48
|
+
end
|
49
|
+
@data << row
|
50
|
+
end
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
54
|
+
def clear
|
55
|
+
@data.clear
|
56
|
+
@width = 0
|
57
|
+
@height = 0
|
58
|
+
end
|
59
|
+
|
60
|
+
def trim_blank
|
61
|
+
false
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_data
|
65
|
+
return @data
|
66
|
+
end
|
67
|
+
|
68
|
+
def insert_or_delete_rows(fate,hfate)
|
69
|
+
ndata = []
|
70
|
+
fate.length.times do |i|
|
71
|
+
j = fate[i];
|
72
|
+
ndata[j] = @data[i] if j!=-1
|
73
|
+
end
|
74
|
+
@data.clear
|
75
|
+
ndata.length.times do |i|
|
76
|
+
@data[i] = ndata[i]
|
77
|
+
end
|
78
|
+
self.resize(@width,hfate)
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
def insert_or_delete_columns(fate,wfate)
|
83
|
+
if wfate==@width and wfate==fate.length
|
84
|
+
eq = true
|
85
|
+
wfate.times do |i|
|
86
|
+
if fate[i]!=i
|
87
|
+
eq = false
|
88
|
+
break
|
89
|
+
end
|
90
|
+
end
|
91
|
+
return true if eq
|
92
|
+
end
|
93
|
+
@height.times do |i|
|
94
|
+
row = @data[i]
|
95
|
+
nrow = []
|
96
|
+
@width.times do |j|
|
97
|
+
next if fate[j]==-1
|
98
|
+
nrow[fate[j]] = row[j]
|
99
|
+
end
|
100
|
+
while nrow.length<wfate
|
101
|
+
nrow << nil
|
102
|
+
end
|
103
|
+
@data[i] = nrow
|
104
|
+
end
|
105
|
+
@width = wfate
|
106
|
+
if @width == 0
|
107
|
+
@height = 0
|
108
|
+
end
|
109
|
+
true
|
110
|
+
end
|
111
|
+
|
112
|
+
def is_similar(alt)
|
113
|
+
return false if alt.width!=@width
|
114
|
+
return false if alt.height!=@height
|
115
|
+
@width.times do |c|
|
116
|
+
@height.times do |r|
|
117
|
+
v1 = "" + self.get_cell(c,r)
|
118
|
+
v2 = "" + alt.get_cell(c,r)
|
119
|
+
if (v1!=v2)
|
120
|
+
puts("MISMATCH "+ v1 + " " + v2);
|
121
|
+
return false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
true
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def clone
|
130
|
+
result = TableView.new([])
|
131
|
+
result.resize(@width,@height)
|
132
|
+
@width.times do |c|
|
133
|
+
@height.times do |r|
|
134
|
+
result.set_cell(c,r,self.get_cell(c,r))
|
135
|
+
end
|
136
|
+
end
|
137
|
+
result
|
138
|
+
end
|
139
|
+
|
140
|
+
def create
|
141
|
+
TableView.new([])
|
142
|
+
end
|
143
|
+
|
144
|
+
def get_meta
|
145
|
+
nil
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class Tables
|
6
|
+
|
7
|
+
def initialize(template)
|
8
|
+
@template = template
|
9
|
+
@tables = {}
|
10
|
+
@table_order = Array.new
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
attr_accessor :template
|
16
|
+
attr_accessor :tables
|
17
|
+
attr_accessor :table_order
|
18
|
+
|
19
|
+
public
|
20
|
+
|
21
|
+
attr_accessor :alignment
|
22
|
+
|
23
|
+
def add(name)
|
24
|
+
t = @template.clone
|
25
|
+
@tables[name] = t
|
26
|
+
@table_order.push(name)
|
27
|
+
t
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_order
|
31
|
+
@table_order
|
32
|
+
end
|
33
|
+
|
34
|
+
def get(name)
|
35
|
+
@tables[name]
|
36
|
+
end
|
37
|
+
|
38
|
+
def one
|
39
|
+
@tables[@table_order[0]]
|
40
|
+
end
|
41
|
+
|
42
|
+
def has_ins_del
|
43
|
+
return false if @alignment == nil
|
44
|
+
return true if @alignment.has_addition
|
45
|
+
return true if @alignment.has_removal
|
46
|
+
false
|
47
|
+
end
|
48
|
+
|
49
|
+
haxe_me ["coopy", "Tables"]
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class TerminalDiffRender
|
6
|
+
|
7
|
+
def initialize(flags = nil,delim = nil,diff = true)
|
8
|
+
@align_columns = true
|
9
|
+
@wide_columns = false
|
10
|
+
@use_glyphs = true
|
11
|
+
@flags = flags
|
12
|
+
if flags != nil
|
13
|
+
@align_columns = false if flags.padding_strategy == "dense"
|
14
|
+
@wide_columns = true if flags.padding_strategy == "sparse"
|
15
|
+
@use_glyphs = flags.use_glyphs
|
16
|
+
end
|
17
|
+
if delim != nil
|
18
|
+
@delim = delim
|
19
|
+
else
|
20
|
+
@delim = ","
|
21
|
+
end
|
22
|
+
@diff = diff
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
attr_accessor :codes
|
28
|
+
attr_accessor :t
|
29
|
+
attr_accessor :csv
|
30
|
+
attr_accessor :v
|
31
|
+
attr_accessor :align_columns
|
32
|
+
attr_accessor :wide_columns
|
33
|
+
attr_accessor :use_glyphs
|
34
|
+
attr_accessor :flags
|
35
|
+
attr_accessor :delim
|
36
|
+
attr_accessor :diff
|
37
|
+
|
38
|
+
public
|
39
|
+
|
40
|
+
def align_columns(enable)
|
41
|
+
@align_columns = enable
|
42
|
+
end
|
43
|
+
|
44
|
+
def render(t)
|
45
|
+
@csv = ::Coopy::Csv.new
|
46
|
+
result = ""
|
47
|
+
w = t.get_width
|
48
|
+
h = t.get_height
|
49
|
+
txt = ""
|
50
|
+
@t = t
|
51
|
+
@v = t.get_cell_view
|
52
|
+
@codes = {}
|
53
|
+
@codes["header"] = "\x1B[0;1m"
|
54
|
+
@codes["minor"] = "\x1B[33m"
|
55
|
+
@codes["done"] = "\x1B[0m"
|
56
|
+
@codes["meta"] = "\x1B[0;1m"
|
57
|
+
@codes["spec"] = "\x1B[35;1m"
|
58
|
+
@codes["add"] = "\x1B[32;1m"
|
59
|
+
@codes["conflict"] = "\x1B[33;1m"
|
60
|
+
@codes["modify"] = "\x1B[34;1m"
|
61
|
+
@codes["remove"] = "\x1B[31;1m"
|
62
|
+
sizes = nil
|
63
|
+
sizes = self.pick_sizes(t) if @align_columns
|
64
|
+
begin
|
65
|
+
_g = 0
|
66
|
+
while(_g < h)
|
67
|
+
y = _g
|
68
|
+
_g+=1
|
69
|
+
target = 0
|
70
|
+
at = 0
|
71
|
+
begin
|
72
|
+
_g1 = 0
|
73
|
+
while(_g1 < w)
|
74
|
+
x = _g1
|
75
|
+
_g1+=1
|
76
|
+
if sizes != nil
|
77
|
+
spaces = target - at
|
78
|
+
begin
|
79
|
+
_g2 = 0
|
80
|
+
while(_g2 < spaces)
|
81
|
+
i = _g2
|
82
|
+
_g2+=1
|
83
|
+
txt += " "
|
84
|
+
at+=1
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
txt += _hx_str(@codes["minor"]) + _hx_str(@delim) + _hx_str(@codes["done"]) if x > 0
|
89
|
+
txt += self.get_text(x,y,true)
|
90
|
+
if sizes != nil
|
91
|
+
bit = self.get_text(x,y,false)
|
92
|
+
at += bit.length
|
93
|
+
target += sizes[x]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
txt += "\r\n"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
@t = nil
|
101
|
+
@v = nil
|
102
|
+
@csv = nil
|
103
|
+
@codes = nil
|
104
|
+
txt
|
105
|
+
end
|
106
|
+
|
107
|
+
protected
|
108
|
+
|
109
|
+
def get_text(x,y,color)
|
110
|
+
val = @t.get_cell(x,y)
|
111
|
+
cell = ::Coopy::DiffRender.render_cell(@t,@v,x,y)
|
112
|
+
if color && @diff
|
113
|
+
code = nil
|
114
|
+
code = @codes[cell.category] if cell.category != nil
|
115
|
+
if cell.category_given_tr != nil
|
116
|
+
code_tr = @codes[cell.category_given_tr]
|
117
|
+
code = code_tr if code_tr != nil
|
118
|
+
end
|
119
|
+
if code != nil
|
120
|
+
separator = nil
|
121
|
+
if @use_glyphs
|
122
|
+
separator = cell.pretty_separator
|
123
|
+
else
|
124
|
+
separator = cell.separator
|
125
|
+
end
|
126
|
+
if cell.rvalue != nil
|
127
|
+
val = _hx_str(@codes["remove"]) + _hx_str(cell.lvalue) + _hx_str(@codes["modify"]) + _hx_str(separator) + _hx_str(@codes["add"]) + _hx_str(cell.rvalue) + _hx_str(@codes["done"])
|
128
|
+
val = _hx_str(@codes["conflict"]) + _hx_str(cell.pvalue) + _hx_str(@codes["modify"]) + _hx_str(separator) + _hx_str(val.to_s) if cell.pvalue != nil
|
129
|
+
else
|
130
|
+
if @use_glyphs
|
131
|
+
val = cell.pretty_value
|
132
|
+
else
|
133
|
+
val = cell.value
|
134
|
+
end
|
135
|
+
val = _hx_str(code) + _hx_str(val.to_s) + _hx_str(@codes["done"])
|
136
|
+
end
|
137
|
+
end
|
138
|
+
elsif color && !@diff
|
139
|
+
val = _hx_str(@codes["header"]) + _hx_str(val.to_s) + _hx_str(@codes["done"]) if y == 0
|
140
|
+
elsif @use_glyphs
|
141
|
+
val = cell.pretty_value
|
142
|
+
else
|
143
|
+
val = cell.value
|
144
|
+
end
|
145
|
+
@csv.render_cell(@v,val)
|
146
|
+
end
|
147
|
+
|
148
|
+
def pick_sizes(t)
|
149
|
+
w = t.get_width
|
150
|
+
h = t.get_height
|
151
|
+
v = t.get_cell_view
|
152
|
+
csv = ::Coopy::Csv.new
|
153
|
+
sizes = Array.new
|
154
|
+
row = -1
|
155
|
+
total = w - 1
|
156
|
+
begin
|
157
|
+
_g = 0
|
158
|
+
while(_g < w)
|
159
|
+
x = _g
|
160
|
+
_g+=1
|
161
|
+
m = 0
|
162
|
+
m2 = 0
|
163
|
+
mmax = 0
|
164
|
+
mmostmax = 0
|
165
|
+
mmin = -1
|
166
|
+
begin
|
167
|
+
_g1 = 0
|
168
|
+
while(_g1 < h)
|
169
|
+
y = _g1
|
170
|
+
_g1+=1
|
171
|
+
txt = self.get_text(x,y,false)
|
172
|
+
row = y if txt == "@@" && row == -1 && @diff
|
173
|
+
row = y if row == -1 && !@diff
|
174
|
+
len = txt.length
|
175
|
+
mmin = len if y == row
|
176
|
+
m += len
|
177
|
+
m2 += len * len
|
178
|
+
mmax = len if len > mmax
|
179
|
+
end
|
180
|
+
end
|
181
|
+
mean = m / h
|
182
|
+
stddev = Math.sqrt(m2 / h - mean * mean)
|
183
|
+
most = (mean + stddev * 2 + 0.5).to_i
|
184
|
+
begin
|
185
|
+
_g11 = 0
|
186
|
+
while(_g11 < h)
|
187
|
+
y1 = _g11
|
188
|
+
_g11+=1
|
189
|
+
txt1 = self.get_text(x,y1,false)
|
190
|
+
len1 = txt1.length
|
191
|
+
if len1 <= most
|
192
|
+
mmostmax = len1 if len1 > mmostmax
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
full = mmax
|
197
|
+
most = mmostmax
|
198
|
+
if mmin != -1
|
199
|
+
most = mmin if most < mmin
|
200
|
+
end
|
201
|
+
most = full if @wide_columns
|
202
|
+
sizes.push(most)
|
203
|
+
total += most
|
204
|
+
end
|
205
|
+
end
|
206
|
+
return nil if total > 130
|
207
|
+
sizes
|
208
|
+
end
|
209
|
+
|
210
|
+
haxe_me ["coopy", "TerminalDiffRender"]
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|