Stylish + 80 col

This commit is contained in:
Elliot Glaysher 2019-09-13 11:02:41 -07:00
parent 13f6d97545
commit 189f03e285
2 changed files with 24 additions and 19 deletions

View File

@ -162,20 +162,23 @@ clay pierPath king enqueueEv =
atomically $ modifyTVar (cdMountPoints cd) (M.delete desk) atomically $ modifyTVar (cdMountPoints cd) (M.delete desk)
-- Change the structures off of the event into something we can work with in Unix. -- Change the structures off of the event into something we can work with
calculateActionHash :: FilePath -> (Path, Maybe Mime) -> (FilePath, Maybe (Mime, Int)) -- in Unix.
calculateActionHash :: FilePath -> (Path, Maybe Mime)
-> (FilePath, Maybe (Mime, Int))
calculateActionHash base (p, Nothing) = (base </> pathToFilePath p, Nothing) calculateActionHash base (p, Nothing) = (base </> pathToFilePath p, Nothing)
calculateActionHash base (p, Just (Mime t f)) = calculateActionHash base (p, Just (Mime t f)) =
(base </> pathToFilePath p, Just ((Mime t f), (hash $ unOcts $ unFile f))) (base </> pathToFilePath p, Just ((Mime t f), (hash $ unOcts $ unFile f)))
-- Performs the actions on the actual filesystem -- Performs the actions on the actual filesystem
performAction :: (Map FilePath Int) -> (FilePath, Maybe (Mime, Int)) -> RIO e () performAction :: (Map FilePath Int) -> (FilePath, Maybe (Mime, Int))
-> RIO e ()
performAction m (fp, Nothing) = do performAction m (fp, Nothing) = do
logDebug $ displayShow ("(clay) deleting file ", fp) logDebug $ displayShow ("(clay) deleting file ", fp)
removeFile fp removeFile fp
performAction m (fp, Just ((Mime _ (File (Octs bs)), hash))) performAction m (fp, Just ((Mime _ (File (Octs bs)), hash)))
| skip = | skip = logDebug $
logDebug $ displayShow ("(clay) skipping unchanged file update " , fp) displayShow ("(clay) skipping unchanged file update " , fp)
| otherwise = do | otherwise = do
logDebug $ displayShow ("(clay) updating file " , fp) logDebug $ displayShow ("(clay) updating file " , fp)
createDirectoryIfMissing True $ takeDirectory fp createDirectoryIfMissing True $ takeDirectory fp
@ -203,7 +206,8 @@ clay pierPath king enqueueEv =
applySyncAction m (fp, (Just (_, h))) = M.insert fp h m applySyncAction m (fp, (Just (_, h))) = M.insert fp h m
-- Changes an action list item into a form injectable into Urbit -- Changes an action list item into a form injectable into Urbit
actionsToInto :: FilePath -> (FilePath, Maybe (Mime, Int)) -> (Path, Maybe Mime) actionsToInto :: FilePath -> (FilePath, Maybe (Mime, Int))
-> (Path, Maybe Mime)
actionsToInto prefix (fp, mybData) = (p, mybOutData) actionsToInto prefix (fp, mybData) = (p, mybOutData)
where where
p = filePathToPath strippedFp p = filePathToPath strippedFp

View File

@ -1,7 +1,7 @@
module Vere.Term (initializeLocalTerminal, term, TerminalSystem(..)) where module Vere.Term (initializeLocalTerminal, term, TerminalSystem(..)) where
import Arvo hiding (Term)
import UrbitPrelude import UrbitPrelude
import Arvo hiding (Term)
import Vere.Pier.Types import Vere.Pier.Types
import Data.Char import Data.Char
@ -11,9 +11,9 @@ import Foreign.Storable
import System.Posix.IO import System.Posix.IO
import System.Posix.Terminal import System.Posix.Terminal
import System.Console.Terminfo.Base import RIO.Directory (createDirectoryIfMissing)
import RIO.Directory (createDirectoryIfMissing)
import RIO.FilePath import RIO.FilePath
import System.Console.Terminfo.Base
import Data.ByteString.Internal import Data.ByteString.Internal
@ -29,8 +29,8 @@ data LineState = LineState String Int
-- A record used in reading data from stdInput. -- A record used in reading data from stdInput.
data ReadData = ReadData data ReadData = ReadData
{ rdBuf :: Ptr Word8 { rdBuf :: Ptr Word8
, rdEscape :: Bool , rdEscape :: Bool
, rdBracket :: Bool , rdBracket :: Bool
} }
@ -41,15 +41,15 @@ data ReadData = ReadData
-- the session is over, and has a general in/out queue in the types of the -- the session is over, and has a general in/out queue in the types of the
-- vere/arvo interface. -- vere/arvo interface.
data TerminalSystem e = TerminalSystem data TerminalSystem e = TerminalSystem
{ tsReadQueue :: TQueue Belt { tsReadQueue :: TQueue Belt
, tsWriteQueue :: TQueue VereOutput , tsWriteQueue :: TQueue VereOutput
, tsStderr :: Text -> RIO e () , tsStderr :: Text -> RIO e ()
} }
-- Private data to the TerminalSystem that we keep around for stop(). -- Private data to the TerminalSystem that we keep around for stop().
data Private = Private data Private = Private
{ pReaderThread :: Async () { pReaderThread :: Async ()
, pWriterThread :: Async () , pWriterThread :: Async ()
, pPreviousConfiguration :: TerminalAttributes , pPreviousConfiguration :: TerminalAttributes
} }
@ -67,7 +67,7 @@ initialHail = EvBlip $ BlipEvTerm $ TermEvHail (UD 1, ()) ()
runMaybeTermOutput :: Terminal -> (Terminal -> Maybe TermOutput) -> RIO e () runMaybeTermOutput :: Terminal -> (Terminal -> Maybe TermOutput) -> RIO e ()
runMaybeTermOutput t getter = case (getter t) of runMaybeTermOutput t getter = case (getter t) of
Nothing -> pure () Nothing -> pure ()
Just x -> io $ runTermOutput t x Just x -> io $ runTermOutput t x
rioAllocaBytes :: (MonadIO m, MonadUnliftIO m) rioAllocaBytes :: (MonadIO m, MonadUnliftIO m)
=> Int -> (Ptr a -> m b) -> m b => Int -> (Ptr a -> m b) -> m b
@ -113,7 +113,8 @@ initializeLocalTerminal = do
io $ setTerminalAttributes stdInput newTermSettings Immediately io $ setTerminalAttributes stdInput newTermSettings Immediately
tsReadQueue <- newTQueueIO tsReadQueue <- newTQueueIO
pReaderThread <- asyncBound (readTerminal tsReadQueue tsWriteQueue (bell tsWriteQueue)) pReaderThread <- asyncBound
(readTerminal tsReadQueue tsWriteQueue (bell tsWriteQueue))
let tsStderr = \txt -> let tsStderr = \txt ->
atomically $ writeTQueue tsWriteQueue $ VerePrintOutput $ unpack txt atomically $ writeTQueue tsWriteQueue $ VerePrintOutput $ unpack txt
@ -367,7 +368,7 @@ term TerminalSystem{..} shutdownSTM pierPath king enqueueEv =
handleFsWrite :: Blit -> RIO e () handleFsWrite :: Blit -> RIO e ()
handleFsWrite (Sag path noun) = performPut path (jamBS noun) handleFsWrite (Sag path noun) = performPut path (jamBS noun)
handleFsWrite (Sav path atom) = pure () --performPut path atom handleFsWrite (Sav path atom) = pure () --performPut path atom
handleFsWrite _ = pure () handleFsWrite _ = pure ()
performPut :: Path -> ByteString -> RIO e () performPut :: Path -> ByteString -> RIO e ()
performPut path bs = do performPut path bs = do