Class: VER::Buffer::MarkupUnderlineLink

Inherits:
Tag
  • Object
show all
Defined in:
lib/ver/buffer/markup_underline_link.rb

Constant Summary collapse

NAME =
'markup.underline.link'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(buffer, name = NAME) ⇒ MarkupUnderlineLink

Returns a new instance of MarkupUnderlineLink.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ver/buffer/markup_underline_link.rb', line 6

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

Instance Method Details

#refresh(options = {}) ⇒ Object



25
26
27
# File 'lib/ver/buffer/markup_underline_link.rb', line 25

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