Sha256: 52d146c761400df4426b6e638503e03053d46da1cd2ef0d124cd3141a9176745

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

module VER
  class Buffer
    class MarkupUnderlineLink < Tag
      NAME = 'markup.underline.link'.freeze

      def initialize(buffer, name = NAME)
        super

        configure underline: true, foreground: '#0ff'
        bind('<1>') do |event|
          current = buffer.index('current')
          uri = ranges.find{|range|
            next unless range.first <= current && range.last >= current
            range.get
          }

          if uri
            browser = buffer.options.http_browser
            system(*browser, uri)
            buffer.message "Opening %p in %p" % [uri, browser]
          end
        end
      end

      def refresh(options = {})
        buffer.tag_all_matching(self, /https?:\/\/[^<>)\]}\s'"]+/, options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ver-2010.08 lib/ver/buffer/markup_underline_link.rb