Thibaut Colar avatar Thibaut Colar committed 5c949eb

contextual new file command on nav items (files & folders)

Comments (0)

Files changed (3)

src/brie/fan/command/FileCommands.fan

   override const Str name := "New File"
   override Void invoke(Event event)
   {
+    newFile(frame.curFile?.parent, frame)
+  }
+
+  Void newFile(File? dir, Frame frame)
+  {
     clazz := File(`${Options.standard.parent}/class.tpl`)
     if(!clazz.exists)
     {
     path := Text
     {
       prefCols = 60
-      text = (frame.curFile?.parent?.osPath ?: Env.cur.workDir.osPath) + "/"
+      text = (dir?.osPath ?: Env.cur.workDir.osPath) + "/"
     }
 
     combo := Combo

src/brie/fan/widget/Item.fan

   Menu? popup(Frame frame)
   {
     if (file == null) return null
-    FindCmd findCmd := frame.sys.commands.find
+    // File menus
     return Menu
     {
       MenuItem
       {
         it.text = "Find in \"$dis\""
-        it.onAction.add |e| { findCmd.find(file) }
+        it.onAction.add |e|
+          { (frame.sys.commands.find as FindCmd).find(file) }
+      },
+      MenuItem
+      {
+        dir := file.isDir ? file : file.parent
+        it.text = "New file in \"$dir.name\""
+        it.onAction.add |e|
+          { (frame.sys.commands.newFile as NewFileCmd).newFile(dir, frame) }
       },
     }
   }
 delete file/folder
 rename file/folder (& move)
-duplicate file
 
 find/replace .. local / global
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.