summaryrefslogtreecommitdiffstats
path: root/src/State.hs
blob: 9f5574328157755ad05533b10bd930825b45f690 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{-# LANGUAGE OverloadedStrings #-}
module State where

import qualified Data.Char
import Data.Default (Default,def)
import Data.Text (Text)
import Data.Maybe (catMaybes)
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import qualified Data.Text.Read as Text
import Control.Monad (forever)
import Blessings.Text (Blessings(Plain,SGR),pp)
import qualified Blessings.Internal as Blessings
import Control.Concurrent
import Data.Time
import Data.Map (Map)
import qualified Data.Map as Map
import Scanner
import System.IO
import qualified System.Console.Terminal.Size as Term
import System.Posix.Signals (Handler(Catch), Signal, installHandler, sigINT)
import Much.Screen (Screen(Screen), withScreen)
import qualified Hack.Buffer as Buffer
import Hack.Buffer (Buffer)
--import XMonad.Aeson ()
--import qualified XMonad.Web.Types ()
--import qualified XMonad
--import qualified XMonad.Web.Types
--import qualified XMonad.StackSet
import Network.HTTP.Client (Manager)
import Pager.Types


data State = State
    { buffer :: Buffer
    , count :: Int
    , flashMessage :: Blessings Text
    -- , now :: UTCTime
    , termWidth :: Int
    , termHeight :: Int
    , charHeight :: Int
    , charWidth :: Int
    , screenWidth :: Int
    , screenHeight :: Int
    , termHeightPixels :: Int
    , termWidthPixels :: Int
    , termBorder :: Int
    , manager :: Manager -- TODO not part of the state

    --Request -> Manager -> IO (Response ByteString)Source

    , workspaceViewportHeight :: Int
    , workspaceViewportOffset :: Int

    , foundWorkspaces :: [Text]
    --, workspaces :: [Text]
    --, workspaces :: Map Text [XMonad.Web.Types.Window]
    , workspaces :: Map Text Workspace
    , workspaceCursor :: Int
    --
    --, xmonadState :: XMonad.Web.Types.State (XMonad.Web.Types.DummyLayout Text)
    , ex_offsetY :: Int -- TODO Word
    }


instance Default State where
  def = State
      { buffer = Buffer.emptyBuffer
      , count = 1
      , flashMessage = "Welcome to pager; quit with ^C"
      -- , now = UTCTime (fromGregorian 1984 5 23) 49062
      , termWidth = 0
      , termHeight = 0
      , screenHeight = 768 -- TODO
      , screenWidth = 1366 -- TODO
      , charWidth = 0
      , charHeight = 0
      , termWidthPixels = 0
      , termHeightPixels = 0
      , termBorder = 0
      --
      , workspaceViewportHeight = 0
      , workspaceViewportOffset = 0
      , foundWorkspaces = []
      , workspaces = Map.empty
      , workspaceCursor = 0
      --
      --, xmonadState = def
      , ex_offsetY = 0
      }