Method: RubyCurses::TextView#set_content

Defined in:
lib/rbcurse/core/widgets/rtextview.rb

#set_content(list, config = {}) ⇒ Object

send in a list e.g. set_content File.open(“README.txt”,“r”).readlines set wrap at time of passing :WRAP_NONE :WRAP_WORD XXX if we widen the textview later, as in a vimsplit that data will sti1ll be wrapped at this width !!

2011-12-3 changed wrap to hash, so we can use content_type :ansi, :tmux


105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/rbcurse/core/widgets/rtextview.rb', line 105

def set_content list, config = {} #wrap = :WRAP_NONE
  @content_type = config[:content_type]
  _title = config[:title]
  self.title = _title if _title
  if @content_type
    formatted_text list, @content_type
    return
  end
  # please note that content type is lost once formatted text does it's work
  @wrap_policy = config[:wrap]
  if list.is_a? String
    if @wrap_policy == :WRAP_WORD
      data = wrap_text list
      @list = data.split("\n")
    else
      @list = list.split("\n")
    end
  elsif list.is_a? Array
    if @wrap_policy == :WRAP_WORD
      data = wrap_text list.join(" ")
      @list = data.split("\n")
    else
      @list = list
    end
  else
    raise "set_content expects Array not #{list.class}"
  end
  init_vars
end