def paint  #:nodoc:
    
      $log.debug "XXX TEXTVIEW repaint HAPPENING #{@current_index} "
      my_win = nil
      if @form
        my_win = @form.window
      else
        my_win = @target_window
      end
      @graphic = my_win unless @graphic
      if @formatted_text
        $log.debug "XXX:  INSIDE FORMATTED TEXT "

        # I don't want to do this in 20 places and then have to change
        # it and retest. Let me push it to util.
        l = Canis::Utils.parse_formatted_text(@color_parser,
                                               @formatted_text)

        #cp = Chunks::ColorParser.new @color_parser
        #l = []
        #@formatted_text.each { |e| l << cp.convert_to_chunk(e) }

        @old_content_type = @content_type
        text(l)
        @formatted_text = nil

      end

      print_borders if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes
      rc = row_count
      maxlen = @maxlen || @width-@internal_width
      #$log.debug " #{@name} textview repaint width is #{@width}, height is #{@height} , maxlen #{maxlen}/ #{@maxlen}, #{@graphic.name} roff #{@row_offset} coff #{@col_offset}" 
      tm = get_content
      tr = @toprow
      acolor = get_color $datacolor
      h = scrollatrow() 
      r,c = rowcol
      @longest_line = @width-@internal_width #maxlen
      0.upto(h) do |hh|
        crow = tr+hh
        if crow < rc
            #focussed = @current_index == crow ? true : false 
            #selected = is_row_selected crow
            content = tm[crow]
            # next call modified string. you may wanna dup the string.
            # rlistbox does
            # scrolling fails if you do not dup, since content gets truncated
            if content.is_a? String
              content = content.dup
              sanitize(content) if @sanitization_required
              truncate content
              @graphic.printstring  r+hh, c, "%-*s" % [@width-@internal_width,content], 
                acolor, @attr
            elsif content.is_a? Chunks::ChunkLine
              # clear the line first
              @graphic.printstring  r+hh, c, " "* (@width-@internal_width), 
                acolor, @attr
              # move back
              @graphic.wmove r+hh, c
              # either we have to loop through and put in default color and attr
              # or pass it to show_col
              a = get_attrib @attrib
              # FIXME this does not clear till the eol
              @graphic.show_colored_chunks content, acolor, a, @width-@internal_width, @pcol
            elsif content.is_a? Chunks::Chunk
              raise "TODO chunk in textview"
            elsif content.is_a? Array
                # several chunks in one row - NOTE Very experimental may change
              if content[0].is_a? Array
                # clearing the line since colored_chunks does not yet XXX FIXME if possible
                @graphic.printstring  r+hh, c, " "* (@width-@internal_width), 
                  acolor, @attr
                @graphic.wmove r+hh, c
                # either we have to loop through and put in default color and attr
                # or pass it to show_col
                a = get_attrib @attrib
                # FIXME this does not clear till the eol
                # # NOTE 2013-03-08 - 17:37 pls add width to avoid overflow
                @graphic.show_colored_chunks content, acolor, a, @width-@internal_width
                #@graphic.show_colored_chunks content, acolor, a
              else
                # a single row chunk - NOTE Very experimental may change
                text = content[1].dup
                sanitize(text) if @sanitization_required
                truncate text
                @graphic.printstring  r+hh, c, "%-*s" % [@width-@internal_width,text], 
                  content[0] || acolor, content[2] || @attr
              end
            end

            # highlighting search results.
            if @search_found_ix == tr+hh
              if !@find_offset.nil?
                # handle exceed bounds, and if scrolling
                if @find_offset1 < maxlen+@pcol and @find_offset > @pcol
                @graphic.mvchgat(y=r+hh, x=c+@find_offset-@pcol, @find_offset1-@find_offset, Ncurses::A_NORMAL, $reversecolor, nil)
                end
              end
            end

        else
          # clear rows
          @graphic.printstring r+hh, c, " " * (@width-@internal_width), acolor,@attr
        end
      end


      @repaint_required = false
      @repaint_footer_required = true
      @repaint_all = false 
      # 2011-10-15 
      @widget_scrolled = false
      @record_changed = false
      @property_changed = false
      @old_pcol = @pcol

    end
def paint  #:nodoc:
    
      $log.debug "XXX TEXTVIEW repaint HAPPENING #{@current_index} "
      my_win = nil
      if @form
        my_win = @form.window
      else
        my_win = @target_window
      end
      @graphic = my_win unless @graphic
      if @formatted_text
        $log.debug "XXX:  INSIDE FORMATTED TEXT "

        # I don't want to do this in 20 places and then have to change
        # it and retest. Let me push it to util.
        l = Canis::Utils.parse_formatted_text(@color_parser,
                                               @formatted_text)

        #cp = Chunks::ColorParser.new @color_parser
        #l = []
        #@formatted_text.each { |e| l << cp.convert_to_chunk(e) }

        @old_content_type = @content_type
        text(l)
        @formatted_text = nil

      end

      print_borders if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes
      rc = row_count
      maxlen = @maxlen || @width-@internal_width
      #$log.debug " #{@name} textview repaint width is #{@width}, height is #{@height} , maxlen #{maxlen}/ #{@maxlen}, #{@graphic.name} roff #{@row_offset} coff #{@col_offset}" 
      tm = get_content
      tr = @toprow
      acolor = get_color $datacolor
      h = scrollatrow() 
      r,c = rowcol
      @longest_line = @width-@internal_width #maxlen
      0.upto(h) do |hh|
        crow = tr+hh
        if crow < rc
            #focussed = @current_index == crow ? true : false 
            #selected = is_row_selected crow
            content = tm[crow]
            # next call modified string. you may wanna dup the string.
            # rlistbox does
            # scrolling fails if you do not dup, since content gets truncated
            if content.is_a? String
              content = content.dup
              sanitize(content) if @sanitization_required
              truncate content
              @graphic.printstring  r+hh, c, "%-*s" % [@width-@internal_width,content], 
                acolor, @attr
            elsif content.is_a? Chunks::ChunkLine
              # clear the line first
              @graphic.printstring  r+hh, c, " "* (@width-@internal_width), 
                acolor, @attr
              # move back
              @graphic.wmove r+hh, c
              # either we have to loop through and put in default color and attr
              # or pass it to show_col
              a = get_attrib @attrib
              # FIXME this does not clear till the eol
              @graphic.show_colored_chunks content, acolor, a, @width-@internal_width, @pcol
            elsif content.is_a? Chunks::Chunk
              raise "TODO chunk in textview"
            elsif content.is_a? Array
                # several chunks in one row - NOTE Very experimental may change
              if content[0].is_a? Array
                # clearing the line since colored_chunks does not yet XXX FIXME if possible
                @graphic.printstring  r+hh, c, " "* (@width-@internal_width), 
                  acolor, @attr
                @graphic.wmove r+hh, c
                # either we have to loop through and put in default color and attr
                # or pass it to show_col
                a = get_attrib @attrib
                # FIXME this does not clear till the eol
                # # NOTE 2013-03-08 - 17:37 pls add width to avoid overflow
                @graphic.show_colored_chunks content, acolor, a, @width-@internal_width
                #@graphic.show_colored_chunks content, acolor, a
              else
                # a single row chunk - NOTE Very experimental may change
                text = content[1].dup
                sanitize(text) if @sanitization_required
                truncate text
                @graphic.printstring  r+hh, c, "%-*s" % [@width-@internal_width,text], 
                  content[0] || acolor, content[2] || @attr
              end
            end

            # highlighting search results.
            if @search_found_ix == tr+hh
              if !@find_offset.nil?
                # handle exceed bounds, and if scrolling
                if @find_offset1 < maxlen+@pcol and @find_offset > @pcol
                @graphic.mvchgat(y=r+hh, x=c+@find_offset-@pcol, @find_offset1-@find_offset, Ncurses::A_NORMAL, $reversecolor, nil)
                end
              end
            end

        else
          # clear rows
          @graphic.printstring r+hh, c, " " * (@width-@internal_width), acolor,@attr
        end
      end


      @repaint_required = false
      @repaint_footer_required = true
      @repaint_all = false 
      # 2011-10-15 
      @widget_scrolled = false
      @record_changed = false
      @property_changed = false
      @old_pcol = @pcol

    end
NOTE: earlier print_border was called only once in constructor, but when
+ a window is resized, and destroyed, then this was never called again, so the
+ border would not be seen in splitpane unless the width coincided exactly with
+ what is calculated in divider_location.