Method: RubyCurses::TextView#truncate

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

#truncate(content) ⇒ Object

returns only the visible portion of string taking into account display length and horizontal scrolling. MODIFIES STRING



598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'lib/rbcurse/core/widgets/rtextview.rb', line 598

def truncate content  #:nodoc:
  _maxlen = @maxlen || @width-@internal_width
  _maxlen = @width-@internal_width if _maxlen > @width-@internal_width # take care of decrease in width
  if !content.nil? 
    if content.length > _maxlen # only show maxlen
      @longest_line = content.length if content.length > @longest_line
      #content = content[@pcol..@pcol+maxlen-1] 
      content.replace(content[@pcol..@pcol+_maxlen-1] || "")
    else
      if @pcol > 0
          content.replace(content[@pcol..-1]  || "")
      end
    end
  end
  content
end