Class: GitCrecord::Diff::Line
Constant Summary
Constants inherited
from Difference
Difference::REVERSE_SELECTED_MAP, Difference::SELECTED_MAP, Difference::SELECTION_MARKER_WIDTH
Instance Attribute Summary collapse
Attributes inherited from Difference
#subs, #y1, #y2
Instance Method Summary
collapse
Methods inherited from Difference
#content_width, #max_height, #prefix, #prefix_style, #print, #selectable_subs, #strings
Constructor Details
#initialize(line, reverse: false) ⇒ Line
Returns a new instance of Line.
45
46
47
48
49
|
# File 'lib/git_crecord/diff/line.rb', line 45
def initialize(line, reverse: false)
@line = line
@selected = true
super(reverse: reverse)
end
|
Instance Attribute Details
#selected ⇒ Object
Returns the value of attribute selected.
43
44
45
|
# File 'lib/git_crecord/diff/line.rb', line 43
def selected
@selected
end
|
Instance Method Details
#add? ⇒ Boolean
59
60
61
|
# File 'lib/git_crecord/diff/line.rb', line 59
def add?
@line.start_with?('+')
end
|
#del? ⇒ Boolean
63
64
65
|
# File 'lib/git_crecord/diff/line.rb', line 63
def del?
@line.start_with?('-')
end
|
#expanded ⇒ Object
75
76
77
|
# File 'lib/git_crecord/diff/line.rb', line 75
def expanded
false
end
|
#generate_diff ⇒ Object
79
80
81
82
83
84
|
# File 'lib/git_crecord/diff/line.rb', line 79
def generate_diff
return " #{@line[1..-1]}" if !selected && del?
return @line if selected
nil
end
|
#selectable? ⇒ Boolean
67
68
69
|
# File 'lib/git_crecord/diff/line.rb', line 67
def selectable?
add? || del?
end
|
#style(is_highlighted) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/git_crecord/diff/line.rb', line 86
def style(is_highlighted)
return UI::Color.hl if is_highlighted
return UI::Color.green if add?
return UI::Color.red if del?
UI::Color.normal
end
|
#to_s ⇒ Object
51
52
53
|
# File 'lib/git_crecord/diff/line.rb', line 51
def to_s
@to_s ||= @line.gsub(/\t/, Git.tab)
end
|
#x_offset ⇒ Object
55
56
57
|
# File 'lib/git_crecord/diff/line.rb', line 55
def x_offset
6
end
|