module ReadlineNG
  class ChunkedString

    def initialize(str="")
      @buf = str
    end

    def <<(str)
      @buf += str
    end

    def each_chunk
      until @buf.empty?
        yield @buf.slice!(0)
      end
    end

  end
end

module ReadlineNG
  class ChunkedString

    def initialize(str="")
      @buf = str
    end

    def <<(str)
      @buf += str
    end

    def each_chunk
      until @buf.empty?
        t = @buf.slice!(0)
        if t == "\e"
          t += @buf.slice!(0..1)
        end

        yield t
      end
    end

  end
end

Make the optimistic assumption that all escapes are 2 bytes
Make the optimistic assumption that all escapes are 2 bytes
