如何调整撬色 [英] How to adjust pry colors

查看:34
本文介绍了如何调整撬色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

褪色只是 0.9.7.3 及之前版本的问题.此后已更改为更深的灰色.

The faded gray is only an issue with version 0.9.7.3 and before. It has since been changed to a darker gray.

Pry 有很好的着色,但是创建或更改对象时返回的值是我几乎看不到的褪色灰色.

Pry has nice colorizing, but the value returned when an object is created or changed is a faded gray that I can barely see.

 u = User.new
 =>#<User...   <<<<<< This is what is barely readable.

我尝试弄乱 .pryrc 中的值,但无法更改此颜色或任何其他颜色.

I tried messing with values in .pryrc, but couldn't get this, or any other color for that matter, to change.

推荐答案

Pry 使用 CodeRay 进行着色,因此您可以将以下内容放入 .pryrc 文件中:

Pry uses CodeRay for coloring, so you can put the following in your .pryrc file:

CodeRay.scan("example", :ruby).term # just to load necessary files

TERM_TOKEN_COLORS = {
    :symbol => '1;31' # will make symbols bolded and light red on my terminal
}

module CodeRay
    module Encoders
        class Term < Encoder
            # override old colors
            TERM_TOKEN_COLORS.each_pair do |key, value|
                TOKEN_COLORS[key] = value
            end
        end
    end
end

您可以在此处看到所有可以自定义的值(不确定您提到的是哪一个,但应该不难找到):https://github.com/rubychan/coderay/blob/master/lib/coderay/encoders/terminal.rb

You can see here all values that can be customized (not sure which one exactly is the one you mentioned, but shouldn't be hard to track down): https://github.com/rubychan/coderay/blob/master/lib/coderay/encoders/terminal.rb

这篇关于如何调整撬色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆