Class: Watobo::Gui::ChatDiffFrame
- Inherits:
-
FXVerticalFrame
- Object
- FXVerticalFrame
- Watobo::Gui::ChatDiffFrame
- Defined in:
- lib/watobo/gui/chat_diff.rb
Instance Method Summary collapse
- #highlightChanges(textWidget, text, diff_blocks) ⇒ Object
-
#initialize(owner, opts) ⇒ ChatDiffFrame
constructor
A new instance of ChatDiffFrame.
- #makeRowVisible(row) ⇒ Object
- #showDiff(data, diff_blocks) ⇒ Object
- #textWidth ⇒ Object
- #textWidth=(cols) ⇒ Object
Constructor Details
#initialize(owner, opts) ⇒ ChatDiffFrame
Returns a new instance of ChatDiffFrame.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/watobo/gui/chat_diff.rb', line 68 def initialize(owner, opts) @textWidth = 80 @diffType = DIFF_TYPE_ORIG @style = 1 super(owner, :opts => opts[:opts]) @textWidth = opts[:textWidth] if opts[:textWidth] @diffType = opts[:diffType] if opts[:diffType] @style = 2 if @diffType == DIFF_TYPE_NEW #text_opts = LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_FIXEDWRAP|TEXT_WORDWRAP|FRAME_SUNKEN text_opts = LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN hs_green = FXHiliteStyle.new hs_green.normalForeColor = FXRGBA(255,255,255,255) hs_green.normalBackColor = FXRGBA(0,255,0,1) hs_green.style = FXText::STYLE_BOLD hs_red = FXHiliteStyle.new hs_red.normalForeColor = FXRGBA(255,255,255,255) hs_red.normalBackColor = FXRGBA(255,0,0,1) hs_red.style = FXText::STYLE_BOLD frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED|FRAME_THICK, :padding => 0) data_frame = FXVerticalFrame.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0) @dataText = FXText.new(data_frame, :opts => text_opts) @dataText.styled = true @dataText.hiliteStyles = [ hs_red, hs_green] @dataText.wrapColumns = @textWidth @dataText.visibleColumns = @textWidth @dataText.editable = false end |
Instance Method Details
#highlightChanges(textWidget, text, diff_blocks) ⇒ Object
21 22 23 |
# File 'lib/watobo/gui/chat_diff.rb', line 21 def highlightChanges(textWidget, text, diff_blocks) end |
#makeRowVisible(row) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/watobo/gui/chat_diff.rb', line 26 def makeRowVisible(row) dummy = @dataText.to_s dummy = dummy.unpack("C*").pack("C*") data_rows = dummy.split("\n") if row > 0 then pos = data_rows.slice(0..row-1).join("\n").length+1 else pos = 0 end @dataText.makePositionVisible(@dataText.to_s.length) @dataText.makePositionVisible(pos) end |
#showDiff(data, diff_blocks) ⇒ Object
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 |
# File 'lib/watobo/gui/chat_diff.rb', line 39 def showDiff(data, diff_blocks) data_pos = 0 diff_pos = 0 @dataText.setText('') begin if diff_blocks.length > 0 then data.each do |d| if diff_blocks[diff_pos].position == data_pos then @dataText.appendStyledText(data[data_pos]+"\n", @style) diff_pos += 1 else @dataText.appendText(data[data_pos]+"\n") end data_pos += 1 break if diff_pos >= diff_blocks.length end end while data_pos < data.length @dataText.appendText(data[data_pos]+"\n") data_pos += 1 end rescue => bang puts bang end end |
#textWidth ⇒ Object
17 18 19 |
# File 'lib/watobo/gui/chat_diff.rb', line 17 def textWidth @textWidth end |
#textWidth=(cols) ⇒ Object
11 12 13 14 15 |
# File 'lib/watobo/gui/chat_diff.rb', line 11 def textWidth=(cols) @textWidth = cols @dataText.wrapColumns = cols end |