Sha256: 3df62267c9849f34c726a912fc83843d9305e2dbaf92d5a0066521fca5101332

Contents?: true

Size: 582 Bytes

Versions: 2

Compression:

Stored size: 582 Bytes

Contents

module VER
  module Methods
    module AutoFill
      module_function

      def auto_fill_space(text)
        enabled = text.store(self, :enable)
        return text.insert(:insert, ' ') unless enabled

        from, to = 'insert linestart', 'insert lineend'
        line = text.get(from, to)

        if line.size < (text.options.auto_fill_width || 78)
          text.insert(:insert, ' ')
        else
          chunks = line.scan(/(.{1,78}[^\s])(?:\s|$)/)
          lines = chunks.join("\n") << ' '
          text.replace(from, to, lines)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ver-2010.08 lib/ver/methods/autofill.rb
ver-2010.02 lib/ver/methods/autofill.rb