gnachman/iTerm2 — pull request #149 by samdoshi (2013-11-23 21:16:41+00:00)
Title: Adding sRGB support to iTerm themes

### Problem
Currently iTerm 2 themes are specified using colours with a colour space of "Apple Generic RGB" (a.k.a `NSCalibratedRGBColorSpace`) this presents a bit of a problem when trying to automatically generate themes, e.g. [chriskempson/base16](https://github.com/chriskempson/base16), as colour space conversion is *hard*. See textmate/textmate@d70ccc7 for other OSX software with a similar issue.

### Solution
This pull request attempts to fix the issue by allowing each colour to specify it's colour space in a theme file:
- Calibrated: The current colour space used by iTerm themes.
- sRGB: What people expect when they use hex colours (e.g. CSS).

e.g.
```xml
Ansi 0 Color

Color Space
sRGB
Blue Component
0.21176470588235294
Green Component
0.16862745098039217
Red Component
0.0

```

I've done this by standardising all colour loading and saving on `encodeColor` and `decodeColor` in `ITAddressBookMgr`. If no colour space is specified then it falls back to calibrated so that existing themes continue to look the same. Themes are exported using "calibrated".

### Example
![example](https://f.cloud.github.com/assets/112490/1607376/d4e44edc-5482-11e3-98ee-784cefd8bb9b.png)
In the example image, the left hand terminal is using [base16-solarized.dark.itermcolors](https://gist.github.com/samdoshi/3dae6125047652d36ff7) as it's theme, the right hand is using [base16-solarized.dark-srgb.itermcolors](https://gist.github.com/samdoshi/486d48564ebcb3b2e611) which specifies sRGB as it's colour space. The raw R, G and B values for both themes are the same. Underneath on the left we have Safari displaying the Solarized website, and on the right Preview viewing the same [PNG](http://ethanschoonover.com/solarized/img/solarized-palette.png); notice that the colours do not match between Safari and Preview. (Preview is correct: http://ethanschoonover.com/solarized#the-values, Safari like all web browsers is not colour managed.)

### Backwards Compatibility
At the moment, themes created with iTerm using this patch are not backwards compatible as the previous `decodeColor` method would only allow dictionaries with a count of 3 to be used. We could omit the "Color Space" key in `encodeColor` as "Calibrated" is the default option, thus any exported themes will only have 3 entries per colour.