<commit_before># Abstractions for the window manager.

require 'rumai/fs'
require 'enumerator'

class Object # @private
  # prevent these deprecated properties
  # from clashing with our usage below
  undef id   if respond_to? :id
  undef type if respond_to? :type
end

module Rumai
  IXP_FS_ROOT         = Node.new('/')
  FOCUSED_WIDGET_ID   = 'sel'.freeze
  FLOATING_AREA_ID    = '~'.freeze
  CLIENT_GROUPING_TAG = '@'.freeze
  CLIENT_STICKY_TAG   = '/./'.freeze

  #---------------------------------------------------------------------------
  # abstraction of WM components
  #---------------------------------------------------------------------------

  ##
  # @note Inheritors must override the {Chain#chain} method.
  #
  module Chain
    ##
    # Returns an array of objects related to this one.
    #
    def chain
      [self]
    end

    ##
    # Returns the object after this one in the chain.
    #
    def next
      sibling(+1)
    end

    ##
    # Returns the object before this one in the chain.
    #
    def prev
      sibling(-1)
    end

    private

    def sibling offset
      arr = chain

      if pos = arr.index(self)
        arr[(pos + offset) % arr.length]
      end
    end
  end

  ##
  # The basic building block of the WM hierarchy.
  #
  # @note Inheritors must define a {curr} class method.
  # @note Inheritors must override the {focus} method.
  #
  module WidgetImpl
    attr_reader :id

    def == other
      @id == other.id
    end

    ##
    # Checks if this widget currently has focus.
    #
    def current?<commit_msg>expose Chain methods as class methods for reuse<commit_after># Abstractions for the window manager.

require 'rumai/fs'
require 'enumerator'

class Object # @private
  # prevent these deprecated properties
  # from clashing with our usage below
  undef id   if respond_to? :id
  undef type if respond_to? :type
end

module Rumai
  IXP_FS_ROOT         = Node.new('/')
  FOCUSED_WIDGET_ID   = 'sel'.freeze
  FLOATING_AREA_ID    = '~'.freeze
  CLIENT_GROUPING_TAG = '@'.freeze
  CLIENT_STICKY_TAG   = '/./'.freeze

  #---------------------------------------------------------------------------
  # abstraction of WM components
  #---------------------------------------------------------------------------

  ##
  # @note Inheritors must override the {Chain#chain} method.
  #
  module Chain
    ##
    # Returns an array of objects related to this one.
    #
    def chain
      [self]
    end

    ##
    # Returns the object before this one in the chain.
    #
    def prev
      Chain.prev chain, self
    end

    ##
    # Returns the object after this one in the chain.
    #
    def next
      Chain.next chain, self
    end

    ##
    # Fetches the object that comes before the
    # given target object in the given array.
    #
    def self.prev array, target
      near array, target, -1
    end

    ##
    # Fetches the object that comes after the
    # given target object in the given array.
    #
    def self.next array, target
      near array, target, +1
    end

    ##
    # Fetches the object at the given offset from
    # the given target object in the given array.
    #
    def self.near array, target, offset
      if index = array.index(target)
        array[(index + offset) % array.length]
      end
    end
  end

  ##
  # The basic building block of the WM hierarchy.
  #
  # @note Inheritors must define a {curr} class method.
  # @note Inheritors must override the {focus} method.
  #
  module WidgetImpl
    attr_reader :id

    def == other
      @id == other.id
    end

    ##
    # Checks if this widget currently has focus.
    #
    def current?
{'fraction_non_alphanumeric': 0.1566694056422898, 'fraction_numerical': 0.0010955902492467817, 'mean_word_length': 1.721311475409836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '297485', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1059, 'n_words': 379}