// -*- Mode: java; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-

package com.danger.terminal;

import danger.app.SettingsDB;


/**
 * Terminal-wide preferences.
 * 
 * There used to be more of these, but now it's down to just the default font
 * to use.  Kinda silly.
 */
public class TerminalPreferences
    implements TerminalResources
{
    public
    TerminalPreferences (SessionManager manager)
    {
        mSessionManager = manager;
        mPrefs = manager.getSettingsDB();
        
        /* default to these until we get real data */
        mDefaultFont = Terminal.instance().getString(DEFAULT_FONT);
    }
    
    public void
    load ()
    {
        mDefaultFont = mPrefs.getStringValue(FONT_KEY);
        if (mDefaultFont == null) {
            mDefaultFont = Terminal.instance().getString(DEFAULT_FONT);
        }
    }

    public String
    getDefaultFont ()
    {
        return mDefaultFont;
    }
    
    public void
    setDefaultFont (String font)
    {
        if (mDefaultFont != font) {
            mDefaultFont = font;
            mPrefs.setStringValue(FONT_KEY, font);
        }
    }
    
    
    protected SettingsDB        mPrefs;
    protected SessionManager    mSessionManager;
    protected String            mDefaultFont;
    
    /* settings keys */
    static final String         FONT_KEY = "font";
}
