Class: VER::Buffer::MarkupUnderlineLink
- Inherits:
-
Tag
- Object
- Tag
- VER::Buffer::MarkupUnderlineLink
- Defined in:
- lib/ver/buffer/markup_underline_link.rb
Constant Summary collapse
- NAME =
'markup.underline.link'.freeze
Instance Method Summary collapse
-
#initialize(buffer, name = NAME) ⇒ MarkupUnderlineLink
constructor
A new instance of MarkupUnderlineLink.
- #refresh(options = {}) ⇒ Object
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..http_browser system(*browser, uri) buffer. "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( = {}) buffer.tag_all_matching(self, /https?:\/\/[^<>)\]}\s'"]+/, ) end |