zwirn-0.2.3.1: app/zwirnmill/Editor/Core.hs
{-# LANGUAGE TemplateHaskell #-}
module Editor.Core where
import qualified Data.Text as T
import Data.Text.Zipper
import Lens.Micro.TH (makeLenses)
data Diagnostic = Diagnostic
{ diagnosticLoc :: ((Int, Int), (Int, Int)),
diagnosticText :: String
}
deriving (Eq, Show)
data UndoEntry = UndoEntry
{ undoZipper :: TextZipper T.Text,
undoSelection :: Maybe (Int, Int)
}
deriving (Eq, Show)
data Popup = Popup
{ popupContent :: String,
popupPosition :: (Int, Int)
}
deriving (Eq, Show)
data OutputType
= OutputError
| OutputInfo
deriving (Eq, Show)
data EditorState = EditorState
{ _esZipper :: TextZipper T.Text,
_esDiagnostics :: [Diagnostic],
_esFilePath :: Maybe FilePath,
_esUnsaved :: Bool,
_esUndoStack :: [UndoEntry],
_esRedoStack :: [UndoEntry],
_esSelection :: Maybe (Int, Int),
_esFlashBlock :: Maybe (OutputType, (Int, Int)),
_esTabWidth :: Int,
_esMessage :: Maybe String,
_esPopup :: Maybe Popup
}
deriving (Eq, Show)
makeLenses ''EditorState
newEditor :: EditorState
newEditor =
EditorState
{ _esZipper = textZipper [] Nothing,
_esDiagnostics = [],
_esFilePath = Nothing,
_esUnsaved = False,
_esUndoStack = [],
_esRedoStack = [],
_esSelection = Nothing,
_esFlashBlock = Nothing,
_esTabWidth = 4,
_esMessage = Nothing,
_esPopup = Nothing
}