Use color scheme 'name' as key (vs an index number) #3712

Closed
opened 2026-01-30 23:28:07 +00:00 by claunia · 1 comment
Owner

Originally created by @mikemaccana on GitHub (Sep 2, 2019).

Currently color schemes are referred to by their name attribute:

"colorScheme": "Monokai Soda",

But they're stored in an array, ie keyed by index number. The actual key used - name - is mixed in with the colors. This makes the file slightly harder to parse if you're hand editing, and is also odd - you don't expect the name to be one of the colors.

Instead of:

  "schemes": [
    {
      "background": "#1A1A1A",
      "black": "#CCCCCC",
      "blue": "#9D65FF",
      "brightBlack": "#625E4C",
      "brightBlue": "#9D65FF",
      "brightCyan": "#58D1EB",
      "brightGreen": "#98E024",
      "brightPurple": "#F4005F",
      "brightRed": "#F4005F",
      "brightWhite": "#F6F6EF",
      "brightYellow": "#E0D561",
      "cyan": "#58D1EB",
      "foreground": "#C4C5B5",
      "green": "#98E024",
      "name": "Monokai Soda",
      "purple": "#F4005F",
      "red": "#F4005F",
      "white": "#C4C5B5",
      "yellow": "#FA8419"
    }
  ]

It would be better to do:

  "schemes": {
    "Monokai Soda": {
      "background": "#1A1A1A",
      "black": "#CCCCCC",
      "blue": "#9D65FF",
      "brightBlack": "#625E4C",
      "brightBlue": "#9D65FF",
      "brightCyan": "#58D1EB",
      "brightGreen": "#98E024",
      "brightPurple": "#F4005F",
      "brightRed": "#F4005F",
      "brightWhite": "#F6F6EF",
      "brightYellow": "#E0D561",
      "cyan": "#58D1EB",
      "foreground": "#C4C5B5",
      "green": "#98E024",
      "purple": "#F4005F",
      "red": "#F4005F",
      "white": "#C4C5B5",
      "yellow": "#FA8419"
    }
  }
Originally created by @mikemaccana on GitHub (Sep 2, 2019). Currently color schemes are referred to by their `name` attribute: ```"colorScheme": "Monokai Soda",``` But they're stored in an array, ie keyed by index number. The actual key used - `name` - is mixed in with the colors. This makes the file slightly harder to parse if you're hand editing, and is also odd - you don't expect the name to be one of the colors. Instead of: ``` "schemes": [ { "background": "#1A1A1A", "black": "#CCCCCC", "blue": "#9D65FF", "brightBlack": "#625E4C", "brightBlue": "#9D65FF", "brightCyan": "#58D1EB", "brightGreen": "#98E024", "brightPurple": "#F4005F", "brightRed": "#F4005F", "brightWhite": "#F6F6EF", "brightYellow": "#E0D561", "cyan": "#58D1EB", "foreground": "#C4C5B5", "green": "#98E024", "name": "Monokai Soda", "purple": "#F4005F", "red": "#F4005F", "white": "#C4C5B5", "yellow": "#FA8419" } ] ``` It would be better to do: ``` "schemes": { "Monokai Soda": { "background": "#1A1A1A", "black": "#CCCCCC", "blue": "#9D65FF", "brightBlack": "#625E4C", "brightBlue": "#9D65FF", "brightCyan": "#58D1EB", "brightGreen": "#98E024", "brightPurple": "#F4005F", "brightRed": "#F4005F", "brightWhite": "#F6F6EF", "brightYellow": "#E0D561", "cyan": "#58D1EB", "foreground": "#C4C5B5", "green": "#98E024", "purple": "#F4005F", "red": "#F4005F", "white": "#C4C5B5", "yellow": "#FA8419" } } ```
Author
Owner

@zadjii-msft commented on GitHub (Sep 9, 2019):

So, we just discussed this right now.

There are a couple issues here. If we use the name as the primary key for the scheme, and don't include the name property in the scheme object, then the object can't really exist independently. The scheme object is now dependent upon being in a map of other colors.

Also, what happens if we have more sources for settings than just the singular profiles.json file? What if we have some WindowsTerminal/schemes folder with a bunch of scheme files? These might conflict, they might not have the name as the key for the object.

I'm not really sure what we get from switching to this schema, esp. when #2515 will both not reorder settings, and add a defaults.json where the name is the first key.

@zadjii-msft commented on GitHub (Sep 9, 2019): So, we just discussed this right now. There are a couple issues here. If we use the `name` as the primary key for the scheme, and _don't_ include the `name` property in the scheme object, then the object can't really exist independently. The scheme object is now dependent upon being in a map of other colors. Also, what happens if we have more sources for settings than just the singular `profiles.json` file? What if we have some `WindowsTerminal/schemes` folder with a bunch of scheme files? These might conflict, they might not have the name as the key for the object. I'm not really sure what we get from switching to this schema, esp. when #2515 will both _not_ reorder settings, and add a `defaults.json` where the name _is_ the first key.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3712