<commit_before>class Shoes
  DEFAULT_TEXTBLOCK_FONT = "Arial"

  class TextBlock
    include CommonMethods
    include Common::Clickable
    include DimensionsDelegations


    attr_reader   :gui, :parent, :text, :links, :app, :text_styles, :dimensions
    attr_accessor :font, :font_size, :cursor, :textcursor

    def initialize(app, parent, text, font_size, opts = {})
      @parent       = parent
      @app          = app
      @font         = @app.font || DEFAULT_TEXTBLOCK_FONT
      @font_size    = opts[:size] || font_size
      @text         = text
      @links        = []
      @text_styles  = opts[:text_styles]
      opts[:stroke] = Shoes::Color.new(opts[:stroke]) if opts[:stroke].is_a?(String)
      opts[:fill]   = Shoes::Color.new(opts[:fill]) if opts[:fill].is_a?(String)
      @dimensions   = Dimensions.new parent, opts

      handle_opts opts

      @gui = Shoes.configuration.backend_for(self, opts)
      self.width, self.height = @gui.get_size
      @parent.add_child(self)
      set_size left

      clickable_options(opts)
    end

    def text=(*values)
      @gui.replace *values[0]
    end

    def replace *values
      @gui.replace *values
    end

    def to_s
      self.text
    end

    def set_size left
      self.width = (left + @parent.width <= app.width) ? @parent.width : app.width - left
      self.height = @gui.get_height + margin_top + margin_bottom
    end

    # We always claim we fit, and do our own wrapping if we don't
    def fits_on_the_same_line?(_)
      true
    end

    def absolute_right=(value)
      @absolute_right = value
    end

    def absolute_right
      return @dimensions.absolute_right unless @absolute_right
      @absolute_right
    end

    def update_current_position(current_position)
      @gui.update_current_position(current_position)
    end

    private

    def handle_opts(opts)
      parse_font_opt opts[:font] if opts.has_key? :font
    end

    def parse_font_opt(type)
      size_regex = /\d+(?=px)?/
      style_regex = /none|bold|normal|oblique|italic/i # TODO: add more

      font_family = type.gsub(style_regex,'').gsub(/\d+(px)?/,'').<commit_msg>With update_current_position, don't need absolute_right overrides<commit_after>class Shoes
  DEFAULT_TEXTBLOCK_FONT = "Arial"

  class TextBlock
    include CommonMethods
    include Common::Clickable
    include DimensionsDelegations


    attr_reader   :gui, :parent, :text, :links, :app, :text_styles, :dimensions
    attr_accessor :font, :font_size, :cursor, :textcursor

    def initialize(app, parent, text, font_size, opts = {})
      @parent       = parent
      @app          = app
      @font         = @app.font || DEFAULT_TEXTBLOCK_FONT
      @font_size    = opts[:size] || font_size
      @text         = text
      @links        = []
      @text_styles  = opts[:text_styles]
      opts[:stroke] = Shoes::Color.new(opts[:stroke]) if opts[:stroke].is_a?(String)
      opts[:fill]   = Shoes::Color.new(opts[:fill]) if opts[:fill].is_a?(String)
      @dimensions   = Dimensions.new parent, opts

      handle_opts opts

      @gui = Shoes.configuration.backend_for(self, opts)
      self.width, self.height = @gui.get_size
      @parent.add_child(self)
      set_size left

      clickable_options(opts)
    end

    def text=(*values)
      @gui.replace *values[0]
    end

    def replace *values
      @gui.replace *values
    end

    def to_s
      self.text
    end

    def set_size left
      self.width = (left + @parent.width <= app.width) ? @parent.width : app.width - left
      self.height = @gui.get_height + margin_top + margin_bottom
    end

    # We always claim we fit, and do our own wrapping if we don't
    def fits_on_the_same_line?(_)
      true
    end

    def update_current_position(current_position)
      @gui.update_current_position(current_position)
    end

    private

    def handle_opts(opts)
      parse_font_opt opts[:font] if opts.has_key? :font
    end

    def parse_font_opt(type)
      size_regex = /\d+(?=px)?/
      style_regex = /none|bold|normal|oblique|italic/i # TODO: add more

      font_family = type.gsub(style_regex,'').gsub(/\d+(px)?/,'').
{'fraction_non_alphanumeric': 0.11073582629674307, 'fraction_numerical': 0.0004825090470446321, 'mean_word_length': 2.672276350752879, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1424474', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1324, 'n_words': 301}