libui 0.1.3.pre-x86_64-linux → 0.2.0-x86_64-linux
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/LICENSE.txt +1 -1
- data/README.md +36 -26
- data/lib/libui/error.rb +10 -0
- data/lib/libui/ffi.rb +15 -4
- data/lib/libui/fiddle_patch.rb +1 -1
- data/lib/libui/libui_base.rb +6 -4
- data/lib/libui/version.rb +1 -1
- data/lib/libui.rb +22 -6
- data/vendor/libui.x86_64.so +0 -0
- metadata +21 -10
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 6a4a93bc8fdec0c9c4e2587bb2aa99c0ac11d54e34ae9956e64a9a841a39cac5
         | 
| 4 | 
            +
              data.tar.gz: 9b4caca40127dea74380e48afa011f0162e2169cdba6a4037d52ad1e38247924
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9b39de93bfeeb054f86237741ea0b072aead99d1835156fb3f4e18e73f17bbb6e2c8a2592cce0adc31f00c4c1c28d85d31c7d1564a36f074c7bd64664ce39298
         | 
| 7 | 
            +
              data.tar.gz: 333a266fcec1f2108cf7443cbcc56b9f0f86d2620886bdbed5e4bd874e6b18c22a4f493c375da1f9afc38c0595baf1ee32bcc3638f6b1d6780d5e71f868ee15f
         | 
    
        data/LICENSE.txt
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -4,21 +4,32 @@ | |
| 4 4 | 
             
            [](https://badge.fury.io/rb/libui)
         | 
| 5 5 | 
             
            <a href="https://github.com/AndyObtiva/glimmer-dsl-libui"><img alt="glimmer-dsl-libui" src="https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-logo-hi-res.svg" width="50" height="50" align="right"></a>
         | 
| 6 6 | 
             
            [](https://github.com/kojix2/libui-ng/actions/workflows/pre-build.yml)
         | 
| 7 | 
            +
            [](https://tokei.kojix2.net/github/kojix2/LibUI)
         | 
| 7 8 |  | 
| 8 | 
            -
            LibUI is a Ruby wrapper for libui  | 
| 9 | 
            +
            LibUI is a Ruby wrapper for libui family.
         | 
| 9 10 |  | 
| 10 11 | 
             
            :rocket: [libui-ng](https://github.com/libui-ng/libui-ng) - A cross-platform portable GUI library
         | 
| 11 12 |  | 
| 13 | 
            +
            :wrench: [libui-dev](https://github.com/petabyt/libui-dev) - Native UI library for C - with some extras
         | 
| 14 | 
            +
             | 
| 12 15 | 
             
            :radio_button: [libui](https://github.com/andlabs/libui) - Original version by andlabs.
         | 
| 13 16 |  | 
| 14 17 | 
             
            ## Installation
         | 
| 15 18 |  | 
| 19 | 
            +
            It is recommended to use libui-ng, via the --pre commandline flag:
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ```sh
         | 
| 22 | 
            +
            gem install libui --pre # libui-ng; this will fetch libui-0.1.3.pre-x86_64-linux.gem
         | 
| 23 | 
            +
            ```
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            If for some reason you would like to install the slightly older libui-0.1.2.gem release, issue:
         | 
| 26 | 
            +
             | 
| 16 27 | 
             
            ```sh
         | 
| 17 28 | 
             
            gem install libui
         | 
| 18 29 | 
             
            ```
         | 
| 19 30 |  | 
| 20 | 
            -
            - The gem package includes the  | 
| 21 | 
            -
              - Namely `libui.dll`, `libui.dylib`,  | 
| 31 | 
            +
            - The gem package includes the libui-ng shared library for Windows, Mac, and Linux.
         | 
| 32 | 
            +
              - Namely `libui.dll`, `libui.dylib`, or `libui.so`.
         | 
| 22 33 | 
             
            - No dependencies required.
         | 
| 23 34 | 
             
              - The libui gem uses the standard Ruby library [Fiddle](https://github.com/ruby/fiddle) to call C functions.
         | 
| 24 35 |  | 
| @@ -51,9 +62,8 @@ end | |
| 51 62 |  | 
| 52 63 | 
             
            UI.window_on_closing(main_window) do
         | 
| 53 64 | 
             
              puts 'Bye Bye'
         | 
| 54 | 
            -
              UI.control_destroy(main_window)
         | 
| 55 65 | 
             
              UI.quit
         | 
| 56 | 
            -
               | 
| 66 | 
            +
              1
         | 
| 57 67 | 
             
            end
         | 
| 58 68 |  | 
| 59 69 | 
             
            UI.window_set_child(main_window, button)
         | 
| @@ -167,42 +177,42 @@ Add additional options below if necessary: | |
| 167 177 | 
             
            git clone https://github.com/kojix2/libui
         | 
| 168 178 | 
             
            cd libui
         | 
| 169 179 | 
             
            bundle install
         | 
| 170 | 
            -
            bundle exec rake vendor:auto | 
| 180 | 
            +
            bundle exec rake vendor:auto
         | 
| 171 181 | 
             
            bundle exec rake test
         | 
| 172 182 | 
             
            ```
         | 
| 173 183 |  | 
| 174 184 | 
             
            ### Pre-built shared libraries for libui-ng
         | 
| 175 185 |  | 
| 176 | 
            -
             | 
| 177 | 
            -
             | 
| 178 | 
            -
            `rake -T`
         | 
| 186 | 
            +
            Download pre-built libui-ng shared libraries (per your current platform):
         | 
| 179 187 |  | 
| 188 | 
            +
            ```sh
         | 
| 189 | 
            +
            bundle exec rake vendor:auto
         | 
| 180 190 | 
             
            ```
         | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
            rake vendor: | 
| 186 | 
            -
            rake vendor:raspbian_aarch64     # Download pre-build for Raspbian to vendor directory
         | 
| 187 | 
            -
            rake vendor:ubuntu_x64           # Download pre-build for Ubuntu to vendor directory
         | 
| 188 | 
            -
            rake vendor:windows_x64          # Download pre-build for Windows to vendor directory
         | 
| 189 | 
            -
            rake vendor:windows_x86          # Download pre-build for Windows to vendor directory
         | 
| 191 | 
            +
             | 
| 192 | 
            +
            Clean downloaded vendor files (keeps `vendor/{LICENSE,README}.md`):
         | 
| 193 | 
            +
             | 
| 194 | 
            +
            ```sh
         | 
| 195 | 
            +
            bundle exec rake vendor:clean
         | 
| 190 196 | 
             
            ```
         | 
| 191 197 |  | 
| 192 | 
            -
             | 
| 193 | 
            -
             | 
| 198 | 
            +
            ### Using your own libui build
         | 
| 199 | 
            +
             | 
| 200 | 
            +
            If you build libui-ng yourself, set `LIBUIDIR` to the directory containing the compiled `.so/.dylib/.dll` so LibUI can load it. You may also replace files under `vendor/` with your build if preferred. See [#46](https://github.com/kojix2/LibUI/issues/46#issuecomment-1041575792).
         | 
| 194 201 |  | 
| 195 | 
            -
            ###  | 
| 202 | 
            +
            ### Publishing gems
         | 
| 196 203 |  | 
| 197 | 
            -
             | 
| 204 | 
            +
            #### Automated Publishing
         | 
| 198 205 |  | 
| 199 | 
            -
             | 
| 206 | 
            +
            Push a version tag to automatically publish platform-specific gems:
         | 
| 200 207 |  | 
| 201 | 
            -
             | 
| 208 | 
            +
            ```sh
         | 
| 209 | 
            +
            git tag v0.1.3
         | 
| 210 | 
            +
            git push origin v0.1.3
         | 
| 211 | 
            +
            ```
         | 
| 202 212 |  | 
| 203 | 
            -
             | 
| 213 | 
            +
            Requires `RUBYGEMS_API_KEY` repository secret with scoped API key.
         | 
| 204 214 |  | 
| 205 | 
            -
             | 
| 215 | 
            +
            #### Manual Publishing
         | 
| 206 216 |  | 
| 207 217 | 
             
            ```sh
         | 
| 208 218 | 
             
            ls vendor             # check the vendor directory
         | 
    
        data/lib/libui/error.rb
    ADDED
    
    
    
        data/lib/libui/ffi.rb
    CHANGED
    
    | @@ -1,15 +1,23 @@ | |
| 1 1 | 
             
            require 'fiddle/import'
         | 
| 2 2 | 
             
            require_relative 'fiddle_patch'
         | 
| 3 | 
            +
            require_relative 'error'
         | 
| 3 4 |  | 
| 4 5 | 
             
            module LibUI
         | 
| 6 | 
            +
             | 
| 5 7 | 
             
              module FFI
         | 
| 6 8 | 
             
                extend Fiddle::Importer
         | 
| 7 9 | 
             
                extend FiddlePatch
         | 
| 8 10 |  | 
| 9 | 
            -
                 | 
| 10 | 
            -
                   | 
| 11 | 
            -
                 | 
| 12 | 
            -
                  raise  | 
| 11 | 
            +
                if LibUI.ffi_lib.nil?
         | 
| 12 | 
            +
                  raise LibraryNotFoundError, 'Could not find libui shared library. LibUI.ffi_lib is nil.'
         | 
| 13 | 
            +
                elsif !File.exist?(LibUI.ffi_lib)
         | 
| 14 | 
            +
                  raise LibraryNotFoundError, "Could not find libui shared library: #{LibUI.ffi_lib}"
         | 
| 15 | 
            +
                else
         | 
| 16 | 
            +
                  begin
         | 
| 17 | 
            +
                    dlload LibUI.ffi_lib
         | 
| 18 | 
            +
                  rescue LoadError
         | 
| 19 | 
            +
                    raise LibraryLoadError, "Could not load libui shared library: #{LibUI.ffi_lib}"
         | 
| 20 | 
            +
                  end
         | 
| 13 21 | 
             
                end
         | 
| 14 22 |  | 
| 15 23 | 
             
                class << self
         | 
| @@ -18,6 +26,8 @@ module LibUI | |
| 18 26 | 
             
                  def try_extern(signature, *opts)
         | 
| 19 27 | 
             
                    extern(signature, *opts)
         | 
| 20 28 | 
             
                  rescue StandardError => e
         | 
| 29 | 
            +
                    # Do not raise error when the function is not found
         | 
| 30 | 
            +
                    # because some functions may not be available on older versions of libui.
         | 
| 21 31 | 
             
                    warn "#{e.class.name}: #{e.message}"
         | 
| 22 32 | 
             
                  end
         | 
| 23 33 |  | 
| @@ -27,6 +37,7 @@ module LibUI | |
| 27 37 | 
             
                end
         | 
| 28 38 |  | 
| 29 39 | 
             
                typealias('uint32_t', 'unsigned int')
         | 
| 40 | 
            +
                typealias('uint64_t', 'unsigned long long')
         | 
| 30 41 |  | 
| 31 42 | 
             
                InitOptions = struct [
         | 
| 32 43 | 
             
                  'size_t Size'
         | 
    
        data/lib/libui/fiddle_patch.rb
    CHANGED
    
    | @@ -16,7 +16,7 @@ module LibUI | |
| 16 16 | 
             
                                      when /^([\w\*\s]+[*\s])(\w+)\((.*?)\);?$/
         | 
| 17 17 | 
             
                                        [parse_ctype(Regexp.last_match(1).strip, tymap), Regexp.last_match(2), Regexp.last_match(3)]
         | 
| 18 18 | 
             
                                      else
         | 
| 19 | 
            -
                                        raise("can't  | 
| 19 | 
            +
                                        raise("can't parse the function prototype: #{signature}")
         | 
| 20 20 | 
             
                                      end
         | 
| 21 21 | 
             
                  symname = func
         | 
| 22 22 | 
             
                  callback_argument_types = {}                                              # Added
         | 
    
        data/lib/libui/libui_base.rb
    CHANGED
    
    | @@ -25,11 +25,13 @@ module LibUI | |
| 25 25 | 
             
                      # Protect from GC
         | 
| 26 26 | 
             
                      # by giving the owner object a reference to the callback.
         | 
| 27 27 | 
             
                      # See https://github.com/kojix2/LibUI/issues/8
         | 
| 28 | 
            -
                       | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 28 | 
            +
                      receiver = args.first
         | 
| 29 | 
            +
                      owner = if idx == 0 || # UI.queue_main{}
         | 
| 30 | 
            +
                                 receiver.nil? ||
         | 
| 31 | 
            +
                                 (receiver.respond_to?(:frozen?) && receiver.frozen?) # UI.timer(100) {}
         | 
| 32 | 
            +
                                LibUIBase # keep a reference on an internal module to avoid GC
         | 
| 31 33 | 
             
                              else
         | 
| 32 | 
            -
                                 | 
| 34 | 
            +
                                receiver # receiver object holds the callback
         | 
| 33 35 | 
             
                              end
         | 
| 34 36 | 
             
                      if owner.instance_variable_defined?(:@callbacks)
         | 
| 35 37 | 
             
                        owner.instance_variable_get(:@callbacks) << callback
         | 
    
        data/lib/libui/version.rb
    CHANGED
    
    
    
        data/lib/libui.rb
    CHANGED
    
    | @@ -1,16 +1,26 @@ | |
| 1 1 | 
             
            require_relative 'libui/version'
         | 
| 2 2 | 
             
            require_relative 'libui/utils'
         | 
| 3 | 
            +
            require_relative 'libui/error'
         | 
| 3 4 | 
             
            require 'rbconfig'
         | 
| 4 5 |  | 
| 5 6 | 
             
            module LibUI
         | 
| 6 | 
            -
              class Error < StandardError; end
         | 
| 7 | 
            -
             | 
| 8 7 | 
             
              class << self
         | 
| 9 8 | 
             
                attr_accessor :ffi_lib
         | 
| 10 9 | 
             
              end
         | 
| 11 10 |  | 
| 11 | 
            +
              host_cpu = case RbConfig::CONFIG['host_cpu']
         | 
| 12 | 
            +
                         when /i\d86/
         | 
| 13 | 
            +
                           'x86'
         | 
| 14 | 
            +
                         else
         | 
| 15 | 
            +
                           RbConfig::CONFIG['host_cpu']
         | 
| 16 | 
            +
                         end
         | 
| 17 | 
            +
             | 
| 12 18 | 
             
              lib_name = [
         | 
| 19 | 
            +
                # For libui-ng shared libraries compiled with (rake vendor:build)
         | 
| 13 20 | 
             
                "libui.#{RbConfig::CONFIG['host_cpu']}.#{RbConfig::CONFIG['SOEXT']}",
         | 
| 21 | 
            +
                # For libui-ng shared library downloaded from RubyGems.org
         | 
| 22 | 
            +
                "libui.#{host_cpu}.#{RbConfig::CONFIG['SOEXT']}",
         | 
| 23 | 
            +
                # For backward compatibility or manual compilation of libui-ng
         | 
| 14 24 | 
             
                "libui.#{RbConfig::CONFIG['SOEXT']}"
         | 
| 15 25 | 
             
              ]
         | 
| 16 26 |  | 
| @@ -32,15 +42,21 @@ module LibUI | |
| 32 42 |  | 
| 33 43 | 
             
              class << self
         | 
| 34 44 | 
             
                def init(opt = nil)
         | 
| 45 | 
            +
                  # Allocate uiInitOptions if not provided
         | 
| 35 46 | 
             
                  unless opt
         | 
| 36 47 | 
             
                    opt = FFI::InitOptions.malloc
         | 
| 37 48 | 
             
                    opt.to_ptr.free = Fiddle::RUBY_FREE
         | 
| 49 | 
            +
                    opt.Size = FFI::InitOptions.size
         | 
| 38 50 | 
             
                  end
         | 
| 39 | 
            -
                  i = super(opt)
         | 
| 40 | 
            -
                  return if i.size.zero?
         | 
| 41 51 |  | 
| 42 | 
            -
                   | 
| 43 | 
            -
                   | 
| 52 | 
            +
                  err_ptr = super(opt) # uiInit returns const char* error or NULL on success
         | 
| 53 | 
            +
                  return nil if err_ptr.null?
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  # Convert C string to Ruby string and free the error string per API contract
         | 
| 56 | 
            +
                  err_msg = err_ptr.to_s
         | 
| 57 | 
            +
                  free_init_error(err_ptr)
         | 
| 58 | 
            +
                  warn err_msg
         | 
| 59 | 
            +
                  nil
         | 
| 44 60 | 
             
                end
         | 
| 45 61 |  | 
| 46 62 | 
             
                # Gets the window position.
         | 
    
        data/vendor/libui.x86_64.so
    CHANGED
    
    | Binary file | 
    
        metadata
    CHANGED
    
    | @@ -1,16 +1,28 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: libui
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: x86_64-linux
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - kojix2
         | 
| 8 | 
            -
            autorequire:
         | 
| 9 8 | 
             
            bindir: bin
         | 
| 10 9 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 12 | 
            -
            dependencies: | 
| 13 | 
            -
             | 
| 10 | 
            +
            date: 1980-01-02 00:00:00.000000000 Z
         | 
| 11 | 
            +
            dependencies:
         | 
| 12 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 13 | 
            +
              name: fiddle
         | 
| 14 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 15 | 
            +
                requirements:
         | 
| 16 | 
            +
                - - ">="
         | 
| 17 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 18 | 
            +
                    version: '0'
         | 
| 19 | 
            +
              type: :runtime
         | 
| 20 | 
            +
              prerelease: false
         | 
| 21 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 22 | 
            +
                requirements:
         | 
| 23 | 
            +
                - - ">="
         | 
| 24 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 25 | 
            +
                    version: '0'
         | 
| 14 26 | 
             
            email:
         | 
| 15 27 | 
             
            - 2xijok@gmail.com
         | 
| 16 28 | 
             
            executables: []
         | 
| @@ -20,6 +32,7 @@ files: | |
| 20 32 | 
             
            - LICENSE.txt
         | 
| 21 33 | 
             
            - README.md
         | 
| 22 34 | 
             
            - lib/libui.rb
         | 
| 35 | 
            +
            - lib/libui/error.rb
         | 
| 23 36 | 
             
            - lib/libui/ffi.rb
         | 
| 24 37 | 
             
            - lib/libui/fiddle_patch.rb
         | 
| 25 38 | 
             
            - lib/libui/libui_base.rb
         | 
| @@ -32,7 +45,6 @@ homepage: https://github.com/kojix2/libui | |
| 32 45 | 
             
            licenses:
         | 
| 33 46 | 
             
            - MIT
         | 
| 34 47 | 
             
            metadata: {}
         | 
| 35 | 
            -
            post_install_message:
         | 
| 36 48 | 
             
            rdoc_options: []
         | 
| 37 49 | 
             
            require_paths:
         | 
| 38 50 | 
             
            - lib
         | 
| @@ -43,12 +55,11 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 43 55 | 
             
                  version: '2.6'
         | 
| 44 56 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 45 57 | 
             
              requirements:
         | 
| 46 | 
            -
              - - " | 
| 58 | 
            +
              - - ">="
         | 
| 47 59 | 
             
                - !ruby/object:Gem::Version
         | 
| 48 | 
            -
                  version:  | 
| 60 | 
            +
                  version: '0'
         | 
| 49 61 | 
             
            requirements: []
         | 
| 50 | 
            -
            rubygems_version: 3. | 
| 51 | 
            -
            signing_key:
         | 
| 62 | 
            +
            rubygems_version: 3.6.9
         | 
| 52 63 | 
             
            specification_version: 4
         | 
| 53 64 | 
             
            summary: Ruby bindings to libui
         | 
| 54 65 | 
             
            test_files: []
         |