curses-extension 1.2 → 1.3
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 +4 -4
 - data/lib/curses-extension.rb +3 -1
 - data/lib/curses-template.rb +35 -18
 - metadata +4 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 7a03325b4dbf6aa5c2cd506e50e642f62588a07cc543314d98eafce40cb7d2e3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2862dc209031c64df476ca07c3bd7fcba8f2929620966492f53f858903f30207
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: be4ab27081169af7f9219df23272012e287e3f838f78407bc495d7470f522d1c1fd9c945c7b3ce99ea9dd48a81930ab2a7411e76efbe0b11d75da18a86af425d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3eaa3fba2972af226cffa6380d55a3a3e034bc0ba8984c2893d6cec6cee7801eafdbbae023c711195217f5def9e48e34450dbf97229762d9a20d1f7b8ad4a6bd
         
     | 
    
        data/lib/curses-extension.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Curses::Window # CLASS EXTENSION 
         
     | 
| 
       2 
2 
     | 
    
         
             
              # General extensions (see https://github.com/isene/Ruby-Curses-Class-Extension)
         
     | 
| 
       3 
     | 
    
         
            -
              attr_accessor :color, :fg, :bg, :attr, :update
         
     | 
| 
      
 3 
     | 
    
         
            +
              attr_accessor :color, :fg, :bg, :attr, :update, :index
         
     | 
| 
       4 
4 
     | 
    
         
             
              # Set self.color for an already defined color pair such as: init_pair(1, 255, 3)
         
     | 
| 
       5 
5 
     | 
    
         
             
              # The color pair is defined like this: init_pair(index, foreground, background)
         
     | 
| 
       6 
6 
     | 
    
         
             
              # self.fg is set for the foreground color (and is used if self.color is not set)
         
     | 
| 
         @@ -103,3 +103,5 @@ class Curses::Window # CLASS EXTENSION 
     | 
|
| 
       103 
103 
     | 
    
         
             
                return "\n" + text.gsub(/(.{1,#{self.maxx}})( +|$\n?)|(.{1,#{self.maxx}})/, "\\1\\3\n")
         
     | 
| 
       104 
104 
     | 
    
         
             
              end
         
     | 
| 
       105 
105 
     | 
    
         
             
            end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            # vim: set sw=2 sts=2 et fdm=syntax fdn=2 fcs=fold\:\ :
         
     | 
    
        data/lib/curses-template.rb
    CHANGED
    
    | 
         @@ -16,20 +16,23 @@ 
     | 
|
| 
       16 
16 
     | 
    
         
             
            # | @w_b                          |
         
     | 
| 
       17 
17 
     | 
    
         
             
            # +-------------------------------+
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            require ' 
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
            begin #Basic setup
         
     | 
| 
      
 20 
     | 
    
         
            +
              require 'io/console'
         
     | 
| 
      
 21 
     | 
    
         
            +
              require 'io/wait'
         
     | 
| 
      
 22 
     | 
    
         
            +
              require 'curses'
         
     | 
| 
      
 23 
     | 
    
         
            +
              include  Curses
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
            Curses.init_screen
         
     | 
| 
       24 
     | 
    
         
            -
            Curses.start_color
         
     | 
| 
       25 
     | 
    
         
            -
            Curses.curs_set(0)
         
     | 
| 
       26 
     | 
    
         
            -
            Curses.noecho
         
     | 
| 
       27 
     | 
    
         
            -
            Curses.cbreak
         
     | 
| 
       28 
     | 
    
         
            -
            Curses.stdscr.keypad = true
         
     | 
| 
      
 25 
     | 
    
         
            +
              Curses.init_screen
         
     | 
| 
      
 26 
     | 
    
         
            +
              Curses.start_color
         
     | 
| 
      
 27 
     | 
    
         
            +
              Curses.curs_set(0)
         
     | 
| 
      
 28 
     | 
    
         
            +
              Curses.noecho
         
     | 
| 
      
 29 
     | 
    
         
            +
              Curses.cbreak
         
     | 
| 
      
 30 
     | 
    
         
            +
              Curses.stdscr.keypad = true
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
       29 
32 
     | 
    
         | 
| 
       30 
33 
     | 
    
         
             
            class Curses::Window # CLASS EXTENSION 
         
     | 
| 
       31 
34 
     | 
    
         
             
              # General extensions (see https://github.com/isene/Ruby-Curses-Class-Extension)
         
     | 
| 
       32 
     | 
    
         
            -
              attr_accessor :color, :fg, :bg, :attr, :update
         
     | 
| 
      
 35 
     | 
    
         
            +
              attr_accessor :color, :fg, :bg, :attr, :update, :index
         
     | 
| 
       33 
36 
     | 
    
         
             
              # Set self.color for an already defined color pair such as: init_pair(1, 255, 3)
         
     | 
| 
       34 
37 
     | 
    
         
             
              # The color pair is defined like this: init_pair(index, foreground, background)
         
     | 
| 
       35 
38 
     | 
    
         
             
              # self.fg is set for the foreground color (and is used if self.color is not set)
         
     | 
| 
         @@ -133,13 +136,14 @@ class Curses::Window # CLASS EXTENSION 
     | 
|
| 
       133 
136 
     | 
    
         
             
              end
         
     | 
| 
       134 
137 
     | 
    
         
             
            end
         
     | 
| 
       135 
138 
     | 
    
         | 
| 
       136 
     | 
    
         
            -
            def getchr #  
     | 
| 
       137 
     | 
    
         
            -
              c = STDIN.getch 
     | 
| 
      
 139 
     | 
    
         
            +
            def getchr # Process key presses
         
     | 
| 
      
 140 
     | 
    
         
            +
              c = STDIN.getch
         
     | 
| 
      
 141 
     | 
    
         
            +
              #c = STDIN.getch(min: 0, time: 1) # Use this if you need to poll for user keys
         
     | 
| 
       138 
142 
     | 
    
         
             
              case c
         
     | 
| 
       139 
143 
     | 
    
         
             
              when "\e"    # ANSI escape sequences
         
     | 
| 
       140 
     | 
    
         
            -
                case  
     | 
| 
      
 144 
     | 
    
         
            +
                case STDIN.getc
         
     | 
| 
       141 
145 
     | 
    
         
             
                when '['   # CSI
         
     | 
| 
       142 
     | 
    
         
            -
                  case  
     | 
| 
      
 146 
     | 
    
         
            +
                  case STDIN.getc
         
     | 
| 
       143 
147 
     | 
    
         
             
                  when 'A' then chr = "UP"
         
     | 
| 
       144 
148 
     | 
    
         
             
                  when 'B' then chr = "DOWN"
         
     | 
| 
       145 
149 
     | 
    
         
             
                  when 'C' then chr = "RIGHT"
         
     | 
| 
         @@ -152,8 +156,8 @@ def getchr # PROCESS KEY PRESSES 
     | 
|
| 
       152 
156 
     | 
    
         
             
                  when '7' then chr = "HOME"   ; chr = "C-HOME"   if STDIN.getc == "^"
         
     | 
| 
       153 
157 
     | 
    
         
             
                  when '8' then chr = "END"    ; chr = "C-END"    if STDIN.getc == "^"
         
     | 
| 
       154 
158 
     | 
    
         
             
                  end
         
     | 
| 
       155 
     | 
    
         
            -
                when 'O'
         
     | 
| 
       156 
     | 
    
         
            -
                  case  
     | 
| 
      
 159 
     | 
    
         
            +
                when 'O'   # Set Ctrl+ArrowKey equal to ArrowKey; May be used for other purposes in the future
         
     | 
| 
      
 160 
     | 
    
         
            +
                  case STDIN.getc
         
     | 
| 
       157 
161 
     | 
    
         
             
                  when 'a' then chr = "C-UP"
         
     | 
| 
       158 
162 
     | 
    
         
             
                  when 'b' then chr = "C-DOWN"
         
     | 
| 
       159 
163 
     | 
    
         
             
                  when 'c' then chr = "C-RIGHT"
         
     | 
| 
         @@ -161,12 +165,22 @@ def getchr # PROCESS KEY PRESSES 
     | 
|
| 
       161 
165 
     | 
    
         
             
                  end
         
     | 
| 
       162 
166 
     | 
    
         
             
                end
         
     | 
| 
       163 
167 
     | 
    
         
             
              when "", "" then chr = "BACK"
         
     | 
| 
      
 168 
     | 
    
         
            +
              when "" then chr = "C-C"
         
     | 
| 
      
 169 
     | 
    
         
            +
              when "" then chr = "C-D"
         
     | 
| 
      
 170 
     | 
    
         
            +
              when "" then chr = "C-E"
         
     | 
| 
      
 171 
     | 
    
         
            +
              when "" then chr = "C-G"
         
     | 
| 
      
 172 
     | 
    
         
            +
              when "" then chr = "C-K"
         
     | 
| 
      
 173 
     | 
    
         
            +
              when "" then chr = "C-L"
         
     | 
| 
      
 174 
     | 
    
         
            +
              when "" then chr = "C-N"
         
     | 
| 
      
 175 
     | 
    
         
            +
              when "" then chr = "C-O"
         
     | 
| 
      
 176 
     | 
    
         
            +
              when "" then chr = "C-P"
         
     | 
| 
      
 177 
     | 
    
         
            +
              when "" then chr = "C-T"
         
     | 
| 
      
 178 
     | 
    
         
            +
              when "" then chr = "C-Y"
         
     | 
| 
       164 
179 
     | 
    
         
             
              when "" then chr = "WBACK"
         
     | 
| 
       165 
180 
     | 
    
         
             
              when "" then chr = "LDEL"
         
     | 
| 
       166 
     | 
    
         
            -
              when "" then chr = "C-T"
         
     | 
| 
       167 
181 
     | 
    
         
             
              when "\r" then chr = "ENTER"
         
     | 
| 
       168 
182 
     | 
    
         
             
              when "\t" then chr = "TAB"
         
     | 
| 
       169 
     | 
    
         
            -
              when  
     | 
| 
      
 183 
     | 
    
         
            +
              when /[[:print:]]/  then chr = c
         
     | 
| 
       170 
184 
     | 
    
         
             
              end
         
     | 
| 
       171 
185 
     | 
    
         
             
              return chr
         
     | 
| 
       172 
186 
     | 
    
         
             
            end
         
     | 
| 
         @@ -197,6 +211,9 @@ def main_getkey # GET KEY FROM USER 
     | 
|
| 
       197 
211 
     | 
    
         
             
              when 'q' # Exit 
         
     | 
| 
       198 
212 
     | 
    
         
             
                exit 0
         
     | 
| 
       199 
213 
     | 
    
         
             
              end
         
     | 
| 
      
 214 
     | 
    
         
            +
              while STDIN.ready?
         
     | 
| 
      
 215 
     | 
    
         
            +
                chr = STDIN.getc
         
     | 
| 
      
 216 
     | 
    
         
            +
              end
         
     | 
| 
       200 
217 
     | 
    
         
             
            end
         
     | 
| 
       201 
218 
     | 
    
         | 
| 
       202 
219 
     | 
    
         
             
            # TOP WINDOW FUNCTIONS 
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: curses-extension
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: '1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: '1.3'
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Geir Isene
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-07-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: curses
         
     | 
| 
         @@ -35,8 +35,8 @@ description: 'The Ruby curses library is sorely lacking some important features. 
     | 
|
| 
       35 
35 
     | 
    
         
             
              terminal curses applications in Ruby. See the Github page for information on what
         
     | 
| 
       36 
36 
     | 
    
         
             
              properties and functions are included: https://github.com/isene/Ruby-Curses-Class-Extension.
         
     | 
| 
       37 
37 
     | 
    
         
             
              The curses_template.rb is also installed in the lib directory and serves as the
         
     | 
| 
       38 
     | 
    
         
            -
              basis for my own curses applications. New in 1. 
     | 
| 
       39 
     | 
    
         
            -
               
     | 
| 
      
 38 
     | 
    
         
            +
              basis for my own curses applications. New in 1.3: Included :index as Class accessor
         
     | 
| 
      
 39 
     | 
    
         
            +
              and other improvements'
         
     | 
| 
       40 
40 
     | 
    
         
             
            email: g@isene.com
         
     | 
| 
       41 
41 
     | 
    
         
             
            executables: []
         
     | 
| 
       42 
42 
     | 
    
         
             
            extensions: []
         
     |