module FilePickPopupF(filePickF,filePickF',filePickPopupF,filePickPopupF',filePickPopupOptF,filePickPopupOptF',startDir,aFilePath,popup) where
import AllFudgets
import EndButtonsF
--import Files
import Data.List(sort,partition)
import HbcUtils(uncurry3)
import DialogueIO hiding (IOError)
import CompletionStringF
import UnsafePerformIO(unsafePerformIO)
import System.Directory(getCurrentDirectory)

popup :: (String, Maybe a)
popup = (String
"OK",forall a. Maybe a
Nothing)

filePickPopupF :: F (a, (String, Maybe String)) ((a, (String, Maybe String)), String)
filePickPopupF = forall {t3} {a}.
Graphic t3 =>
[(AFilePath -> AFilePath, String, t3)]
-> F (a, (String, Maybe String))
     ((a, (String, Maybe String)), String)
filePickPopupF' [(AFilePath -> AFilePath, String, String)]
noextrabuttons
filePickPopupOptF :: F (a, (String, Maybe String))
  ((a, (String, Maybe String)), Maybe String)
filePickPopupOptF = forall {t3} {a}.
Graphic t3 =>
[(AFilePath -> AFilePath, String, t3)]
-> F (a, (String, Maybe String))
     ((a, (String, Maybe String)), Maybe String)
filePickPopupOptF' [(AFilePath -> AFilePath, String, String)]
noextrabuttons
filePickF :: F (String, Maybe String) (Maybe String)
filePickF = forall {t3}.
Graphic t3 =>
[(AFilePath -> AFilePath, String, t3)]
-> F (String, Maybe String) (Maybe String)
filePickF' [(AFilePath -> AFilePath, String, String)]
noextrabuttons

noextrabuttons :: [(AFilePath -> AFilePath, String, String)]
noextrabuttons = [] :: ([(AFilePath->AFilePath,KeySym,String)])

filePickPopupF' :: [(AFilePath -> AFilePath, String, t3)]
-> F (a, (String, Maybe String))
     ((a, (String, Maybe String)), String)
filePickPopupF' [(AFilePath -> AFilePath, String, t3)]
btns = forall {t} {b}. (t -> Maybe b) -> SP t b
mapFilterSP forall {a} {b}. (a, Maybe b) -> Maybe (a, b)
ok forall a b e. SP a b -> F e a -> F e b
>^^=< forall {t3} {a}.
Graphic t3 =>
[(AFilePath -> AFilePath, String, t3)]
-> F (a, (String, Maybe String))
     ((a, (String, Maybe String)), Maybe String)
filePickPopupOptF' [(AFilePath -> AFilePath, String, t3)]
btns
  where
    ok :: (a, Maybe b) -> Maybe (a, b)
ok (a
x,Maybe b
Nothing) = forall a. Maybe a
Nothing
    ok (a
x,Just b
y) = forall a. a -> Maybe a
Just (a
x,b
y)


filePickPopupOptF' :: [(AFilePath -> AFilePath, String, t3)]
-> F (a, (String, Maybe String))
     ((a, (String, Maybe String)), Maybe String)
filePickPopupOptF' [(AFilePath -> AFilePath, String, t3)]
btns =
  --delayF $ -- commented out to avoid a layout problem under XQuartz
  forall {a} {b}. String -> Maybe Point -> F a b -> F a (a, b)
popupShellF String
"File Selection" forall a. Maybe a
Nothing (forall {t3}.
Graphic t3 =>
[(AFilePath -> AFilePath, String, t3)]
-> F (String, Maybe String) (Maybe String)
filePickF' [(AFilePath -> AFilePath, String, t3)]
btns forall c d e. F c d -> (e -> c) -> F e d
>=^< forall a b. (a, b) -> b
snd)


filePickF' :: [(AFilePath -> AFilePath, String, t3)]
-> F (String, Maybe String) (Maybe String)
filePickF' [(AFilePath -> AFilePath, String, t3)]
btns =
    forall a b c d. F (Either a b) (Either c d) -> F c a -> F b d
loopThroughRightF (forall {a} {b} {a} {a} {b} {b} {b}.
Eq a =>
(AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
ctrlF (String -> AFilePath
aFilePath String
startDir,String
"")) (forall {t3} {a}.
Graphic t3 =>
[(AFilePath -> AFilePath, String, t3)]
-> F (Either
        (Either (Either [(String, String)] AFilePath) Click)
        (Either (Either (String -> [(a, String)]) String) String))
     (Either
        (Either
           (Either (InputMsg AFilePath) [(String, AFilePath)])
           (AFilePath -> AFilePath))
        (Either
           (Either [(a, String)] (InputMsg String)) (Either Click Click)))
partsF [(AFilePath -> AFilePath, String, t3)]
btns)
  where
    ctrlF :: (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
ctrlF st :: (AFilePath, String)
st@(AFilePath
dir,String
file) = forall {a} {ho}. Cont (F a ho) a
getF forall a b. (a -> b) -> a -> b
$ forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall {b} {a} {b}.
Either
  (Either
     (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
  (Either (Either a (InputMsg String)) (Either a b))
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
internal (b, Maybe String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
external
      where
        same :: F (Either
     (Either
        (Either
           (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
        (Either (Either a (InputMsg String)) (Either a b)))
     (b, Maybe String))
  (Either
     (Either
        (Either (Either a AFilePath) b)
        (Either (Either ([a] -> [([a], [a])]) String) b))
     (Maybe String))
same = (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
ctrlF (AFilePath, String)
st

        internal :: Either
  (Either
     (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
  (Either (Either a (InputMsg String)) (Either a b))
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
internal = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall {b}.
Either (InputMsg AFilePath) [([a], b)]
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
dirDisp (AFilePath -> AFilePath)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
goto) (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either Either a (InputMsg String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
fileInput forall {a} {b}.
Either a b
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
done)

	external :: (b, Maybe String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
external (b
lbl,Maybe String
optpath) = forall {ho} {hi}. ho -> F hi ho -> F hi ho
putF (forall {a} {a} {a} {b}. a -> Either (Either a (Either a a)) b
toButtons b
lbl) (Maybe String
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
external2 Maybe String
optpath)
          where
	    external2 :: Maybe String
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
external2 Maybe String
Nothing = forall {ho} {hi}. ho -> F hi ho -> F hi ho
putF (forall {a} {a} {b} {b} {b}.
a -> Either (Either (Either (Either a a) b) b) b
toDirDispDir AFilePath
dir) F (Either
     (Either
        (Either
           (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
        (Either (Either a (InputMsg String)) (Either a b)))
     (b, Maybe String))
  (Either
     (Either
        (Either (Either a AFilePath) b)
        (Either (Either ([a] -> [([a], [a])]) String) b))
     (Maybe String))
same
	    external2 (Just String
s) = AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
newpath (String -> AFilePath
aFilePath String
s)

        dirDisp :: Either (InputMsg AFilePath) [([a], b)]
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
dirDisp = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either InputMsg AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
pick forall {b}.
[([a], b)]
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
dirList
        dirList :: [([a], b)]
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
dirList [([a], b)]
list = forall {ho} {hi}. ho -> F hi ho -> F hi ho
putF (forall {a} {a} {b} {b} {b}.
a -> Either (Either a (Either (Either a b) b)) b
toFileCompletion (forall {a}. Eq a => [[a]] -> [a] -> [([a], [a])]
completeFromList (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [([a], b)]
list))) F (Either
     (Either
        (Either
           (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
        (Either (Either a (InputMsg String)) (Either a b)))
     (b, Maybe String))
  (Either
     (Either
        (Either (Either a AFilePath) b)
        (Either (Either ([a] -> [([a], [a])]) String) b))
     (Maybe String))
same

        pick :: InputMsg AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
pick InputMsg AFilePath
inp =
	    forall {a} {b}.
AFilePath -> ((AFilePath, String) -> F a b) -> F a b
pathPartsF (AFilePath -> AFilePath
compactPath AFilePath
path) forall a b. (a -> b) -> a -> b
$ \ st' :: (AFilePath, String)
st'@(AFilePath
dir',String
file') ->
	    if String
file'forall a. Eq a => a -> a -> Bool
==String
""
	    then (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
change (AFilePath
dir',String
file) -- keep previous file name
	    else case forall {a}. InputMsg a -> Maybe a
inputDone InputMsg AFilePath
inp of
	           Maybe AFilePath
Nothing -> (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
change (AFilePath, String)
st'
		   Just AFilePath
_ -> if String
file'forall a. Eq a => a -> a -> Bool
==String
file -- Hmm. Check dir too.
		             then AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
output AFilePath
path
			     else F (Either
     (Either
        (Either
           (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
        (Either (Either a (InputMsg String)) (Either a b)))
     (b, Maybe String))
  (Either
     (Either
        (Either (Either a AFilePath) b)
        (Either (Either ([a] -> [([a], [a])]) String) b))
     (Maybe String))
same -- false double click
	  where
	    path :: AFilePath
path = forall {a}. InputMsg a -> a
stripInputMsg InputMsg AFilePath
inp

	goto :: (AFilePath -> AFilePath)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
goto AFilePath -> AFilePath
f = (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
change (AFilePath -> AFilePath
f AFilePath
dir,String
file)

        fileInput :: Either a (InputMsg String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
fileInput = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either a
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
completionList InputMsg String
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
filename

        completionList :: a
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
completionList = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall {ho} {hi}. ho -> F hi ho -> F hi ho
putF F (Either
     (Either
        (Either
           (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
        (Either (Either a (InputMsg String)) (Either a b)))
     (b, Maybe String))
  (Either
     (Either
        (Either (Either a AFilePath) b)
        (Either (Either ([a] -> [([a], [a])]) String) b))
     (Maybe String))
same forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {a} {b} {b} {b} {b}.
a -> Either (Either (Either (Either a b) b) b) b
toDirDispCompletions

	filename :: InputMsg String
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
filename InputMsg String
inp =
	    case forall {a}. InputMsg a -> Maybe a
inputDone InputMsg String
inp of
	      Maybe String
Nothing -> (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
ctrlF (AFilePath
dir,forall {a}. InputMsg a -> a
stripInputMsg InputMsg String
inp)
	      Just String
"" -> F (Either
     (Either
        (Either
           (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
        (Either (Either a (InputMsg String)) (Either a b)))
     (b, Maybe String))
  (Either
     (Either
        (Either (Either a AFilePath) b)
        (Either (Either ([a] -> [([a], [a])]) String) b))
     (Maybe String))
same
	      --Just name@('/':_) -> newname (aFilePath name)
	      --Just name -> newname (extendPath dir name)
	      Just String
path' -> AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
newname (AFilePath -> AFilePath -> AFilePath
joinPaths AFilePath
dir (String -> AFilePath
aFilePath String
path'))
	  where
	     newname :: AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
newname AFilePath
path =
	       forall {a} {b}.
AFilePath -> ((AFilePath, String) -> F a b) -> F a b
pathPartsF (AFilePath -> AFilePath
compactPath AFilePath
path) forall a b. (a -> b) -> a -> b
$ \ st' :: (AFilePath, String)
st'@(AFilePath
dir',String
file') ->
	       if String
file'forall a. Eq a => a -> a -> Bool
==String
""
	       then (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
change (AFilePath, String)
st'
	       else AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
output (AFilePath -> String -> AFilePath
extendPath AFilePath
dir' String
file')

	done :: Either a b
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
done = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall {p}.
p
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
ok forall {p}.
p
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
cancel
	  where
	    ok :: p
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
ok p
_ = forall {ho} {hi}. ho -> F hi ho -> F hi ho
putF (forall {b} {a}. b -> Either a b
out (forall a. a -> Maybe a
Just (AFilePath -> String
filePath (AFilePath -> String -> AFilePath
extendPath AFilePath
dir String
file)))) F (Either
     (Either
        (Either
           (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
        (Either (Either a (InputMsg String)) (Either a b)))
     (b, Maybe String))
  (Either
     (Either
        (Either (Either a AFilePath) b)
        (Either (Either ([a] -> [([a], [a])]) String) b))
     (Maybe String))
same
	    cancel :: p
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
cancel p
_ = forall {ho} {hi}. ho -> F hi ho -> F hi ho
putF (forall {b} {a}. b -> Either a b
out forall a. Maybe a
Nothing) F (Either
     (Either
        (Either
           (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
        (Either (Either a (InputMsg String)) (Either a b)))
     (b, Maybe String))
  (Either
     (Either
        (Either (Either a AFilePath) b)
        (Either (Either ([a] -> [([a], [a])]) String) b))
     (Maybe String))
same

        newpath :: AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
newpath AFilePath
path = forall {a} {b}.
AFilePath -> ((AFilePath, String) -> F a b) -> F a b
pathPartsF (AFilePath -> AFilePath
compactPath AFilePath
path) (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
change

	change :: (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
change st :: (AFilePath, String)
st@(AFilePath
dir',String
file') =
	   forall {b} {a}. [b] -> F a b -> F a b
putsF ([forall {a} {a} {a} {b} {b}.
a -> Either (Either a (Either (Either a a) b)) b
toFileInput String
file']forall a. [a] -> [a] -> [a]
++
	          (if AFilePath
dir'forall a. Eq a => a -> a -> Bool
/=AFilePath
dir then [forall {a} {a} {b} {b} {b}.
a -> Either (Either (Either (Either a a) b) b) b
toDirDispDir AFilePath
dir'] else [])) forall a b. (a -> b) -> a -> b
$
	   (AFilePath, String)
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
ctrlF (AFilePath, String)
st

        output :: AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
output AFilePath
path =
	    forall {ho} {hi}. ho -> F hi ho -> F hi ho
putF (forall {b} {a}. b -> Either a b
out (forall a. a -> Maybe a
Just (AFilePath -> String
filePath AFilePath
path'))) (AFilePath
-> F (Either
        (Either
           (Either
              (Either (InputMsg AFilePath) [([a], b)]) (AFilePath -> AFilePath))
           (Either (Either a (InputMsg String)) (Either a b)))
        (b, Maybe String))
     (Either
        (Either
           (Either (Either a AFilePath) b)
           (Either (Either ([a] -> [([a], [a])]) String) b))
        (Maybe String))
newpath AFilePath
path')
	  where
	    path' :: AFilePath
path' = AFilePath -> AFilePath
compactPath AFilePath
path

        out :: b -> Either a b
out = forall a b. b -> Either a b
Right
	toDirDisp :: a -> Either (Either (Either a b) b) b
toDirDisp = forall a b. a -> Either a b
Leftforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Leftforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Left
	toDirDispDir :: a -> Either (Either (Either (Either a a) b) b) b
toDirDispDir = forall {a} {b} {b} {b}. a -> Either (Either (Either a b) b) b
toDirDispforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. b -> Either a b
Right
	toDirDispCompletions :: a -> Either (Either (Either (Either a b) b) b) b
toDirDispCompletions = forall {a} {b} {b} {b}. a -> Either (Either (Either a b) b) b
toDirDispforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Left
	toFileInput :: a -> Either (Either a (Either (Either a a) b)) b
toFileInput= forall a b. a -> Either a b
Leftforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. b -> Either a b
Rightforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Leftforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. b -> Either a b
Right
	toFileCompletion :: a -> Either (Either a (Either (Either a b) b)) b
toFileCompletion=forall a b. a -> Either a b
Leftforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. b -> Either a b
Rightforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Leftforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Left
	toButtons :: a -> Either (Either a (Either a a)) b
toButtons=forall a b. a -> Either a b
Leftforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. b -> Either a b
Rightforall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. b -> Either a b
Right

partsF :: [(AFilePath -> AFilePath, String, t3)]
-> F (Either
        (Either (Either [(String, String)] AFilePath) Click)
        (Either (Either (String -> [(a, String)]) String) String))
     (Either
        (Either
           (Either (InputMsg AFilePath) [(String, AFilePath)])
           (AFilePath -> AFilePath))
        (Either
           (Either [(a, String)] (InputMsg String)) (Either Click Click)))
partsF [(AFilePath -> AFilePath, String, t3)]
btns =
  forall {a} {b}. F a b -> F a b
vBoxF ((F (Either [(String, String)] AFilePath)
  (Either (InputMsg AFilePath) [(String, AFilePath)])
dirDispFforall {a} {b} {c} {d}.
F a b -> F c d -> F (Either a c) (Either b d)
>+<forall {t3}.
Graphic t3 =>
[(AFilePath -> AFilePath, String, t3)]
-> F Click (AFilePath -> AFilePath)
gotoButtonsF [(AFilePath -> AFilePath, String, t3)]
btns)forall {a} {b} {c} {d}.
F a b -> F c d -> F (Either a c) (Either b d)
>+<(forall {a}.
F (Either (String -> [(a, String)]) String)
  (Either [(a, String)] (InputMsg String))
fileInputFforall {a} {b} {c} {d}.
F a b -> F c d -> F (Either a c) (Either b d)
>+<F String (Either Click Click)
endButtonsF'))

dirDispF :: F (Either [(String, String)] AFilePath)
  (Either (InputMsg AFilePath) [(String, AFilePath)])
dirDispF =
    forall {a}. Either a a -> a
stripEither forall a b e. (a -> b) -> F e a -> F e b
>^=< forall {a} {b}. F a b -> F a b
vBoxF (forall {b}. F String b
pathDispF forall {a} {b} {c} {d}.
F a b -> F c d -> F (Either a c) (Either b d)
>+< F (Either [(String, String)] String)
  (Either (InputMsg AFilePath) [(String, AFilePath)])
dirListF) forall c d e. F c d -> SP e c -> F e d
>=^^< forall {t} {b}. (t -> [b]) -> SP t b
concatMapSP forall {a}. Either a AFilePath -> [Either String (Either a String)]
pre
  where
    pre :: Either a AFilePath -> [Either String (Either a String)]
pre (Left a
completions) = [forall a b. b -> Either a b
Right (forall a b. a -> Either a b
Left a
completions)]
    pre (Right AFilePath
path) = [forall a b. a -> Either a b
Left String
newdir,forall a b. b -> Either a b
Right (forall a b. b -> Either a b
Right String
newdir)]
      where newdir :: String
newdir = AFilePath -> String
filePath AFilePath
path

    pathDispF :: F String b
pathDispF = forall {a} {b}. Graphic a => Customiser (DisplayF a) -> F a b
displayF' DisplayF String -> DisplayF String
pm
      where pm :: DisplayF String -> DisplayF String
pm = forall xxx. HasAlign xxx => Alignment -> Customiser xxx
setAlign Alignment
aCenterforall b c a. (b -> c) -> (a -> b) -> a -> c
.
                 forall {xxx} {p}.
(HasBgColorSpec xxx, Show p, ColorGen p) =>
p -> Customiser xxx
setBgColor String
bgColorforall b c a. (b -> c) -> (a -> b) -> a -> c
.
		 forall xxx. HasBorderWidth xxx => Int -> Customiser xxx
setBorderWidth Int
0forall b c a. (b -> c) -> (a -> b) -> a -> c
.
		 forall {xxx} {a}.
(HasFontSpec xxx, Show a, FontGen a) =>
a -> Customiser xxx
setFont String
labelFont

    dirListF :: F (Either [(String, String)] String)
  (Either (InputMsg AFilePath) [(String, AFilePath)])
dirListF = forall a b c d. F (Either a b) (Either c d) -> F c a -> F b d
loopThroughRightF (forall {t} {a} {b}. (t -> a -> (t, [b])) -> t -> F a b
mapstateF forall {a} {b} {a} {a} {b}.
Eq a =>
[([a], b)]
-> Either
     (Either (InputMsg (Int, (a, a))) [([a], b)])
     (Either [([a], [a])] b)
-> ([([a], b)],
    [Either
       (Either (ListRequest ([a], b)) b)
       (Either (InputMsg a) [([a], b)])])
ctrl []) (forall {a}.
(a -> String) -> F (PickListRequest a) (InputMsg (Int, a))
pickListF forall a b. (a, b) -> a
fst forall {a} {b} {c} {d}.
F a b -> F c d -> F (Either a c) (Either b d)
>+< F String [(String, AFilePath)]
lsF)
      where
        ctrl :: [([a], b)]
-> Either
     (Either (InputMsg (Int, (a, a))) [([a], b)])
     (Either [([a], [a])] b)
-> ([([a], b)],
    [Either
       (Either (ListRequest ([a], b)) b)
       (Either (InputMsg a) [([a], b)])])
ctrl [([a], b)]
list = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall {a} {a} {a} {b} {b}.
InputMsg (Int, (a, a))
-> ([([a], b)],
    [Either (Either (ListRequest a) b) (Either (InputMsg a) b)])
fromPickListF forall {a} {b} {a}.
[a] -> ([a], [Either (Either (ListRequest a) b) (Either a [a])])
fromLsF) forall {b} {a} {b}.
Either [([a], [a])] b
-> ([([a], b)], [Either (Either (ListRequest a) b) b])
fromInput
	  where
	    fromInput :: Either [([a], [a])] b
-> ([([a], b)], [Either (Either (ListRequest a) b) b])
fromInput = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall {a} {b} {b}.
[([a], [a])] -> ([([a], b)], [Either (Either (ListRequest a) b) b])
completions forall {a} {a} {b}. a -> ([([a], b)], [Either (Either a a) b])
newDir
	    completions :: [([a], [a])] -> ([([a], b)], [Either (Either (ListRequest a) b) b])
completions [([a], [a])]
cs = forall {a}. a -> ([([a], b)], [a])
put (forall {a} {b} {b}. a -> Either (Either a b) b
toPickListF forall {a}. ListRequest a
hilite)
	      where
	        hilite :: ListRequest a
hilite = forall {a}. [Int] -> ListRequest a
highlightItems
	                       [Int
i|(Int
i,([a]
n,b
_))<-forall a b. [a] -> [b] -> [(a, b)]
zip [Int
0..] [([a], b)]
list,[a]
n forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [[a]]
ns]
		ns :: [[a]]
ns = [[a]
preforall a. [a] -> [a] -> [a]
++[a]
compl|([a]
pre,[a]
compl)<-[([a], [a])]
cs]
	    newDir :: a -> ([([a], b)], [Either (Either a a) b])
newDir = forall {a}. a -> ([([a], b)], [a])
put forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {a} {a} {b}. a -> Either (Either a a) b
toLsF
	    fromPickListF :: InputMsg (Int, (a, a))
-> ([([a], b)],
    [Either (Either (ListRequest a) b) (Either (InputMsg a) b)])
fromPickListF InputMsg (Int, (a, a))
msg =
	      forall {a}. a -> a -> ([([a], b)], [a])
put2 (forall {a} {a} {b}. a -> Either a (Either a b)
outPick forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {t} {a}. (t -> a) -> InputMsg t -> InputMsg a
mapInp (forall a b. (a, b) -> b
sndforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall a b. (a, b) -> b
snd) forall a b. (a -> b) -> a -> b
$ InputMsg (Int, (a, a))
msg)
	           (forall {a} {b} {b}. a -> Either (Either a b) b
toPickListFforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall {a}. [Int] -> ListRequest a
highlightItemsforall b c a. (b -> c) -> (a -> b) -> a -> c
.(forall a. a -> [a] -> [a]
:[])forall b c a. (b -> c) -> (a -> b) -> a -> c
.forall a b. (a, b) -> a
fstforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall {a}. InputMsg a -> a
stripInputMsg forall a b. (a -> b) -> a -> b
$ InputMsg (Int, (a, a))
msg)
	    fromLsF :: [a] -> ([a], [Either (Either (ListRequest a) b) (Either a [a])])
fromLsF [a]
list' = ([a]
list',[forall {a} {a} {a}. a -> Either a (Either a a)
outDir [a]
list',forall {a} {b} {b}. a -> Either (Either a b) b
toPickListF (forall {a}. [a] -> ListRequest a
replaceAll [a]
list')])

	    put :: a -> ([([a], b)], [a])
put a
x = ([([a], b)]
list,[a
x])
	    put2 :: a -> a -> ([([a], b)], [a])
put2 a
x a
y = ([([a], b)]
list,[a
x,a
y])

	    out :: b -> Either a b
out = forall a b. b -> Either a b
Right
	    outDir :: a -> Either a (Either a a)
outDir = forall {b} {a}. b -> Either a b
out forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. b -> Either a b
Right
	    outPick :: a -> Either a (Either a b)
outPick = forall {b} {a}. b -> Either a b
out forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Left
	    loop :: a -> Either a b
loop = forall a b. a -> Either a b
Left
	    toPickListF :: a -> Either (Either a b) b
toPickListF = forall a b. a -> Either a b
loop forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Left
	    toLsF :: a -> Either (Either a a) b
toLsF = forall a b. a -> Either a b
loop forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. b -> Either a b
Right

    lsF :: F String [(String, AFilePath)]
lsF = F [AFilePath] [(String, AFilePath)]
showFilesFforall {a1} {b} {a2}. F a1 b -> F a2 a1 -> F a2 b
>==<forall {a}. Show a => (String, Either a [String]) -> [AFilePath]
pathsforall a b e. (a -> b) -> F e a -> F e b
>^=<F String (String, Either IOError [String])
readDirF
      where
	paths :: (String, Either a [String]) -> [AFilePath]
paths (String
dir,Either a [String]
resp) =
	    case Either a [String]
resp of
	      Right [String]
files -> (forall a b. (a -> b) -> [a] -> [b]
map (AFilePath -> String -> AFilePath
extendPath AFilePath
sdir) forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> [String]
sortFiles) [String]
files
	      Left a
err   -> [AFilePath -> String -> AFilePath
extendPath AFilePath
sdir (forall a. Show a => a -> String
show a
err)]
	  where sdir :: AFilePath
sdir = String -> AFilePath
aFilePath String
dir
	        sortFiles :: [String] -> [String]
sortFiles [String]
files =
		  case forall a. (a -> Bool) -> [a] -> ([a], [a])
partition String -> Bool
isDotFile [String]
files of
		    ([String]
dfs,[String]
fs) -> forall a. Ord a => [a] -> [a]
sort [String]
fs forall a. [a] -> [a] -> [a]
++
		                forall a. Ord a => [a] -> [a]
sort [ String
f | String
f<-[String]
dfs, String
f forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String
".",String
".."]]
		isDotFile :: String -> Bool
isDotFile (Char
'.':String
_) = Bool
True
		isDotFile String
_ = Bool
False

	showFilesF :: F [AFilePath] [(String, AFilePath)]
showFilesF = forall {hi} {ho}. (hi -> (ho -> F hi ho) -> F hi ho) -> F hi ho
contMapF forall {a} {b}. [AFilePath] -> Cont (F a b) [(String, AFilePath)]
showFiles
	showFiles :: [AFilePath] -> Cont (F a b) [(String, AFilePath)]
showFiles = forall a c b. (a -> Cont c b) -> [a] -> Cont c [b]
conts forall {a} {b}.
AFilePath -> ((String, AFilePath) -> F a b) -> F a b
showFile
        showFile :: AFilePath -> ((String, AFilePath) -> F a b) -> F a b
showFile = if String -> Bool -> Bool
argFlag String
"slowshowfile" Bool
True
	           then forall {a} {b}.
AFilePath -> ((String, AFilePath) -> F a b) -> F a b
slowShowFile
		   else forall {t}. AFilePath -> ((String, AFilePath) -> t) -> t
fastShowFile

	slowShowFile :: AFilePath -> ((String, AFilePath) -> F a b) -> F a b
slowShowFile AFilePath
path (String, AFilePath) -> F a b
c =
	  forall {a} {b}. String -> F a b -> F a b -> F a b
isDirF (AFilePath -> String
filePath AFilePath
path)
		 ((String, AFilePath) -> F a b
c (String
fileforall a. [a] -> [a] -> [a]
++String
"/",AFilePath
path))
		 ((String, AFilePath) -> F a b
c (String
file,AFilePath
path))
	  where file :: String
file = AFilePath -> String
pathTail AFilePath
path

        fastShowFile :: AFilePath -> ((String, AFilePath) -> t) -> t
fastShowFile AFilePath
path (String, AFilePath) -> t
c = (String, AFilePath) -> t
c (AFilePath -> String
pathTail AFilePath
path,AFilePath
path)

gotoButtonsF :: [(AFilePath -> AFilePath, String, t3)]
-> F Click (AFilePath -> AFilePath)
gotoButtonsF [(AFilePath -> AFilePath, String, t3)]
btns =
   forall a b. Request -> (Response -> F a b) -> F a b
haskellIOF (String -> Request
GetEnv String
"HOME") forall a b. (a -> b) -> a -> b
$ \ Response
homeresp ->
   forall {a} {b}. Bool -> Bool -> F a b -> F a b
noStretchF Bool
False Bool
True forall a b. (a -> b) -> a -> b
$
   forall {a} {b}. Int -> F a b -> F a b
matrixF Int
4 (forall a b. [F a b] -> F a b
untaggedListF ([forall {b}. F Click (b -> AFilePath)
rootF,F Click (AFilePath -> AFilePath)
parentF]forall a. [a] -> [a] -> [a]
++forall {b}. Response -> [F Click (b -> AFilePath)]
homeF Response
homerespforall a. [a] -> [a] -> [a]
++forall {t1}. [(t1, String, t3)] -> [F Click t1]
extra [(AFilePath -> AFilePath, String, t3)]
btns))
  where
    rootF :: F Click (b -> AFilePath)
rootF = forall {lbl} {b}. Graphic lbl => b -> String -> lbl -> F Click b
fButtonF (forall a b. a -> b -> a
const AFilePath
rootPath) String
"r" String
"/ Root"
    parentF :: F Click (AFilePath -> AFilePath)
parentF = forall {lbl} {b}. Graphic lbl => b -> String -> lbl -> F Click b
fButtonF (AFilePath -> AFilePath
compactPathforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall a b c. (a -> b -> c) -> b -> a -> c
flip AFilePath -> String -> AFilePath
extendPath String
"..") String
"p" String
".. Parent"

    homeF :: Response -> [F Click (b -> AFilePath)]
homeF Response
resp=
      case Response
resp of
        Str d :: String
d@(Char
_:String
_) -> [forall {lbl} {b}. Graphic lbl => b -> String -> lbl -> F Click b
fButtonF (forall a b. a -> b -> a
const (String -> AFilePath
aFilePath String
d)) String
"h" String
"Home"]
	Response
_ -> []

    fButtonF :: b -> String -> lbl -> F Click b
fButtonF b
f String
k lbl
lbl = forall a b. a -> b -> a
const b
f forall a b e. (a -> b) -> F e a -> F e b
>^=< forall {lbl}.
Graphic lbl =>
Customiser (ButtonF lbl) -> lbl -> F Click Click
buttonF' (forall xxx. HasKeys xxx => [(ModState, String)] -> Customiser xxx
setKeys [([Modifiers
metaKey],String
k)]) lbl
lbl

    extra :: [(t1, String, t3)] -> [F Click t1]
extra = forall a b. (a -> b) -> [a] -> [b]
map (forall {t1} {t2} {t3} {t4}.
(t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
uncurry3 forall {lbl} {b}. Graphic lbl => b -> String -> lbl -> F Click b
fButtonF)

fileInputF :: F (Either (String -> [(a, String)]) String)
  (Either [(a, String)] (InputMsg String))
fileInputF = String
"File" forall {p} {c} {d}. Graphic p => p -> F c d -> F c d
`labLeftOfF` forall {a}.
F (Either (String -> [(a, String)]) String)
  (Either [(a, String)] (InputMsg String))
completionStringF

pathPartsF :: AFilePath -> ((AFilePath, String) -> F a b) -> F a b
pathPartsF AFilePath
path (AFilePath, String) -> F a b
cont =
    forall {a} {b}. String -> F a b -> F a b -> F a b
isDirF (AFilePath -> String
filePath AFilePath
path) F a b
yes F a b
no
  where
    yes :: F a b
yes = (AFilePath, String) -> F a b
cont (AFilePath
path,String
"")
    no :: F a b
no = (AFilePath, String) -> F a b
cont (AFilePath -> AFilePath
pathHead AFilePath
path,AFilePath -> String
pathTail AFilePath
path)
    {-
    no  = case path of
            [] -> cont ([],[]) -- not likely to happen, since the root is a dir
	    file:dir -> cont (dir,file)
    -}


--- Candidates for inclusion in the Fudget library:

isDirF :: String -> F a b -> F a b -> F a b
isDirF String
file F a b
yes F a b
no =
  forall a b. Request -> (Response -> F a b) -> F a b
haskellIOF (String -> Request
StatusFile String
file) forall a b. (a -> b) -> a -> b
$ \ Response
resp ->
  case Response
resp of
    Str (Char
'd':String
_) -> F a b
yes
    Response
_ -> F a b
no

contMapF :: (hi -> (ho -> F hi ho) -> F hi ho) -> F hi ho
contMapF hi -> (ho -> F hi ho) -> F hi ho
f =
  forall {a} {ho}. Cont (F a ho) a
getF forall a b. (a -> b) -> a -> b
$ \ hi
x ->
  hi -> (ho -> F hi ho) -> F hi ho
f hi
x forall a b. (a -> b) -> a -> b
$ \ ho
y ->
  forall {ho} {hi}. ho -> F hi ho -> F hi ho
putF ho
y forall a b. (a -> b) -> a -> b
$
  (hi -> (ho -> F hi ho) -> F hi ho) -> F hi ho
contMapF hi -> (ho -> F hi ho) -> F hi ho
f

----

-- #ifdef __NHC__
--startDir = argKey "startdir" "/"  -- hmm. should retreive current directory.
-- #else
startDir :: String
startDir = forall a. IO a -> a
unsafePerformIO IO String
getCurrentDirectory
-- #endif

{-
 - reloadknapp?
 - alltid absolut path
 - meddelande för att
     välja kataloger
     spara

 - completion och uppnerpilar
 -

 - pixlar kvar i picklistan
-}