Sha256: f5f9e4ae72be179ea1082540b98642877a60291dd51c310a5056b2cad215003b

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

module TermNote
  class Show
    attr_accessor :panes

    def initialize
      @panes = []
    end

    def add(pane)
      panes << pane
      pane.show = self
    end

    def pane
      @pane || panes.first
    end

    def position
      panes.index pane
    end

    def start
      active = true
      while active
        pane.call $stdout.winsize
        case command
          when "j" then forward
          when "k" then backward
          when "q" then active = false
        end
      end
    end

    def forward
      @pane = panes[position + 1] || panes.first
    end

    def backward
      @pane = panes[position - 1] || panes.last
    end

    def command
      $stdin.getch
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
termnote-1.0.0 lib/termnote/show.rb