Sha256: fafa8256610fba01b3faaebe5844128f5dacf6e95d9580bda3bb714aac4f9d48

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

# require "rbconfig"
# RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ # windows

module Unicode
  class DisplayWidth
    module EmojiSupport
      # Tries to find out which terminal emulator is used to
      # set emoji: config to best suiting value
      #
      # Please note: Many terminals do not set any ENV vars
      def self.recommended
        if ENV["CI"]
          return :rqi_uqe
        end

        case ENV["TERM_PROGRAM"]
        when "iTerm.app"
          return :all
        when "Apple_Terminal"
          return :rgi_uqe
        end

        case ENV["TERM"]
        when "contour"
          return :rgi_uqe
        when /kitty/
          return :rgi_fqe
        end

        # As of last time checked: gnome-terminal, vscode, alacritty, konsole
        :basic
      end

      # Maybe: Implement something like https://github.com/jquast/ucs-detect
      #        which uses the terminal cursor to check for best support level
      #        at runtime
      # def self.detect!
      # end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unicode-display_width-3.0.0 lib/unicode/display_width/emoji_support.rb
unicode-display_width-3.0.0.pre lib/unicode/display_width/emoji_support.rb