Sha256: bde336917fac20fe66170c1551a7b9152dd4e232727b8b79ee50e9396067b0c4

Contents?: true

Size: 778 Bytes

Versions: 19

Compression:

Stored size: 778 Bytes

Contents

class RubyText::Window
  def go(r, c)
    save = self.rc
    @win.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
    [@win.cury, @win.curx]
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rubytext-0.0.60 lib/navigation.rb
rubytext-0.0.59 lib/navigation.rb
rubytext-0.0.58 lib/navigation.rb
rubytext-0.0.57 lib/navigation.rb
rubytext-0.0.56 lib/navigation.rb
rubytext-0.0.55 lib/navigation.rb
rubytext-0.0.54 lib/navigation.rb
rubytext-0.0.53 lib/navigation.rb
rubytext-0.0.52 lib/navigation.rb
rubytext-0.0.51 lib/navigation.rb
rubytext-0.0.50 lib/navigation.rb
rubytext-0.0.49 lib/navigation.rb
rubytext-0.0.48 lib/navigation.rb
rubytext-0.0.47 lib/navigation.rb
rubytext-0.0.46 lib/navigation.rb
rubytext-0.0.45 lib/navigation.rb
rubytext-0.0.44 lib/navigation.rb
rubytext-0.0.43 lib/navigation.rb
rubytext-0.0.42 lib/navigation.rb