Skip to main content
 首页 » 编程设计

python之如何在realgud中自定义颜色

2025年05月04日7lori

我刚刚安装了 realgud,这样我就可以使用 trepan2 在 emacs 中调试 python。我立即遇到了一个严重的问题:comint 缓冲区中的某些颜色太浅以至于几乎看不见:白色上的浅蓝色甚至黄色。我该如何改变它们?

我尝试关闭缓冲区中的 fontlock-mode,但颜色仍然存在。我也试过 M-x customize-faces,但我不清楚 realgud 使用了列出的数百张面孔中的哪一张。 (实际上有六个名字以“Realgud”开头,但似乎没有一个是相关的。)我滚动浏览了整个列表,但找不到任何黄色或浅蓝色的。我还尝试将主题更改为背景较暗的主题:这使黄色可见,但随后深色消失了。

编辑:根据 lawlist 的建议,这里是 C-u C-x = 的结果。如果我没理解错,那就意味着黄色是硬编码的。

             position: 8445 of 9070 (93%), column: 39 
            character: 0 (displayed as 0) (codepoint 48, #o60, #x30) 
    preferred charset: ascii (ASCII (ISO646 IRV)) 
code point in charset: 0x30 
               syntax: w    which means: word 
             category: .:Base, a:ASCII, l:Latin, r:Roman 
             to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET NAME" 
          buffer code: #x30 
            file code: #x30 (encoded by coding system utf-8-unix) 
              display: by this font (glyph code) 
    x:-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1 (#x30) 
 
Character code properties: customize what to show 
  name: DIGIT ZERO 
  general-category: Nd (Number, Decimal Digit) 
  decomposition: (48) ('0') 
 
There is an overlay here: 
 From 8437 to 8450 
  face                 (foreground-color . "yellow") 
  modification-hooks   (ansi-color-freeze-overlay) 
 
 
There are text properties here: 
  field                output 
  fontified            t 
  front-sticky         (field inhibit-line-move-field-capture) 
  inhibit-line-move-field-capture t 
  rear-nonsticky       t 
 
[back] 

老实说,我已经对 realgud 失去了兴趣。尽管增强型 pdb 的想法听起来不错,但 trepan2 和 realgud 似乎有多个令人痛苦的缺陷,使它们几乎无法使用。

谢谢。

请您参考如下方法:

颜色映射来自ansi-term。

这是我的 .emacs 中的内容,但请注意,我使用的是浅色(白色)背景。请注意,虽然主要设置是 ansi-term-color-vector,但它的颜色定义必须事先准备好。

(defface term-color-darkgreen 
  '((t :foreground "DarkGreen" :background "DarkGreen")) 
  "Face used to render dark green color code." 
  :group 'term) 
 
 
(defface term-color-cadetblue 
  '((t :foreground "CadetBlue" :background "CadetBAlue")) 
  "Face used to render dark cadet blue color code." 
  :group 'term) 
 
(defface term-color-purple 
  '((t :foreground "Purple" :background "Purple")) 
  "Face used to render dark Purple color code." 
  :group 'term) 
 
(defface term-color-darkgoldenrod 
  '((t :foreground "Darkgoldenrod" :background "Darkgoldenrod")) 
  "Face used to render dark Darkgoldenrod color code." 
  :group 'term) 
 
(defface term-color-ivory4 
  '((t :foreground "Ivory4" :background "Ivory4")) 
  "Face used to render dark Ivory4 color code." 
  :group 'term) 
 
 
(setq ansi-term-color-vector 
      [term 
       term-color-black 
       term-color-red 
       term-color-darkgreen 
       term-color-cadetblue 
       term-color-blue 
       term-color-purple 
       term-color-darkgoldenrod 
       term-color-ivory4])