Sha256: d17a3cc2246d95922c9c3a77c481a9b1cf81713f79249117d0aa2d7dbc17258b

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

require "karabiner/history"
require "karabiner/namespace"
require "karabiner/property"
require "karabiner/remap"
require "karabiner/vkopenurldef"

module Karabiner::DSL::Item
  AVAILABLE_PROPERTIES = %i[
    name
    identifier
    autogen
  ].freeze

  def remap(target, options = {})
    remap = Karabiner::Remap.new(target, options[:to])
    add_child(remap)
  end

  def show_message(message)
    property = Karabiner::Property.new("autogen", "__ShowStatusMessage__ #{message}")
    add_child(property)
  end

  def invoke(application)
    Karabiner::History.register_application(application)
    Karabiner::Vkopenurldef.application_keycode(application)
  end

  def execute(script)
    Karabiner::History.register_script(script)
    Karabiner::Vkopenurldef.script_keycode(script)
  end

  private

  def method_missing(property, value = '', options = {})
    if AVAILABLE_PROPERTIES.include?(property)
      property = Karabiner::Property.new(property, value, options)
      add_child(property)
    else
      super
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
karabiner-0.4.0 lib/karabiner/dsl/item.rb
karabiner-0.3.1 lib/karabiner/dsl/item.rb
karabiner-0.3.0 lib/karabiner/dsl/item.rb
karabiner-0.2.1 lib/karabiner/dsl/item.rb
karabiner-0.2.0 lib/karabiner/dsl/item.rb