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.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/watobo/gui/chat_diff.rb', line 87 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
42 43 44 |
# File 'lib/watobo/gui/chat_diff.rb', line 42 def highlightChanges(textWidget, text, diff_blocks) end |
#makeRowVisible(row) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/watobo/gui/chat_diff.rb', line 47 def makeRowVisible(row) data_rows = @dataText.to_s.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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/watobo/gui/chat_diff.rb', line 58 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
38 39 40 |
# File 'lib/watobo/gui/chat_diff.rb', line 38 def textWidth @textWidth end |
#textWidth=(cols) ⇒ Object
32 33 34 35 36 |
# File 'lib/watobo/gui/chat_diff.rb', line 32 def textWidth=(cols) @textWidth = cols @dataText.wrapColumns = cols end |