Commits

Anonymous committed 79594d1

B2 prints fullpath

Comments (0)

Files changed (1)

 			doDotDot()
 			continue
 		}
+		if word[0] == 'X' {
+			onExec(word[1:len(word)])
+			continue
+		}
 		onLook(word)
 	}
 }
 	return printDirContents(root, 0)
 }
 
-func doDotDot() {
-	// blank the window
-	err := w.Addr("0,$")
-	if err != nil {
-		fmt.Fprintf(os.Stderr, err.String())
-		os.Exit(1)
-	}
-	w.Write("data", []byte(""))
-	
-	// restart from ..
-	root = path.Clean(root + "/../")
-	title := "xplor-" + root
-	w.Name(title)
-	err = printDirContents(root, 0)
-	if err != nil {
-		fmt.Fprintf(os.Stderr, err.String())
-		os.Exit(1)
-	}
-}
-
 func printDirContents(path string, depth int) os.Error {
 	currentDir, err := os.Open(path, os.O_RDONLY, 0644)
 	if err != nil {
 	}
 }
 
+func doDotDot() {
+	// blank the window
+	err := w.Addr("0,$")
+	if err != nil {
+		fmt.Fprintf(os.Stderr, err.String())
+		os.Exit(1)
+	}
+	w.Write("data", []byte(""))
+	
+	// restart from ..
+	root = path.Clean(root + "/../")
+	title := "xplor-" + root
+	w.Name(title)
+	err = printDirContents(root, 0)
+	if err != nil {
+		fmt.Fprintf(os.Stderr, err.String())
+		os.Exit(1)
+	}
+}
+
+// on a B2 click event we print the fullpath of the file to Stdout.
+// This can come in handy for paths with spaces in it, because the
+// plumber will fail to open them.  Printing it to Stdout allows us to do
+// whatever we want with it when that happens.
+// Also usefull with a dir path: once printed to stdout, a B3 click on
+// the path to open it the "classic" acme way.
+func onExec(charaddr string) {
+	// reconstruct full path and print it to Stdout
+	addr := "#" + charaddr + "+1-"
+	b, err := readLine(addr)
+	if err != nil {
+		fmt.Fprintf(os.Stderr, err.String())
+		return
+	}
+	depth, line := getDepth(b)
+	fullpath := path.Join(root, getParents(charaddr, depth, 1), line)
+	fmt.Fprintf(os.Stdout, fullpath)
+}
+
 func events() <-chan string {
 	c := make(chan string, 10)
 	go func() {
 		for e := range w.EventChan() {
 			switch e.C2 {
-			case 'x', 'X': // execute
+			case 'x': // execute
 				switch string(e.Text) {
 				case "Del": 
 					w.Ctl("delete")
 				default:
 					w.WriteEvent(e)
 				}
+			case 'X':
+				msg := "X" + fmt.Sprint(e.OrigQ0)
+				c <- msg
 			case 'l': // in the tag, let the plumber deal with it
 				w.WriteEvent(e)
 			case 'L': // look
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.