module Document where

import Cursor
import System.IO.MMap
import qualified Data.ByteString.Lazy as B

type Text = B.ByteString

data Document = Document {
  text :: Text,
  mode :: DocumentMode,
  cursor :: Cursor
}

data DocumentMode = Normal | Insert | Selection

readDocument :: FilePath -> IO Document
readDocument path = do
  	bs <- mmapFileByteStringLazy path Nothing
  	return $ Document bs Normal cursor
  where cursor = Cursor (0,0) Nothing
