started with layout
[mTask.git] / miTask.icl
index e81f47d..151074e 100644 (file)
@@ -10,6 +10,7 @@ from Text import class Text(startsWith,concat,split,join), instance Text String
 
 from Data.Func import $
 import Data.Tuple
+import Data.List
 import System.Directory
 
 import iTasks.UI.Definition
@@ -78,12 +79,22 @@ withDevice t = withShared ([], [], False) \ch->
                                prefixes = ["ttyS", "ttyACM", "ttyUSB", "tty.usbserial"]
 
 mTaskManager :: Task ()
-mTaskManager = viewSharedInformation "Devices" [] deviceStore
-       ||- forever (addDevice >>= \d->upd (\l->[d:l]) deviceStore) @! ()
+mTaskManager = viewSharedInformation "Devices" [] deviceStore 
+       ||- forever (addDevice >>= \d->upd (\l->[d:l]) deviceStore)
+       ||- whileUnchanged deviceStore (\l->showTabbed l <<@ ArrangeWithTabs) <<@ ArrangeHorizontal
        where
                deviceStore :: Shared [MTaskDevice]
                deviceStore = sdsFocus "mTaskDevices" $ memoryStore "" (Just [])
 
+               showTabbed :: [MTaskDevice] -> Task ()
+               showTabbed [] = viewInformation "" [] "No devices yet" @! ()
+               showTabbed [l:ls] = foldr (\e es->viewInformation "Dev" [] e ||- es) (viewInformation "Dev" [] l @! ()) ls
+
+               mapPar :: (a -> Task a) [a] -> Task ()
+               mapPar f l = foldr1 (\x y->f x ||- y) l <<@ ArrangeWithTabs @! ()
+               allAtOnce t = foldr1 (||-) t @! ()
+               //allAtOnce = (flip (@!) ()) o foldr1 (||-)
+
 addDevice :: Task MTaskDevice
 addDevice = enterInformation "Enter device type" []
        >>= \ty->case ty of