everyday-curses 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +19 -0
 - data/Gemfile +4 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +29 -0
 - data/Rakefile +1 -0
 - data/everyday-curses.gemspec +27 -0
 - data/lib/everyday-curses/curses_utils.rb +42 -0
 - data/lib/everyday-curses/mycurses.rb +198 -0
 - data/lib/everyday-curses/version.rb +3 -0
 - data/lib/everyday-curses.rb +2 -0
 - metadata +112 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 140960c2a64bf5610adbd265161134d148b1e646
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 178e30d3ce39b391dceca9ae08761bc0f326f9c2
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 74b335625857f162a9a221722261e45cc920edb70a91dd64f99a5c67385feca1d53798608446526a49ea90b286a7d77b363e155f1bd8cc652bd9264355a6fa86
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4fd164b58dd05016af386a73c9b1ea7d88e4f235224e04addc6e7bf40b709054acaa000ab350431be9d331ee09726a89ea5077c79ab56e1d8703698198d5d198
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2014 Eric Henderson
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Everyday::Curses
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            TODO: Write a gem description
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                gem 'everyday-curses'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                $ gem install everyday-curses
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            TODO: Write usage instructions here
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            1. Fork it ( http://github.com/<my-github-username>/everyday-curses/fork )
         
     | 
| 
      
 26 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 27 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 28 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 29 
     | 
    
         
            +
            5. Create new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "bundler/gem_tasks"
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            #noinspection RubyResolve
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'everyday-curses/version'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.name        = 'everyday-curses'
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.version     = EverydayCurses::VERSION
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.authors     = ['Eric Henderson']
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.email       = ['henderea@gmail.com']
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.summary     = %q{The MyCurses class from everyday-cli-utils}
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.description = %q{A utility for handling some curses stuff more easily.  Split out from everyday-cli-utils.}
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.homepage    = 'https://github.com/henderea/everyday-curses'
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.license     = 'MIT'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 20 
     | 
    
         
            +
              spec.require_paths = ['lib']
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_development_dependency 'bundler', '~> 1.5'
         
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_development_dependency 'rake', '~> 10.0'
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_dependency 'curses'
         
     | 
| 
      
 26 
     | 
    
         
            +
              spec.add_dependency 'everyday-cli-utils'
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,42 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'everyday-cli-utils/safe/format'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module EverydayCurses
         
     | 
| 
      
 4 
     | 
    
         
            +
              module CursesUtils
         
     | 
| 
      
 5 
     | 
    
         
            +
                COLOR_TO_CURSES = {
         
     | 
| 
      
 6 
     | 
    
         
            +
                    :black  => Curses::COLOR_BLACK,
         
     | 
| 
      
 7 
     | 
    
         
            +
                    :red    => Curses::COLOR_RED,
         
     | 
| 
      
 8 
     | 
    
         
            +
                    :green  => Curses::COLOR_GREEN,
         
     | 
| 
      
 9 
     | 
    
         
            +
                    :yellow => Curses::COLOR_YELLOW,
         
     | 
| 
      
 10 
     | 
    
         
            +
                    :blue   => Curses::COLOR_BLUE,
         
     | 
| 
      
 11 
     | 
    
         
            +
                    :purple => Curses::COLOR_MAGENTA,
         
     | 
| 
      
 12 
     | 
    
         
            +
                    :cyan   => Curses::COLOR_CYAN,
         
     | 
| 
      
 13 
     | 
    
         
            +
                    :white  => Curses::COLOR_WHITE,
         
     | 
| 
      
 14 
     | 
    
         
            +
                    :none   => -1,
         
     | 
| 
      
 15 
     | 
    
         
            +
                }
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def find_color(bgcolor, fgcolor)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @colors.find_index { |v| v[0] == (fgcolor || :none) && v[1] == (bgcolor || :none) }
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def add_color(bgcolor, fgcolor)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  Curses::init_pair(@colors.count + 1, COLOR_TO_CURSES[fgcolor || :none], COLOR_TO_CURSES[bgcolor || :none])
         
     | 
| 
      
 23 
     | 
    
         
            +
                  ind = @colors.count + 1
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @colors << [fgcolor || :none, bgcolor || :none]
         
     | 
| 
      
 25 
     | 
    
         
            +
                  ind
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                private
         
     | 
| 
      
 30 
     | 
    
         
            +
                def handle_color(fgcolor, bgcolor)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  return 0 if (fgcolor.nil? || fgcolor == :none) && (bgcolor.nil? || bgcolor == :none)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  ind = find_color(bgcolor, fgcolor)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  ind = ind.nil? ? add_color(bgcolor, fgcolor) : ind + 1
         
     | 
| 
      
 34 
     | 
    
         
            +
                  Curses::color_pair(ind)
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                def get_format(str)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  bold, underline, fgcolor, bgcolor = EverydayCliUtils::Format::parse_format(str)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  (bold ? Curses::A_BOLD : 0) | (underline ? Curses::A_UNDERLINE : 0) | handle_color(fgcolor, bgcolor)
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,198 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'curses'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative 'curses_utils'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module EverydayCurses
         
     | 
| 
      
 5 
     | 
    
         
            +
              class MyCurses
         
     | 
| 
      
 6 
     | 
    
         
            +
                include CursesUtils
         
     | 
| 
      
 7 
     | 
    
         
            +
                #region External
         
     | 
| 
      
 8 
     | 
    
         
            +
                def initialize(use_curses, linesh, linesf)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @use_curses = use_curses
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @linesh     = linesh
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @linesf     = linesf
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @colors     = []
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @headers    = []
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @bodies     = []
         
     | 
| 
      
 15 
     | 
    
         
            +
                  @footers    = []
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @cur_l      = 0
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @max_l      = 0
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @ch         = nil
         
     | 
| 
      
 19 
     | 
    
         
            +
                  setup_curses(linesf, linesh) if @use_curses
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                def setup_curses(linesf, linesh)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  Curses::noecho
         
     | 
| 
      
 24 
     | 
    
         
            +
                  Curses::init_screen
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @subpad_start = linesh
         
     | 
| 
      
 26 
     | 
    
         
            +
                  update_subpad_size
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @padh = Curses::Pad.new(linesh, Curses::cols)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @padb = Curses::Pad.new(Curses::lines - linesh - linesf, Curses::cols)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @padf = Curses::Pad.new(linesf, Curses::cols)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  configure_curses
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def configure_curses
         
     | 
| 
      
 34 
     | 
    
         
            +
                  @padh.keypad(true)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  @padh.clear
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @padh.nodelay = true
         
     | 
| 
      
 37 
     | 
    
         
            +
                  @padb.keypad(true)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  @padb.clear
         
     | 
| 
      
 39 
     | 
    
         
            +
                  @padb.nodelay = true
         
     | 
| 
      
 40 
     | 
    
         
            +
                  @padf.keypad(true)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  @padf.clear
         
     | 
| 
      
 42 
     | 
    
         
            +
                  @padf.nodelay = true
         
     | 
| 
      
 43 
     | 
    
         
            +
                  Curses::cbreak
         
     | 
| 
      
 44 
     | 
    
         
            +
                  Curses::start_color
         
     | 
| 
      
 45 
     | 
    
         
            +
                  Curses::use_default_colors
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                def clear
         
     | 
| 
      
 49 
     | 
    
         
            +
                  @headers = []
         
     | 
| 
      
 50 
     | 
    
         
            +
                  @bodies  = []
         
     | 
| 
      
 51 
     | 
    
         
            +
                  @footers = []
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                def myprints
         
     | 
| 
      
 55 
     | 
    
         
            +
                  @use_curses ? print_curses : print_normal
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                def print_normal
         
     | 
| 
      
 59 
     | 
    
         
            +
                  @headers.each { |v| puts v }
         
     | 
| 
      
 60 
     | 
    
         
            +
                  @bodies.each { |v| puts v }
         
     | 
| 
      
 61 
     | 
    
         
            +
                  @footers.each { |v| puts v }
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                def print_curses
         
     | 
| 
      
 65 
     | 
    
         
            +
                  resize_curses
         
     | 
| 
      
 66 
     | 
    
         
            +
                  myprint(@headers.join("\n"), @padh)
         
     | 
| 
      
 67 
     | 
    
         
            +
                  myprint(@bodies.join("\n"), @padb)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  myprint(@footers.join("\n"), @padf)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  update_max_l
         
     | 
| 
      
 70 
     | 
    
         
            +
                  @cur_l = [@cur_l, @max_l].min
         
     | 
| 
      
 71 
     | 
    
         
            +
                  padh_refresh
         
     | 
| 
      
 72 
     | 
    
         
            +
                  padb_refresh
         
     | 
| 
      
 73 
     | 
    
         
            +
                  padf_refresh
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                def resize_curses
         
     | 
| 
      
 77 
     | 
    
         
            +
                  @padh.resize(@headers.count, Curses::cols)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  @padb.resize(@bodies.count, Curses::cols)
         
     | 
| 
      
 79 
     | 
    
         
            +
                  @padf.resize(@footers.count, Curses::cols)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  @padh.clear
         
     | 
| 
      
 81 
     | 
    
         
            +
                  @padb.clear
         
     | 
| 
      
 82 
     | 
    
         
            +
                  @padf.clear
         
     | 
| 
      
 83 
     | 
    
         
            +
                  @padh.setpos(0, 0)
         
     | 
| 
      
 84 
     | 
    
         
            +
                  @padb.setpos(0, 0)
         
     | 
| 
      
 85 
     | 
    
         
            +
                  @padf.setpos(0, 0)
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                def read_ch
         
     | 
| 
      
 89 
     | 
    
         
            +
                  @ch = @padf.getch
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                def clear_ch
         
     | 
| 
      
 93 
     | 
    
         
            +
                  read_ch
         
     | 
| 
      
 94 
     | 
    
         
            +
                  while @ch == 10 || @ch == Curses::Key::ENTER || @ch == Curses::Key::UP || @ch == Curses::Key::DOWN
         
     | 
| 
      
 95 
     | 
    
         
            +
                    read_ch
         
     | 
| 
      
 96 
     | 
    
         
            +
                  end
         
     | 
| 
      
 97 
     | 
    
         
            +
                end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                def scroll_iteration
         
     | 
| 
      
 100 
     | 
    
         
            +
                  old_subpad_size = @subpad_size
         
     | 
| 
      
 101 
     | 
    
         
            +
                  update_subpad_size
         
     | 
| 
      
 102 
     | 
    
         
            +
                  update_max_l
         
     | 
| 
      
 103 
     | 
    
         
            +
                  update_scroll(@subpad_size != old_subpad_size)
         
     | 
| 
      
 104 
     | 
    
         
            +
                  sleep(0.05)
         
     | 
| 
      
 105 
     | 
    
         
            +
                  read_ch
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                def header_live_append(str)
         
     | 
| 
      
 109 
     | 
    
         
            +
                  @padh << str
         
     | 
| 
      
 110 
     | 
    
         
            +
                  padh_refresh
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                def body_live_append(str)
         
     | 
| 
      
 114 
     | 
    
         
            +
                  @padb << str
         
     | 
| 
      
 115 
     | 
    
         
            +
                  padb_refresh
         
     | 
| 
      
 116 
     | 
    
         
            +
                end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                def footer_live_append(str)
         
     | 
| 
      
 119 
     | 
    
         
            +
                  @padf << str
         
     | 
| 
      
 120 
     | 
    
         
            +
                  padf_refresh
         
     | 
| 
      
 121 
     | 
    
         
            +
                end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                def dispose
         
     | 
| 
      
 124 
     | 
    
         
            +
                  Curses::close_screen if @use_curses
         
     | 
| 
      
 125 
     | 
    
         
            +
                end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                #endregion
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                #region Internal
         
     | 
| 
      
 130 
     | 
    
         
            +
                def myputs(text, pad)
         
     | 
| 
      
 131 
     | 
    
         
            +
                  myprint("#{text}\n", pad)
         
     | 
| 
      
 132 
     | 
    
         
            +
                end
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                def myprint(text, pad)
         
     | 
| 
      
 135 
     | 
    
         
            +
                  if @use_curses
         
     | 
| 
      
 136 
     | 
    
         
            +
                    if text.include?("\e")
         
     | 
| 
      
 137 
     | 
    
         
            +
                      pieces = text.scan(/#{"\e"}\[(.+?)m([^#{"\e"}]+?)#{"\e"}\[0m|([^#{"\e"}]+)/)
         
     | 
| 
      
 138 
     | 
    
         
            +
                      pieces.each { |v|
         
     | 
| 
      
 139 
     | 
    
         
            +
                        if v[2].nil?
         
     | 
| 
      
 140 
     | 
    
         
            +
                          pad.attron(get_format(v[0])) {
         
     | 
| 
      
 141 
     | 
    
         
            +
                            pad << v[1]
         
     | 
| 
      
 142 
     | 
    
         
            +
                          }
         
     | 
| 
      
 143 
     | 
    
         
            +
                        else
         
     | 
| 
      
 144 
     | 
    
         
            +
                          pad << v[2]
         
     | 
| 
      
 145 
     | 
    
         
            +
                        end
         
     | 
| 
      
 146 
     | 
    
         
            +
                      }
         
     | 
| 
      
 147 
     | 
    
         
            +
                    else
         
     | 
| 
      
 148 
     | 
    
         
            +
                      pad << text
         
     | 
| 
      
 149 
     | 
    
         
            +
                    end
         
     | 
| 
      
 150 
     | 
    
         
            +
                  else
         
     | 
| 
      
 151 
     | 
    
         
            +
                    print text
         
     | 
| 
      
 152 
     | 
    
         
            +
                  end
         
     | 
| 
      
 153 
     | 
    
         
            +
                end
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
                def update_max_l
         
     | 
| 
      
 156 
     | 
    
         
            +
                  @max_l = [0, @bodies.count - @subpad_size].max
         
     | 
| 
      
 157 
     | 
    
         
            +
                end
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
                def update_subpad_size
         
     | 
| 
      
 160 
     | 
    
         
            +
                  Curses::refresh
         
     | 
| 
      
 161 
     | 
    
         
            +
                  @subpad_size = Curses::lines - @linesh - @linesf
         
     | 
| 
      
 162 
     | 
    
         
            +
                end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
                def padh_refresh
         
     | 
| 
      
 165 
     | 
    
         
            +
                  @padh.refresh(0, 0, 0, 0, @subpad_start - 1, Curses::cols - 1)
         
     | 
| 
      
 166 
     | 
    
         
            +
                end
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                def padb_refresh
         
     | 
| 
      
 169 
     | 
    
         
            +
                  @padb.refresh(@cur_l, 0, @subpad_start, 0, @subpad_start + @subpad_size - 1, Curses::cols - 1)
         
     | 
| 
      
 170 
     | 
    
         
            +
                end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                def padf_refresh
         
     | 
| 
      
 173 
     | 
    
         
            +
                  @padf.refresh(0, 0, @subpad_start + [@subpad_size, @bodies.count].min, 0, @subpad_start + [@subpad_size, @bodies.count].min + @footers.count, Curses::cols - 1)
         
     | 
| 
      
 174 
     | 
    
         
            +
                end
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
                def update_scroll(force_refresh = false)
         
     | 
| 
      
 177 
     | 
    
         
            +
                  if @ch == Curses::Key::UP
         
     | 
| 
      
 178 
     | 
    
         
            +
                    @cur_l = [0, @cur_l - 1].max
         
     | 
| 
      
 179 
     | 
    
         
            +
                  elsif @ch == Curses::Key::DOWN
         
     | 
| 
      
 180 
     | 
    
         
            +
                    @cur_l = [@max_l, @cur_l + 1].min
         
     | 
| 
      
 181 
     | 
    
         
            +
                  end
         
     | 
| 
      
 182 
     | 
    
         
            +
                  @cur_l = [@cur_l, @max_l].min
         
     | 
| 
      
 183 
     | 
    
         
            +
                  if @ch == Curses::Key::UP || @ch == Curses::Key::DOWN || force_refresh
         
     | 
| 
      
 184 
     | 
    
         
            +
                    Curses::refresh
         
     | 
| 
      
 185 
     | 
    
         
            +
                    padh_refresh
         
     | 
| 
      
 186 
     | 
    
         
            +
                    padb_refresh
         
     | 
| 
      
 187 
     | 
    
         
            +
                    padf_refresh
         
     | 
| 
      
 188 
     | 
    
         
            +
                  end
         
     | 
| 
      
 189 
     | 
    
         
            +
                  @cur_l
         
     | 
| 
      
 190 
     | 
    
         
            +
                end
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
                #endregion
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
                attr_reader :ch
         
     | 
| 
      
 195 
     | 
    
         
            +
                attr_accessor :bodies, :headers, :footers
         
     | 
| 
      
 196 
     | 
    
         
            +
                private :myputs, :myprint, :update_max_l, :update_subpad_size, :padh_refresh, :padb_refresh, :padf_refresh, :update_scroll
         
     | 
| 
      
 197 
     | 
    
         
            +
              end
         
     | 
| 
      
 198 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,112 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: everyday-curses
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Eric Henderson
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-01-29 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1.5'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1.5'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: curses
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: everyday-cli-utils
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 69 
     | 
    
         
            +
            description: A utility for handling some curses stuff more easily.  Split out from
         
     | 
| 
      
 70 
     | 
    
         
            +
              everyday-cli-utils.
         
     | 
| 
      
 71 
     | 
    
         
            +
            email:
         
     | 
| 
      
 72 
     | 
    
         
            +
            - henderea@gmail.com
         
     | 
| 
      
 73 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 74 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 75 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 76 
     | 
    
         
            +
            files:
         
     | 
| 
      
 77 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 78 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 79 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 80 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 81 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 82 
     | 
    
         
            +
            - everyday-curses.gemspec
         
     | 
| 
      
 83 
     | 
    
         
            +
            - lib/everyday-curses.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - lib/everyday-curses/curses_utils.rb
         
     | 
| 
      
 85 
     | 
    
         
            +
            - lib/everyday-curses/mycurses.rb
         
     | 
| 
      
 86 
     | 
    
         
            +
            - lib/everyday-curses/version.rb
         
     | 
| 
      
 87 
     | 
    
         
            +
            homepage: https://github.com/henderea/everyday-curses
         
     | 
| 
      
 88 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 89 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 90 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 91 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 92 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 93 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 94 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 95 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 96 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 97 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 98 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 99 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 100 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 101 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 102 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 103 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 104 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 105 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 106 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 107 
     | 
    
         
            +
            rubygems_version: 2.2.0
         
     | 
| 
      
 108 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 109 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 110 
     | 
    
         
            +
            summary: The MyCurses class from everyday-cli-utils
         
     | 
| 
      
 111 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 112 
     | 
    
         
            +
            has_rdoc: 
         
     |