Class: Rvim::Marks

Inherits:
Object
  • Object
show all
Defined in:
lib/rvim/marks.rb

Overview

Local marks (a-z) live in a Marks instance owned by each Buffer. Global marks (A-Z) live in a separate Marks-like store on Editor; their entries carry a buffer_id so jumps can switch buffers.

Instance Method Summary collapse

Constructor Details

#initializeMarks

Returns a new instance of Marks.



8
9
10
# File 'lib/rvim/marks.rb', line 8

def initialize
  @table = {}
end

Instance Method Details

#clearObject



18
19
20
# File 'lib/rvim/marks.rb', line 18

def clear
  @table.clear
end

#get(name, editor) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rvim/marks.rb', line 22

def get(name, editor)
  case name
  when "'", '`'
    editor.previous_jump_position
  when '<', '>'
    editor.visual_position(name)
  when '.'
    editor.last_change_pos
  when '^'
    editor.last_insert_pos
  when '['
    editor.last_yank_range_start
  when ']'
    editor.last_yank_range_end
  when /\A[a-z]\z/
    @table[name]
  when /\A[A-Z]\z/
    editor.global_mark(name)
  end
end

#set(name, line, col) ⇒ Object



12
13
14
15
16
# File 'lib/rvim/marks.rb', line 12

def set(name, line, col)
  return unless name =~ /\A[a-z]\z/

  @table[name] = [line, col]
end