from Data.Func import $
import Data.Tuple
+import Data.List
import System.Directory
import iTasks.UI.Definition
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