class Amun::Buffer
A buffer could present any kind of IO object (File, StringIO…etc) also it has a major mode responsible update lines and visual lines
Attributes
current[W]
instances[W]
io[RW]
major_mode[RW]
mark[W]
minor_modes[RW]
name[RW]
point[W]
text[RW]
Public Class Methods
current()
click to toggle source
# File lib/amun/buffer.rb, line 82 def current @current ||= scratch end
instances()
click to toggle source
# File lib/amun/buffer.rb, line 78 def instances @instances ||= Set.new end
messages()
click to toggle source
# File lib/amun/buffer.rb, line 92 def messages @messages ||= new('*Messages*') instances << @messages @messages end
new(name, io = StringIO.new)
click to toggle source
Calls superclass method
# File lib/amun/buffer.rb, line 14 def initialize(name, io = StringIO.new) super() self.io = io self.name = name self.point = 0 self.text = '' self.major_mode = MajorModes::Fundamental.new(self) self.minor_modes = Set.new end
scratch()
click to toggle source
# File lib/amun/buffer.rb, line 86 def scratch @scratch ||= new('*Scratch*') instances << @scratch @scratch end
Public Instance Methods
<<(p1)
click to toggle source
# File lib/amun/buffer.rb, line 63 def <<(p1) insert(length, p1) end
clear()
click to toggle source
# File lib/amun/buffer.rb, line 67 def clear slice!(0, length) end
insert(index, other_str)
click to toggle source
# File lib/amun/buffer.rb, line 55 def insert(index, other_str) text.insert(index, other_str) end
mark()
click to toggle source
# File lib/amun/buffer.rb, line 32 def mark return nil if @mark.nil? return 0 if @mark.negative? return length if @mark > length @mark end
point()
click to toggle source
# File lib/amun/buffer.rb, line 25 def point return 0 if @point.negative? return length if @point > length @point end
slice!(start, length = 1)
click to toggle source
# File lib/amun/buffer.rb, line 59 def slice!(start, length = 1) text.slice!(start, length) end
to_s()
click to toggle source
# File lib/amun/buffer.rb, line 71 def to_s text.dup end
trigger(event)
click to toggle source
# File lib/amun/buffer.rb, line 39 def trigger(event) EventManager.join( event, *([events] + minor_modes.to_a + [major_mode]) ) end