From: Mart Lubbers Date: Fri, 21 Sep 2018 07:03:17 +0000 (+0200) Subject: Merge branch 'master' of git.martlubbers.net:clean-tests X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=8b58864aa5e0ace806f15156d51cdbc256e4f9f5;hp=1eb7ba9a34eacb68c762bd9f7f81865cf37ecb0b;p=clean-tests.git Merge branch 'master' of git.martlubbers.net:clean-tests --- diff --git a/filepicker/prj b/filepicker/prj new file mode 100644 index 0000000..ff38448 --- /dev/null +++ b/filepicker/prj @@ -0,0 +1,3 @@ +[?25l[?25h[?1049h[?1h=[?25l"Clean System Files" is a directory~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ [?25h[?25l-- VISUAL --[?25h[?25l[?25h[?25l[?25h[?25l[?25h[?25l[?25h[?25l[?25h[?25l[?25h[?25lType :qa! and press to abandon all changes and exit Vim[?25h[?25l[?25h[?25l[?25h[?25l[?25h[?1l>[?1049lVim: Error reading input, exiting... +Vim: Finished. +[?25h6 files to edit diff --git a/filepicker/test.icl b/filepicker/test.icl index f308b33..a306d2c 100644 --- a/filepicker/test.icl +++ b/filepicker/test.icl @@ -1,83 +1,8 @@ module test -from StdFunc import seq, seqList, :: St -import StdFunctions -import System.Directory -import System.File -import System.FilePath -import Data.Tuple -import Data.Func -import Data.Bifunctor -import iTasks -import iTasks.Internal.Util +import iTasks.Extensions.Files -derive class iTask RTree, FileInfo, Tm - -Start w = startEngine - (viewSharedInformation () [] - $ mapRead (map fst) - $ sdsFocus "/opt/clean/lib/StdLib" directoryShare - ) w - -instance toString OSError where toString (_, e) = e -instance Bifunctor MaybeError -where - bifmap fa fb (Error a) = Error (fa a) - bifmap fa fb (Ok b) = Ok (fb b) - first fa fab = bifmap fa id fab - second fb fab = bifmap id fb fab - -selectFile :: FilePath -> Task FilePath -selectFile root = get (sdsFocus root directoryShare) - >>= \cs->withShared (RNode root (map fst cs)) \tree-> - editSelectionWithShared () False selectOption (mapRead numberTree tree) - (\tree->[i\\(i, (f, _))<-leafs tree]) - -selectFile :: !FilePath !d !Bool [FilePath]-> Task [FilePath] | toPrompt d -selectFile root prompt multi initial - = accWorld (createDirectoryTree root) @ numberTree - >>= \tree->editSelection prompt multi selectOption tree - [i\\(i, (f, _))<-leafs tree | elem f initial] -where - selectOption = SelectInTree - (\tree->[{foldTree fp2cn tree & label=root}]) - (\tree sel->[f\\(i, (f, _))<-leafs tree | isMember i sel]) - - fp2cn (i, (fp, mfi)) cs = - { id = case mfi of - Error e = ~i - Ok {directory=True} = ~i - _ = i - , label=dropDirectory fp - , icon=Nothing - , expanded=False - , children=cs - } - - numberTree :: ((RTree a) -> RTree (Int, a)) - numberTree = flip evalState zero o foldTree \a cs-> - (\lvs i->RNode (i, a) lvs) <$> 'CM'.sequence cs <*> getState <* modify inc - - - - - - = - -directoryShare :: ROShared FilePath [(FilePath, MaybeOSError FileInfo)] -directoryShare = SDSSource {SDSSource | name = "directoryShare", read = read, write=write} -where - read p iw - # (merr, iw) = liftIWorld (readDirectory p) iw - | isError merr = (liftError (first exception merr), iw) - # (Ok files) = merr - # (fis, iw) = liftIWorld (seqList (map getFileInfo files)) iw - = (Ok $ sortBy fst [(f, fi)\\f<-files & fi<-fis], iw) - - write p w iw = (Ok (const (const False)), iw) -//import iTasks -//import iTasks.Extensions.Files -// -//Start w = startEngine ( -// selectFile "/opt/clean/lib" () False [] -// >&> viewSharedInformation "Selection" []) w +Start w = startEngine ( + selectFileTreeLazy "select a file" False "/opt/clean" + -&&- selectFileTree False "select a file" False "/opt/clean"[] + >&> viewSharedInformation "selection" []) w diff --git a/filepickerbas/test.icl b/filepickerbas/test.icl new file mode 100644 index 0000000..c77ef2a --- /dev/null +++ b/filepickerbas/test.icl @@ -0,0 +1,6 @@ +module test + +import iTasks +import iTasks.Extensions.FileDialog + +Start w = startEngine (editFilePath "bork" (Action "Ok") (Just "/opt/clean")) w diff --git a/runtasks/test.dcl b/runtasks/test.dcl new file mode 100644 index 0000000..a102fe3 --- /dev/null +++ b/runtasks/test.dcl @@ -0,0 +1,6 @@ +definition module test + +class c c +where + m1 :: c + m2 :: c diff --git a/runtasks/test.icl b/runtasks/test.icl new file mode 100644 index 0000000..e84c95e --- /dev/null +++ b/runtasks/test.icl @@ -0,0 +1,7 @@ +implementation module test + +class c c +where + m1 :: c + +Start = 42 diff --git a/shared_selection/test.icl b/shared_selection/test.icl new file mode 100644 index 0000000..4ac4faa --- /dev/null +++ b/shared_selection/test.icl @@ -0,0 +1,17 @@ +module test + +import Data.Func, StdFunctions, iTasks + +derive gDefault ChoiceNode + +Start w = flip startEngine w $ + withShared 5 \sharedInt-> + withShared [] \sharedSel-> + editSharedSelectionWithShared "test" False + (SelectInTree + (\l->[{defaultValue & id=i,label=toString i}\\i<-[0..l]]) + (\_ s->s) + ) sharedInt sharedSel + -|| updateSharedInformation "Number of items" [] sharedInt + -|| updateSharedInformation "Current selection" [] sharedSel + >&> viewSharedInformation "Current task value" [] o mapRead toSingleLineText