class Vice::Movement

Public Class Methods

b(line, start) click to toggle source
# File lib/vice/movement.rb, line 41
def self.b(line, start)
        b_real(line, start, false)
end
b_internal(line, start, harsh) click to toggle source
# File lib/vice/movement.rb, line 24
def self.b_internal(line, start, harsh)
        return start if start.zero?

        return start if !whitespace(line[start], harsh) && whitespace(line[start - 1], harsh)

        b_internal(line, start - 1, harsh)
end
b_large(line, start) click to toggle source
# File lib/vice/movement.rb, line 45
def self.b_large(line, start)
        b_real(line, start, true)
end
b_real(line, start, harsh) click to toggle source
# File lib/vice/movement.rb, line 32
def self.b_real(line, start, harsh)
        # if we're already on the beginning of a word, we jump to the previous one
        if start.positive? && !whitespace(line[start], harsh) && whitespace(line[start - 1], harsh)
                start -= 1
        end

        b_internal(line, start, harsh)
end
dollar(line) click to toggle source
# File lib/vice/movement.rb, line 49
def self.dollar(line)
        line.length - 1
end
w(line, start) click to toggle source
# File lib/vice/movement.rb, line 16
def self.w(line, start)
        w_real(line, start, false)
end
w_large(line, start) click to toggle source
# File lib/vice/movement.rb, line 20
def self.w_large(line, start)
        w_real(line, start, true)
end
w_real(line, start, harsh) click to toggle source
# File lib/vice/movement.rb, line 10
def self.w_real(line, start, harsh)
        return start if start == line.length - 1
        return start + 1 if whitespace(line[start], harsh) && !whitespace(line[start + 1], harsh)
        w_real(line, start + 1, harsh)
end
whitespace(char, harsh) click to toggle source
# File lib/vice/movement.rb, line 2
def self.whitespace(char, harsh)
        if harsh # only real whitespace
                (char == ' ' || char == "\t" || char == "\n")
        else # anything that's not alphanumeric
                char !~ /\A\p{Alnum}+\z/
        end
end
zero() click to toggle source
# File lib/vice/movement.rb, line 53
def self.zero
        0
end