{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

module KitsuneBook.PrettyPrint where

import           Common
import qualified Data.Text as Text

printNotes :: MonadIO m => (Text -> m ()) -> [(Int, NoteInfo)] -> m ()
printNotes cmd notes = cmd . notesToText $ notes
  where notesToText =
          intercalate "\n" .
          map (uncurry prettyShow)

printNotes' :: MonadIO m => [(Int, NoteInfo)] -> m ()
printNotes' = printNotes say'

data PrettyShowType = Short | Description | ShortBody | FullBody

prettyShow' :: PrettyShowType -> Int -> NoteInfo -> Text -> Text
prettyShow' t i n body =
  case t of
    Short -> " <" ++ show i ++ "> " ++ noteName n ++ " :: " ++ tags
    Description -> prettyShow' Short i n body ++ "\n\t" ++ desc
    ShortBody -> prettyShow' Short i n body ++ "\n\t" ++ short body
    FullBody -> prettyShow' Short i n body ++ "\n\t" ++ body
  where ts = noteTags n
        tags =
          if null ts
             then "/no tags/"
             else Text.intercalate ", " .
                  map ("@" ++) $
                  ts
        desc = noteDescription n
        short _ = ""

prettyShow :: Int -> NoteInfo -> Text
prettyShow i n = prettyShow' Short i n ""

takeShort :: Text -> Text
takeShort = undefined
