类 Reline::KillRing
常量
- RingPoint
公共类方法
new(max = 1024) 点击切换源代码
# File lib/reline/kill_ring.rb, line 61 def initialize(max = 1024) @ring = RingBuffer.new(max) @ring_pointer = nil @buffer = nil @state = State::FRESH end
公共实例方法
append(string, before_p = false) 点击切换源代码
# File lib/reline/kill_ring.rb, line 68 def append(string, before_p = false) case @state when State::FRESH, State::YANK @ring << RingPoint.new(string) @state = State::CONTINUED when State::CONTINUED, State::PROCESSED if before_p @ring.head.str.prepend(string) else @ring.head.str.concat(string) end @state = State::CONTINUED end end
each() { |str| ... } 点击切换源代码
# File lib/reline/kill_ring.rb, line 116 def each start = head = @ring.head loop do break if head.nil? yield head.str head = head.backward break if head == start end end
process() 点击切换源代码
# File lib/reline/kill_ring.rb, line 83 def process case @state when State::FRESH # nothing to do when State::CONTINUED @state = State::PROCESSED when State::PROCESSED @state = State::FRESH when State::YANK # nothing to do end end
yank() 点击切换源代码
# File lib/reline/kill_ring.rb, line 96 def yank unless @ring.empty? @state = State::YANK @ring_pointer = @ring.head @ring_pointer.str else nil end end
yank_pop() 点击切换源代码
# File lib/reline/kill_ring.rb, line 106 def yank_pop if @state == State::YANK prev_yank = @ring_pointer.str @ring_pointer = @ring_pointer.backward [@ring_pointer.str, prev_yank] else nil end end