Class: VER::Buffer::MatchingBrace

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

Constant Summary collapse

NAME =
'ver.highlight.brace'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(buffer, name = NAME) ⇒ MatchingBrace

Returns a new instance of MatchingBrace.



6
7
8
9
10
# File 'lib/ver/buffer/matching_brace.rb', line 6

def initialize(buffer, name = NAME)
  super

  configure background: '#ff0', foreground: '#00f'
end

Instance Method Details

#refresh(index = buffer.at_insert) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/ver/buffer/matching_brace.rb', line 12

def refresh(index = buffer.at_insert)
  remove('1.0', 'end')

  from, to = index.matching_brace_indices
  if from && to
    add(from, from + '1 chars', to, to + '1 chars')
  end
end