2010-08-23

In the same vein as the โ€œdistraction-free writingโ€ features of WriteRoom and PyRoom, a custom color scheme for gedit can be leveraged to hide all text except for the current line. The effect is something like ADD Helper for your text editor:

Distraction-free writing in gedit

Here I've modified the Oblivion theme:

<?xml version="1.0" encoding="UTF-8"?>
<style-scheme id="oblivion-mask" _name="Oblivion with Mask" version="1.0">
<!-- Color Palette -->
<color name="chameleon3" value="#4e9a06" />
<color name="aluminium1" value="#eeeeec" />
<color name="aluminium4" value="#888a85" />
<color name="aluminium5" value="#555753" />
<color name="aluminium6" value="#2e3436" />
<color name="attention1" value="#ffb300" />

<!-- Color Assignments -->
<style name="text" foreground="aluminium6" background="aluminium6" />
<style name="selection" foreground="aluminium1" background="aluminium4" />
<style name="cursor" foreground="aluminium6" />
<style name="current-line" background="attention1" />
<style name="line-numbers" foreground="aluminium5" background="#black" />
<style name="draw-spaces" foreground="aluminium4" />
<style name="right-margin" foreground="aluminium1" background="aluminium4" />
<style name="search-match" foreground="aluminium1" background="chameleon3" />
</style-scheme>

For ease of use, a keyboard shortcut can be mapped to a small script that toggles between masked and unmasked color schemes:

#!/usr/bin/env bash

set_scheme() {
gconftool-2 --type string --set /apps/gedit-2/preferences/editor/colors/scheme "$1"
}

if [ "$(gconftool-2 --get /apps/gedit-2/preferences/editor/colors/scheme)" = "oblivion-mask" ]; then
set_scheme "oblivion"
else
set_scheme "oblivion-mask"
fi