Class: Coopy::TerminalDiffRender

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/coopy/terminal_diff_render.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ TerminalDiffRender

Returns a new instance of TerminalDiffRender.



7
8
9
# File 'lib/lib/coopy/terminal_diff_render.rb', line 7

def initialize
  @align_columns = true
end

Instance Attribute Details

#align_columns(enable) ⇒ Object

Returns the value of attribute align_columns.



17
18
19
# File 'lib/lib/coopy/terminal_diff_render.rb', line 17

def align_columns
  @align_columns
end

Instance Method Details

#render(t) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/lib/coopy/terminal_diff_render.rb', line 25

def render(t)
  @csv = ::Coopy::Csv.new
  result = ""
  w = t.get_width
  h = t.get_height
  txt = ""
  @t = t
  @v = t.get_cell_view
  @codes = {}
  @codes["header"] = "\x1B[0;1m"
  @codes["meta"] = "\x1B[0;1m"
  @codes["spec"] = "\x1B[35;1m"
  @codes["add"] = "\x1B[32;1m"
  @codes["conflict"] = "\x1B[33;1m"
  @codes["modify"] = "\x1B[34;1m"
  @codes["remove"] = "\x1B[31;1m"
  @codes["minor"] = "\x1B[2m"
  @codes["done"] = "\x1B[0m"
  sizes = nil
  sizes = self.pick_sizes(t) if @align_columns
  begin
    _g = 0
    while(_g < h) 
      y = _g
      _g+=1
      begin
        _g1 = 0
        while(_g1 < w) 
          x = _g1
          _g1+=1
          txt += _hx_str(@codes["minor"]) + "," + _hx_str(@codes["done"]) if x > 0
          txt += self.get_text(x,y,true)
          if sizes != nil 
            bit = self.get_text(x,y,false)
            begin
              _g3 = 0
              _g2 = sizes[x] - bit.length
              while(_g3 < _g2) 
                i = _g3
                _g3+=1
                txt += " "
              end
            end
          end
        end
      end
      txt += "\r\n"
    end
  end
  @t = nil
  @v = nil
  @csv = nil
  @codes = nil
  txt
end