module FilePickF(oldFilePickF,smallPickListF) where
import List2(sort)
import MoreF(pickListF)
import ListRequest(replaceAll)
import CompOps
import FilePaths
import IoF(ioF)
import HaskellIO(hIOerr)
import Fudget
import NullF(startupF,getK,putK)
import ReadFileF(readDirF)
import LayoutDir(Orientation(..))
import LayoutOps
import Loops(loopLeftF)
import SerCompF(bypassF)
import InputMsg(stripInputMsg)
import InputSP(inputLeaveDoneSP)
import InputF(inputThroughF)
import DStringF(stringF)
import EitherUtils(stripEither)
import DialogueIO hiding (IOError)
dirF :: F FilePath AFilePath
dirF = FilePath -> AFilePath
aFilePath forall a b e. (a -> b) -> F e a -> F e b
>^=< forall a. F a a -> F a a
bypassF (forall {b}. SP (InputMsg b) b
inputLeaveDoneSP forall a b e. SP a b -> F e a -> F e b
>^^=< F FilePath (InputMsg FilePath)
stringF)
shownameF :: F FilePath (InputMsg FilePath)
shownameF = forall a. InF a a -> InF a a
inputThroughF F FilePath (InputMsg FilePath)
stringF
startpath :: FilePath
startpath = FilePath
"."
lsF :: F AFilePath [AFilePath]
lsF = forall {a}. (FilePath, Either a [FilePath]) -> [AFilePath]
pathsforall a b e. (a -> b) -> F e a -> F e b
>^=<F FilePath (FilePath, Either IOError [FilePath])
readDirFforall c d e. F c d -> (e -> c) -> F e d
>=^<AFilePath -> FilePath
filePath
where
paths :: (FilePath, Either a [FilePath]) -> [AFilePath]
paths (FilePath
dir,Either a [FilePath]
resp) =
case Either a [FilePath]
resp of
Right [FilePath]
files -> (forall a b. (a -> b) -> [a] -> [b]
map (AFilePath -> FilePath -> AFilePath
extendPath AFilePath
sdir) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Ord a => [a] -> [a]
sort forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. Eq a => a -> a -> Bool
/=FilePath
".")) [FilePath]
files
Left a
err -> [FilePath -> AFilePath
aFilePath FilePath
"Error", AFilePath
sdir]
where sdir :: AFilePath
sdir = FilePath -> AFilePath
aFilePath FilePath
dir
smallPickListF :: (d -> FilePath) -> F [d] d
smallPickListF d -> FilePath
f = (forall a b. (a, b) -> b
sndforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall {a}. InputMsg a -> a
stripInputMsgforall a b e. (a -> b) -> F e a -> F e b
>^=<forall {a}.
(a -> FilePath) -> F (PickListRequest a) (InputMsg (Int, a))
pickListF d -> FilePath
fforall c d e. F c d -> (e -> c) -> F e d
>=^<forall {a}. [a] -> ListRequest a
replaceAll)
oldFilePickF :: F FilePath (InputMsg FilePath)
oldFilePickF =
let showdirF :: F AFilePath AFilePath
showdirF =
forall {hi} {ho}. [hi] -> F hi ho -> F hi ho
startupF [FilePath -> AFilePath
aFilePath FilePath
startpath]
((AFilePath -> AFilePath
compactPath forall a b e. (a -> b) -> F e a -> F e b
>^=< F [AFilePath] AFilePath
filePickListF) forall {a1} {b} {a2}. F a1 b -> F a2 a1 -> F a2 b
>==< F AFilePath [AFilePath]
lsF)
filePickListF :: F [AFilePath] AFilePath
filePickListF = forall {d}. (d -> FilePath) -> F [d] d
smallPickListF AFilePath -> FilePath
pathTail
routeK :: K AFilePath (Either FilePath FilePath)
routeK =
forall {hi} {ho}. Cont (K hi ho) (KEvent hi)
getK forall a b. (a -> b) -> a -> b
$ \ KEvent AFilePath
msg ->
case KEvent AFilePath
msg of
High AFilePath
p ->
let s :: FilePath
s = AFilePath -> FilePath
filePath AFilePath
p
cont :: (FilePath -> Either FilePath FilePath)
-> K AFilePath (Either FilePath FilePath)
cont FilePath -> Either FilePath FilePath
r = forall {ho} {hi}. KCommand ho -> K hi ho -> K hi ho
putK (forall a b. b -> Message a b
High (FilePath -> Either FilePath FilePath
r FilePath
s)) K AFilePath (Either FilePath FilePath)
routeK
fileCont :: K AFilePath (Either FilePath FilePath)
fileCont = (FilePath -> Either FilePath FilePath)
-> K AFilePath (Either FilePath FilePath)
cont forall a b. b -> Either a b
Right
dirCont :: K AFilePath (Either FilePath FilePath)
dirCont = (FilePath -> Either FilePath FilePath)
-> K AFilePath (Either FilePath FilePath)
cont forall a b. a -> Either a b
Left
checkCont :: Response -> K AFilePath (Either FilePath FilePath)
checkCont (Str (Char
'd':FilePath
_)) = K AFilePath (Either FilePath FilePath)
dirCont
checkCont Response
_ = K AFilePath (Either FilePath FilePath)
fileCont
in forall {f :: * -> * -> *} {hi} {ho}.
FudgetIO f =>
Request -> (IOError -> f hi ho) -> (Response -> f hi ho) -> f hi ho
hIOerr (FilePath -> Request
StatusFile FilePath
s) (forall a b. a -> b -> a
const K AFilePath (Either FilePath FilePath)
fileCont) Response -> K AFilePath (Either FilePath FilePath)
checkCont
F d f
f1 >=#=< :: F d f -> F e d -> F e f
>=#=< F e d
f2 = (F d f
f1,Orientation
Below) forall {d} {f} {e}. (F d f, Orientation) -> F e d -> F e f
>#==< F e d
f2
in F FilePath (InputMsg FilePath)
shownameF forall {a1} {b} {a2}. F a1 b -> F a2 a1 -> F a2 b
>=#=<
forall a b c. F (Either a b) (Either a c) -> F b c
loopLeftF (((forall {a} {b}. K a b -> F a b
ioF K AFilePath (Either FilePath FilePath)
routeK forall {a1} {b} {a2}. F a1 b -> F a2 a1 -> F a2 b
>==< F AFilePath AFilePath
showdirF) forall {a1} {b} {a2}. F a1 b -> F a2 a1 -> F a2 b
>=#=< F FilePath AFilePath
dirF) forall c d e. F c d -> (e -> c) -> F e d
>=^< forall {a}. Either a a -> a
stripEither)