1. Thibaut Colar
  2. camembert

Commits

Thibaut Colar  committed ac26acc

edit/reload config

  • Participants
  • Parent commits 4a93a7f
  • Branches default

Comments (0)

Files changed (4)

File src/brie/fan/Commands.fan

View file
   const Cmd findInSpace := FindInSpaceCmd()
   const Cmd goto        := GotoCmd()
   const Cmd build       := BuildCmd()
+  const Cmd editConfig  := EditConfigCmd()
+  const Cmd reloadConfig:= ReloadConfigCmd()
 }
 
 **************************************************************************
     }
     return null
   }
+  
+  
 }
 
+internal const class EditConfigCmd : Cmd
+{
+  override const Str name := "Edit config"
+  override Void invoke(Event event)
+  {
+    frame.goto(Item.makeFile(Options.file))
+  }
+}
 
+internal const class ReloadConfigCmd : Cmd
+{
+  override const Str name := "Reload Config"
+  override const Key? key := Key("Shift+Ctrl+R")
+  override Void invoke(Event event)
+  {
+    Sys.reload
+  }
+}
+
+

File src/brie/fan/Frame.fan

View file
         MenuItem{ text= "Build"; command = sys.commands.build.asCommand},
         MenuItem{ text= "Quit process"; command = sys.commands.esc.asCommand},
       },
+      Menu {
+        text = "Options"
+        MenuItem{ text= "Edit Config"; command = sys.commands.editConfig.asCommand},
+        MenuItem{ text= "Reload Config"; command = sys.commands.reloadConfig.asCommand},
+      },
     }
 
     // eventing
     onKeyDown.add |e| { trapKeyDown(e) }
     onDrop = |data| { doDrop(data) }
 
-    // build UI
+   // build UI
     this.spaceBar = SpaceBar(this)
     this.spacePane = ContentPane()
     this.statusBar = StatusBar(this)
       }
       it.bottom = statusBar
     }
-
+ 
     // load session and home space
     loadSession
     curSpace = spaces.first
     load(curSpace, 0, null)
   }
 
+  Void update(Sys sys)
+  {
+    this.sys = sys
+    spaces[0] = HomeSpace(sys)
+    select(spaces[0])
+  }
+
   //////////////////////////////////////////////////////////////////////////
   // Access
   //////////////////////////////////////////////////////////////////////////
 
   ** System services
-  const Sys sys
+  Sys sys
 
   ** Current space
   Space curSpace

File src/brie/fan/Options.fan

View file
 @Serializable
 const class Options
 {
+  static const File file := Env.cur.workDir + `etc/camenbert/options.fog`
+  
   ** Reload options
   static Options load()
   {
-    f := Env.cur.workDir + `etc/camenbert/options.fog`
-    try
-      if (f.exists) return f.readObj
-    catch (Err e)
-      echo("ERROR: Cannot load $f\n  $e")
-    return Options()
+    Options? options
+    if (file.exists) 
+    {
+      try
+        options = file.readObj
+      catch (Err e)
+        echo("ERROR: Cannot load $file\n  $e")
+    }
+    else
+    {
+      options = Options()
+      options.save()
+    }  
+    return options
   }
 
   ** Default constructor with it-block
   new make(|This|? f := null)
   {
     if (f != null) f(this)
-    fanHome = fanHomeUri.toFile.normalize
+      fanHome = fanHomeUri.toFile.normalize
+  }
+  
+  Void save()
+  {
+    file.writeObj(this)
   }
 
   ** Directories to crawl looking for for pod, file navigation
-  const Uri[] indexDirs := [Env.cur.homeDir.uri + `etc/camembert/`]
+  const Uri[] indexDirs := [file.uri]
 
   ** Home directory to use for fan/build commands
   const Uri fanHomeUri := Env.cur.homeDir.uri
 
   ** File of `fanHomeUri`
+  @Transient
   const File fanHome
   
   ** Name of theme to use (saved in etc/camembert/theme-name.fog)

File src/brie/fan/Sys.fan

View file
 
   ** Logger
   const Log log := Log.get("camembert")
+  
+  override Void onStop()
+  {
+    index.cache.pool.stop
+    index.crawler.pool.stop
+    Actor.sleep(1sec)
+    index.cache.pool.kill
+    index.crawler.pool.kill
+  }
+  
+  static Void reload()
+  {
+    sys := Service.find(Sys#) as Sys
+ sys.uninstall
+    
+    sys = Sys()
+    sys.install  
+    sys.frame.update(sys)  
+  } 
 }