Skip to content
Myr

Support old Ruby (even runs on 1.8.5)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent b54fd30 · Browse files · 1 file+14 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+14 added−9 removed

  • other:+14 added−9 removed

1 file+14 added−9 removed

modified:fzf+14 added-9 removed
103 unmodified lines
104 def ord105 self.unpack('c').first106 end107 end108109 class Fixnum110 def ord111 self112 end113 end114end115116C.init_screen117C.start_color
66 unmodified lines
184185 new_search = new_items || query_changed186 if new_search187 regexp = pquery.empty? ? nil :182 Regexp.new(pquery.each_char.inject('') { |sum, e|188 Regexp.new(pquery.split(//).inject('') { |sum, e|189 e = Regexp.escape e190 sum << "#{e}[^#{e}]*?"191 }, Regexp::IGNORECASE)192
20 unmodified lines
213 break214 end215 end216211 cache[pquery] ||= (prefix_cache ? prefix_cache.map(&:first) : list).map { |line|217 cache[pquery] ||= (prefix_cache ? prefix_cache.map { |e| e.first } : list).map { |line|218 if regexp219 md = line.match regexp220 md ? [line, md.offset(0)] : nil221 else222 [line, zz]223 end224 }.compact225 end220 }.flatten(1)226 }.inject([]) { |all, e| all.concat e }227 @stat.search += 1228229 new_length = matches.length230 if new_length <= MAX_SORT_LEN
101 unmodified lines
332 },333 127 => proc { input[cursor -= 1] = '' if cursor > 0 },334 :left => proc { cursor = [0, cursor - 1].max },335 :right => proc { cursor = [input.length, cursor + 1].min },330 }.tap { |actions|331 actions[ctrl :b] = actions[:left]332 actions[ctrl :f] = actions[:right]333 actions[ctrl :h] = actions[127]334 actions[ctrl :n] = actions[ctrl :j]335 actions[ctrl :p] = actions[ctrl :k]336 }337 actions[ctrl(:b)] = actions[:left]338 actions[ctrl(:f)] = actions[:right]339 actions[ctrl(:h)] = actions[127]340 actions[ctrl(:n)] = actions[ctrl(:j)]341 actions[ctrl(:p)] = actions[ctrl(:k)]342343 while true344 ord = tty.getc.ord345 if ord == 27
38 unmodified lines