Sha256: 1ebbee6c199a5e947d90361738db940c1c51cb322d5af448286aee77d67e80f5

Contents?: true

Size: 781 Bytes

Versions: 15

Compression:

Stored size: 781 Bytes

Contents

class RubyText::Window
  def go(r, c)
    save = self.rc
    @cwin.setpos(r, c)
    if block_given?
      yield
      go(*save)   # No block here!
    end
  end

  def up(n=1)
    r, c = rc
    go r-n, c
  end

  def down(n=1)
    r, c = rc
    go r+n, c
  end

  def left(n=1)
    r, c = rc
    go r, c-n
  end

  def right(n=1)
    r, c = rc
    go r, c+n
  end

  def top
    r, c = rc
    go 0, c
  end

  def bottom 
    r, c = rc
    rmax = self.rows - 1
    go rmax, c
  end

  def up!
    top
  end

  def down!
    bottom
  end

  def left!
    r, c = rc
    go r, 0
  end

  def right!
    r, c = rc
    cmax = self.cols - 1
    go r, cmax
  end

  def home
    go 0, 0
  end

# def crlf
#   r, c = rc
#   go r+1, 0
# end

  def rc
    [@cwin.cury, @cwin.curx]
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rubytext-0.0.76 lib/navigation.rb
rubytext-0.0.75 lib/navigation.rb
rubytext-0.0.74 lib/navigation.rb
rubytext-0.0.73 lib/navigation.rb
rubytext-0.0.72 lib/navigation.rb
rubytext-0.0.71 lib/navigation.rb
rubytext-0.0.70 lib/navigation.rb
rubytext-0.0.69 lib/navigation.rb
rubytext-0.0.68 lib/navigation.rb
rubytext-0.0.67 lib/navigation.rb
rubytext-0.0.66 lib/navigation.rb
rubytext-0.0.65 lib/navigation.rb
rubytext-0.0.64 lib/navigation.rb
rubytext-0.0.63 lib/navigation.rb
rubytext-0.0.62 lib/navigation.rb