1.10 Color Schemes 🔗

DrRacket comes with a selection of color schemes, available in the preferences dialog’s color panel.

You can add your own color schemes to DrRacket, too. The first step is to create a package (see Creating Packages) and add an "info.rkt" file to it. The file should define framework:color-schemes as a list of hashes that describe the color schemes.

As an example, this is the specification of the "Modern" style:
#lang info
(define framework:color-schemes
  '(#hash((colors
           .
           ((framework:syntax-color:scheme:string
             #(211 72 255))
            (framework:syntax-color:scheme:constant
             #(211 72 255))
            (framework:syntax-color:scheme:comment
             #(194 158 31))
            (framework:syntax-color:scheme:parenthesis
             #(0 150 255))))
          (name . "Modern"))))
 

Each of the keys, e.g., ’framework:syntax-color:scheme:string, maps to a color and possibly to some style information. All keys accept colors (the vectors shown above represent colors in red–green–blue format), but only some accept style information. To find out which are which and to get a complete list of the possible keys, click the button labeled Style & Color Names at the bottom of the Color Schemes tab of the Colors tab in the preferences dialog. If one can accept style information, then you may include any of 'bold, 'underline, 'italic or `#s(background ,color) in the list with the color.

Full details on the specification of the info files can be found in the documentation for the function color-prefs:register-info-based-color-schemes.

You may have to restart DrRacket (and, at least the first time after you add the "info.rkt" file, re-run raco setup) to see changes to your color scheme.

Color schemes are not limited only to the colors that DrRacket already knows about. If you are adding your own plugin to DrRacket, you can add new names that can be mapped in the color scheme. See color-prefs:register-color-preference for more information.