]> git.lizzy.rs Git - micro.git/commitdiff
Switched to +LINE,COL
authorZack Scholl <zack.scholl@gmail.com>
Wed, 31 Aug 2016 14:10:54 +0000 (10:10 -0400)
committerZack Scholl <zack.scholl@gmail.com>
Wed, 31 Aug 2016 14:10:54 +0000 (10:10 -0400)
Previously the flag was parsed for `-cursor LINE,COL`

However, emacs and nano both us `+LINE,COL` and this also makes
it easier to ignore the `+` as a filename.

cmd/micro/buffer.go
cmd/micro/micro.go

index 4a77963d4224aa55bfdd4b1404d5039e6f86b7e8..2046c72971f35365b7a38e46ceab8faeed65f558 100644 (file)
@@ -89,9 +89,9 @@ func NewBuffer(txt []byte, path string) *Buffer {
        // Put the cursor at the first spot
        cursorStartX := 0
        cursorStartY := 0
-       // If -cursor LINE,COL was passed, use start position LINE,COL
-       if len(*flagLineColumn) > 0 {
-               positions := strings.Split(*flagLineColumn, ",")
+       // If +LINE,COL was passed, use start position LINE,COL
+       if len(flagLineColumn) > 0 {
+               positions := strings.Split(flagLineColumn[1:], ",")
                if len(positions) == 2 {
                        lineNum, errPos1 := strconv.Atoi(positions[0])
                        colNum, errPos2 := strconv.Atoi(positions[1])
index dac8df8dc7d370fbbc2342b58fb26c91f3795bac..f19afdf6c5aadd388b02b14232bd8f82dd54cd1c 100644 (file)
@@ -88,9 +88,9 @@ func LoadInput() []*Buffer {
                for i := 1; i < len(os.Args); i++ {
                        filename = os.Args[i]
 
-                       // Need to skip arguments that are not filenames
-                       if filename == "-cursor" {
-                               i++ // also skip the LINE,COL for -cursor
+                       // Check if +LINE,COL was passed, and send this to the flagLineColumn
+                       if string(filename[0]) == "+" && strings.Contains(filename, ",") {
+                               flagLineColumn = filename
                                continue
                        }
 
@@ -204,8 +204,8 @@ func RedrawAll() {
 // Passing -version as a flag will have micro print out the version number
 var flagVersion = flag.Bool("version", false, "Show the version number")
 
-// Passing -cursor LINE,COL will start the cursor at position LINE,COL
-var flagLineColumn = flag.String("cursor", "", "Start the cursor at position `LINE,COL`")
+// Passing +LINE,COL will start the cursor at position LINE,COL
+var flagLineColumn = ""
 
 func main() {
        flag.Parse()