module Yi.Config where
import Data.Prototype
import Data.Accessor.Template
import Yi.Buffer
import Yi.Layout
import Yi.Config.Misc
import Yi.Keymap
import Yi.Editor
import Yi.Dynamic(ConfigVariables)
import Yi.Event
import Yi.Style
import Yi.Style.Library
import Yi.UI.Common
import qualified Yi.Interact as I
data UIConfig = UIConfig {
configVtyEscDelay :: Int,
configFontName :: Maybe String,
configFontSize :: Maybe Int,
configScrollStyle ::Maybe ScrollStyle,
configScrollWheelAmount :: Int,
configLeftSideScrollBar :: Bool,
configAutoHideScrollBar :: Bool,
configAutoHideTabBar :: Bool,
configLineWrap :: Bool,
configCursorStyle :: CursorStyle,
configWindowFill :: Char,
configTheme :: Theme
}
data CursorStyle = AlwaysFat
| NeverFat
| FatWhenFocused
| FatWhenFocusedAndInserting
configStyle :: UIConfig -> UIStyle
configStyle = extractValue . configTheme
data Config = Config {startFrontEnd :: UIBoot,
configUI :: UIConfig,
startActions :: [Action],
initialActions :: [Action],
defaultKm :: KeymapSet,
configInputPreprocess :: I.P Event Event,
modeTable :: [AnyMode],
debugMode :: Bool,
configRegionStyle :: RegionStyle,
configKillringAccumulate :: Bool,
configCheckExternalChangesObsessively :: Bool,
bufferUpdateHandler :: [([Update] -> BufferM ())],
layoutManagers :: [AnyLayoutManager],
configVars :: ConfigVariables
}
configFundamentalMode :: Config -> AnyMode
configFundamentalMode = last . modeTable
configTopLevelKeymap :: Config -> Keymap
configTopLevelKeymap = extractTopKeymap . defaultKm
type UIBoot = Config -> (Event -> IO ()) -> ([Action] -> IO ()) -> Editor -> IO UI
$(nameDeriveAccessors ''Config (\n -> Just (n ++ "A")))
$(nameDeriveAccessors ''UIConfig (\n -> Just (n ++ "A")))