Files
gnatstudio/examples/python/colors.py
Emmanuel Briot 6b10aec791 No need for os.path in fact
git-svn-id: svn+ssh://svn.eu/Dev/importfromcvs/trunk@88912 936e1b1b-40f2-da11-902a-00137254ae57
2004-09-27 13:14:51 +00:00

31 lines
1.0 KiB
Python

## This script sets the background color of .adb files and .ads files
## automatically when they are loaded.
## It demonstrates the use of hooks, and the setting of preferences in GPS
import GPS
def set_bg_color (hook_name, file):
name = file.name()
if name [len(name) - 4 :] == ".adb":
GPS.Editor.set_background_color (file.name(), GPS.Preference ("custom-adb-file-color").get())
elif name [len(name) - 4 :] == ".ads":
GPS.Editor.set_background_color (file.name(), GPS.Preference ("custom-ads-file-color").get())
GPS.parse_xml ("""
<preference name="custom-adb-file-color"
label="Background color for .adb files"
page="Editor:Fonts &amp; Colors"
default="yellow"
type="color" />
<preference name="custom-ads-file-color"
label="Background color for .ads files"
page="Editor:Fonts &amp; Colors"
default="red"
type="color" />
""")
GPS.Hook ("file_edited").add (set_bg_color)