Commit b22be56a authored by Rinus Plasmeijer's avatar Rinus Plasmeijer

polished code a bit

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@3107 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 89b420c8
This diff is collapsed.
This diff is collapsed.
......@@ -32,7 +32,7 @@ start_ide
[ (Embedded, workPane)
, (Embedded, projectPane)
, (Embedded, errorMessages)
] /* <<@ SetLayout layout */ @ const Void
] [] /* <<@ SetLayout layout */ @ const Void
where
//layout = customMergeLayout (sideMerge TopSide 0 (sideMerge LeftSide 250 (sideMerge BottomSide 100 tabbedMerge))) //TROUBLE
......@@ -61,7 +61,8 @@ workPane ts
>>| topMenu ts
topMenu ts
= forever (whileUnchangedWith visibleInMenu IDE_State (\s -> actionTask >>* handleMenu s ))
= return Void
// = forever (whileUnchangedWith visibleInMenu IDE_State (\s -> actionTask >>* handleMenu s ))
where
visibleInMenu :: IDE_State IDE_State -> Bool
visibleInMenu old new
......@@ -70,9 +71,9 @@ where
old.recentFiles <> new.recentFiles ||
old.recentProjects <> new.recentProjects
handleMenu :: IDE_State -> [TaskStep Void Void]
handleMenu state=:{projectName, openedFiles, recentFiles, recentProjects, envTargets}
= []
// handleMenu :: IDE_State -> [TaskStep Void Void]
// handleMenu state=:{projectName, openedFiles, recentFiles, recentProjects, envTargets}
// = []
/*
= [ OnAction (Action "File/Open..." []) (always (launch (openFileSelectorAndEdit ts) ts))
, OnAction (Action "File/Save All" []) (if (openedFiles <> []) always never (saveAll openedFiles))
......
......@@ -5,7 +5,7 @@ implementation module IDE_State
import iTasks
import projectManager, SmallUtil
import projectManager, SmallUtil, StdArray
// The IDE_state is the one and only globally shared state
......@@ -31,7 +31,7 @@ IDE_State = sharedStore IDE_State_fileName init_IDE_State
update_IDE_State :: !(IDE_State -> IDE_State) -> Task !Void
update_IDE_State fun = update fun IDE_State @ const Void
update_IDE_State fun = upd fun IDE_State @ const Void
get_IDE_State :: Task IDE_State
get_IDE_State = get IDE_State
......
......@@ -2,58 +2,54 @@ module IDE
import iTasks
import iTasks.API.Extensions.Development.Codebase
import iTasks.API.Extensions.Development.CleanCode
//import iTasks.API.Extensions.Development.CleanCode
import iTasks.API.Extensions.CodeMirror, StdFile
import System.File
// for the time being one has to set the search paths in the code
cleanPath :== "C:\\Users\\rinus\\Desktop\\Clean_2.2"
idePath :== cleanPath </> "iTasks-SDK\\Examples\\IDE"
stdEnv :== cleanPath </> "Libraries\\StdEnv"
myEnv :== [idePath,stdEnv]
stdEnv :== cleanPath </> "Libraries\\StdEnv"
itaskEnv :== cleanPath </> "iTasks-SDK\\Server"
myEnv :== [idePath,itaskEnv,stdEnv]
//Start w = startEngine IDE_Dashboard w
Start w = startEngine (startWork []) w
:: IDE_Status = { openedFiles :: [(FilePath,ModuleName,Extension)]
}
startWork list
= (chooseFile myEnv ["icl","dcl"] >&> workOnFiles) <<@ (ArrangeWithSideBar 0 LeftSide 200) <<@ FullScreen
derive class iTask IDE_Status
workOnFiles :: (ReadOnlyShared (Maybe (FilePath,FilePath))) -> Task ()
workOnFiles sel
= parallel () [
(Embedded,addSelectedFile sel)
] [] <<@ ArrangeWithTabs @! ()
IDE_Status :: (Shared IDE_Status)
IDE_Status = sharedStore "IDE_Status" { openedFiles = []
}
initIDE
= get IDE_Status
>>= \status -> editModules status.openedFiles
where
addSelectedFile sel list
= watch sel >^* [OnAction (Action "/Start Editor" [ActionKey (unmodified KEY_ENTER)])
(ifValue isJust (\(Just v) -> appendTask Embedded (\_ -> (openFile v <<@ (Title (snd v)))) list))]
@? const NoValue
editModules [] = return ()
editModules [(path,name,ext):modules] = editCleanModule (path,name) ext
import iTasks.API.Extensions.CodeMirror, StdFile
openFile :: (FilePath,FilePath) -> Task String //(Editlet CodeMirror [CodeMirrorDiff])
openFile (path,fileName)
= openAndReadFile (path </> fileName)
>>- viewInformation "TEST" [ViewWith Note]
/*
>>= \content -> updateInformation fileName []
(codeMirrorEditlet { configuration = [CMLineNumbers True] // [CodeMirrorConfiguration]
, position = 0 // cursor position
, selection = Nothing //!Maybe (Int,Int)
, source = content
} [])
*/
Start w = startEngine (startWork []) w
where
openAndReadFile :: FilePath -> Task String
openAndReadFile fileName
= accWorld (myfopen fileName)
startWork list
= ( (codeBaseFromFiles myEnv >>= navigateCodebase)
>&>
workOnCode
) <<@ (ArrangeWithSideBar 0 LeftSide 200) <<@ FullScreen
workOnCode :: (ReadOnlyShared (Maybe (FilePath,FilePath))) -> Task ()
workOnCode sel
= parallel () [(Embedded,\list -> initIDE >>| addSelectedModule sel list)
] [] <<@ ArrangeWithTabs @! ()
where
myfopen fileName world
# (mbError,world) = readFile fileName world
| isError mbError = (toString (fromError mbError),world)
= (fromOk mbError,world)
addSelectedModule sel list
= watch sel >^* [ OnAction (Action "/Open .icl" [ActionKey (unmodified KEY_ENTER)])
(ifValue isJust (\(Just v) -> appendTask Embedded (\_ -> (editCleanModule v Icl <<@ (Title (snd v +++ ".icl")))) list))
, OnAction (Action "/Open .dcl" [ActionKey (unmodified KEY_ENTER)])
(ifValue isJust (\(Just v) -> appendTask Embedded (\_ -> (editCleanModule v Dcl <<@ (Title (snd v +++ ".dcl")))) list))
]
@? const NoValue
This diff is collapsed.
......@@ -96,7 +96,7 @@ where
= { html = DivTag [IdAttr (sourcearea cid), StyleAttr "display: block; position: absolute;"] []
, eventHandlers = []
, width = FlexSize
, height = ExactSize 300
, height = FlexSize //ExactSize 300
}
sourcearea id = "cm_source_" +++ id
......
......@@ -2,17 +2,3 @@ definition module iTasks.API.Extensions.Development.CleanCode
import iTasks
:: FileExtension :== !String
/**
* Given a list of absolute path names, offers a tree structure choice to select a file
* @param absolute paths of directories to search through
* @param only show files with given extensions, all files are shown if this list is empty
* @return selected file and the absolute path directory name it is found
*/
chooseFile :: [FilePath] [FileExtension] -> Task (FilePath,FilePath)
viewCleanModule :: FilePath String -> Task ()
......@@ -8,6 +8,13 @@ viewCleanModule baseDir moduleName
import System.Directory, System.File
/**
* Given a list of absolute path names, offers a tree structure choice to select a file
* @param absolute paths of directories to search through
* @param only show files with given extensions, all files are shown if this list is empty
* @return selected file and the absolute path directory name it is found
*/
chooseFile :: [FilePath] [FileExtension] -> Task (FilePath,FilePath)
chooseFile paths extensions
= accWorld (getFilesInDir paths extensions)
......
......@@ -3,20 +3,18 @@ definition module iTasks.API.Extensions.Development.Codebase
import iTasks
import System.FilePath
//A code base is simpky a list of source trees
:: CodeBase :== [SourceTree]
//A source tree is a collection of modules organized using into a hierarchy
:: SourceTree =
{ baseDir :: FilePath //A directory in the filesystem that holds the source tree
, modules :: [ModuleName]
}
:: CodeBase :== [SourceTree]
:: SourceTree :== (FilePath,[TreeNode FilePath]) // absolute path, tree of code
:: ModuleName :== String
:: Extension = Icl | Dcl
:: ModuleName :== String
derive class iTask Extension
derive class iTask SourceTree
//Scan filepaths and find all the modules on disk
codeBaseFromFiles :: [FilePath] -> Task CodeBase
//Scan a filepath and find all the modules on disk
sourceTreeFromFiles :: FilePath -> Task SourceTree
//Browse the modules in a code base and select a module
//Browse the modules in a code base and select a Clean module
navigateCodebase :: CodeBase -> Task (FilePath,ModuleName)
//Editor for Clean Source Code
editCleanModule :: (FilePath,ModuleName) Extension -> Task ()
implementation module iTasks.API.Extensions.Development.Codebase
import iTasks
import System.File, System.Directory,StdFile
import iTasks.API.Extensions.CodeMirror
derive class iTask SourceTree
derive class iTask Extension
sourceTreeFromFiles :: FilePath -> Task SourceTree
sourceTreeFromFiles baseDir = return {SourceTree|baseDir = baseDir, modules = []}
codeBaseFromFiles :: [FilePath] -> Task CodeBase
codeBaseFromFiles paths = accWorld (getFilesInDir paths ["icl"] False)
navigateCodebase :: CodeBase -> Task (FilePath,ModuleName)
navigateCodebase codebase
= enterChoice "Select a module" []
(flatten [[(baseDir,module) \\ module <- modules] \\ {SourceTree|baseDir,modules} <- codebase])
navigateCodebase codebase = navigate codebase
editCleanModule :: (FilePath,ModuleName) Extension -> Task ()
editCleanModule (path,fileName) Icl = openFile (path,fileName +++ ".icl") @! ()
editCleanModule (path,fileName) Dcl = openFile (path,fileName +++ ".dcl") @! ()
navigate tree = enterChoice [Att (Title "Select File"), Att IconEdit] [ChooseWith (ChooseFromTree (\list _ -> toChoiceTree list))] (treeToList tree [])
@? adjust
where
toChoiceTree :: [(Int,(FilePath,[FilePath],FilePath))] -> [ChoiceTree FilePath]
toChoiceTree [] = []
toChoiceTree [(i,(path,[],fileName)):next]
= [{label = fileName, icon = Nothing, value = ChoiceNode i, type = LeafNode}:toChoiceTree next]
toChoiceTree [(i,(path,[dir:dirs],fileName)):next]
= [{label = dir, icon = Nothing, value = GroupNode dir, type = CollapsedNode (toChoiceTree inDir`)}:toChoiceTree outDir]
where
(inDir,outDir) = span (\(_,(_,dirs,_)) -> if (not (isEmpty dirs)) (hd dirs == dir) False) next
inDir` = [(i,(path,dirs,fileName)):[(j,(path,tl dirs,name)) \\ (j,(path,dirs,name)) <- inDir]]
adjust (Value (path,dirs,fileName) stab)
| fileName == "" = NoValue
= Value (foldl (</>) path dirs,fileName) stab
adjust NoValue = NoValue
treeToList :: [(FilePath,[TreeNode FilePath])] [FilePath] -> [(FilePath,[FilePath],FilePath)]
treeToList [] dirs = []
treeToList [(path,[Leaf file:files]):tree] dirs = [(path,dirs,file): treeToList [(path,files)] dirs] ++ treeToList tree []
treeToList [(path,[Node dir childs :files]):tree] dirs = treeToList [(path,childs)] (dirs++[dir]) ++ treeToList [(path,files)] dirs ++ treeToList tree []
treeToList [_:tree] dirs = treeToList tree []
:: FileExtension :== String
getFilesInDir :: [FilePath] [FileExtension] !Bool !*World -> ([(FilePath,[TreeNode FilePath])],*World)
getFilesInDir [] extensions showExtension w = ([],w)
getFilesInDir [path:paths] extensions showExtension w
# (treeFiles,w) = getTree (takeDirectory path) [dropDirectory path] w
# (ntrees,w) = getFilesInDir paths extensions showExtension w
= ([(takeDirectory path,treeFiles):ntrees],w)
where
getTree absolutePath [] w = ([],w)
getTree absolutePath [fileName:fileNames] w
# absoluteFileName = absolutePath </> fileName
# (mbInfo,w) = getFileInfo absoluteFileName w
| isError mbInfo = getTree absolutePath fileNames w
| (fromOk mbInfo).directory // file is directory name
# (filesInDir,w) = getFilesInPath absoluteFileName w
# (dirNodes,w) = getTree absoluteFileName filesInDir w
# (filesNodes,w) = getTree absolutePath fileNames w
= case dirNodes of
[] -> (filesNodes,w)
_ -> ([Node fileName dirNodes:filesNodes],w)
| isEmpty extensions || isMember (snd (splitExtension fileName)) extensions
# (treeNodes,w) = getTree absolutePath fileNames w
# name = if showExtension fileName (dropExtension fileName)
= ([Leaf name:treeNodes],w)
= getTree absolutePath fileNames w
getFilesInPath :: !FilePath !*World -> ([FilePath],!*World)
getFilesInPath path w
# (mbFiles,w) = readDirectory path w
| isError mbFiles = ([],w)
= ([name \\ name <- fromOk mbFiles | name <> "." && name <> ".."],w)
readDir :: !FilePath !*World -> ([FilePath],!*World)
readDir path w
# (mbInfo,w) = getFileInfo path w
| isError mbInfo = ([],w)
| (fromOk mbInfo).directory = getFilesInPath path w
openFile (path,fileName)
= openAndReadFile (path </> fileName)
>>= \content -> updateInformation fileName []
(codeMirrorEditlet { configuration = [ CMLineNumbers True
, CMMode "Haskell"
, CMDragDrop True
] // [CodeMirrorConfiguration]
, position = 0 // cursor position
, selection = Nothing //!Maybe (Int,Int)
, source = content
} [])
where
openAndReadFile :: FilePath -> Task String
openAndReadFile fileName
= accWorld (myfopen fileName)
where
myfopen fileName world
# (mbError,world) = readFile fileName world
| isError mbError = (toString (fromError mbError),world)
= (fromOk mbError,world)
......@@ -39,9 +39,32 @@ t_StdEnv
= CompileSync
| CompileAsync !Int
| CompilePers
import Directory, StdBool
import System.Directory, StdBool
//import dodebug
getEnvironments :: !String !String !*env -> *([Target],*env) | FileSystem, FileEnv env
getEnvironments stup envpath env
# ((ok,path),env) = pd_StringToPath envpath env
# ((err,entries),env) = getDirectoryContents path env
| err <> NoDirError = (map (fixAppPaths stup) emptyTargets,env)
# eentries = [fileName \\ {fileName} <- entries | size fileName > 4 && fileName%(size fileName - 4,size fileName) == ".env"]
// # eentries = [fileName%(size fileName - 4,size fileName) \\ {fileName} <- entries ]//| size fileName > 4 && fileName%(size fileName - 4,size fileName) == ".env"]
| isEmpty eentries = openEnvironments stup (MakeFullPathname envpath EnvsFileName) env
# (ts,env) = seqSt eentries env
= case ts of
[] -> (map (fixAppPaths stup) emptyTargets,env)
ts -> (map (fixAppPaths stup) ts,env)
where
seqSt [] e = ([],e)
seqSt [e:es] env
# ((t,ok,err),env) = openEnvironment (MakeFullPathname envpath e) env
# env = case ok of
True -> env
// _ -> trace_n` ("Error",err) env
_ -> env
# (ts,env) = seqSt es env
= (t++ts,env)
/*
getEnvironments :: !String !String !*env -> *([Target],*env) | FileSystem, FileEnv env
getEnvironments stup envpath env
# ((ok,path),env) = pd_StringToPath envpath env
# ((err,entries),env) = getDirectoryContents path env
......@@ -64,6 +87,7 @@ where
# (ts,env) = seqSt es env
= (t++ts,env)
*/
openEnvironments :: !String !String !*env -> *([Target],*env) | FileEnv env
openEnvironments stup envpath env
// # (stup,env) = accFiles GetFullApplicationPath env
......
......@@ -11,8 +11,37 @@ IclMod :== False
:: Def_and_Imp :== Bool
:: Project
:: InfList :== List InfListItem
:: InfListItem =
{ mn :: !Modulename // module name
, info :: !ModInfo // module info
, src :: !Bool // src up to date?
, abc :: !Bool // abc up to date?
}
:: Project =
{ saved :: !Bool
, exec :: !Bool // exe linked ok?
, inflist :: !InfList // list with constituent modules
, codegenopt :: !CodeGenOptions // code generator options
, code_gen_options_unchanged :: !Bool
, applicationopt :: !ApplicationOptions // application options
, linkOptions :: !LinkOptions
, prjpaths :: !List String // project paths
, staticLibInfo :: !StaticLibInfo
, target :: !String // environment
, dynamic_info :: !ProjectDynamicInfo
, relative_root_directory :: !String // string of '.'s, relative to .prj file
, root_directory :: !String
, execpath :: !String // move to app_opts
, prec :: !Maybe String // " (precompile command)
, posl :: !Maybe String // " (postlink command)
}
SaveProjectFile ::
!String // path to projectfile
!Project // the project
......
......@@ -12,7 +12,16 @@ import UtilDate
:: ModuleDirAndName = {mdn_dir :: !{#Char}, mdn_name :: !{#Char}}
:: Processor //= CurrentProcessor | MC68000 | MC68020 | MC68020_and_68881
:: Processor
= CurrentProcessor
| MC68000
| MC68020
| MC68020_and_68881
| PowerPC_Classic
| PowerPC_Carbon
| PowerPC_MachO
| I386
DefaultProcessor :: Processor
PlatformProcessors :: [Processor]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment