]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/micro.go
Merge pull request #1125 from nabeelomer/master
[micro.git] / cmd / micro / micro.go
index cf7dfea551472f9cca4cefe0d33bfa0ddb613efc..dc35ed2708f853b0a9c45bbc1b076200fe067892 100644 (file)
@@ -7,6 +7,7 @@ import (
        "os"
        "path/filepath"
        "runtime"
+       "strings"
        "time"
 
        "github.com/go-errors/errors"
@@ -95,6 +96,16 @@ func LoadInput() []*Buffer {
                // Option 1
                // We go through each file and load it
                for i := 0; i < len(args); i++ {
+                       if strings.HasPrefix(args[i], "+") {
+                               if strings.Contains(args[i], ":") {
+                                       split := strings.Split(args[i], ":")
+                                       *flagStartPos = split[0][1:] + "," + split[1]
+                               } else {
+                                       *flagStartPos = args[i][1:] + ",0"
+                               }
+                               continue
+                       }
+
                        buf, err := NewBufferFromFile(args[i])
                        if err != nil {
                                TermMessage(err)
@@ -225,7 +236,7 @@ func RedrawAll() {
                }
        }
 
-       for _, v := range tabs[curTab].views {
+       for _, v := range tabs[curTab].Views {
                v.Display()
        }
        DisplayTabs()
@@ -257,7 +268,7 @@ func LoadAll() {
        InitColorscheme()
 
        for _, tab := range tabs {
-               for _, v := range tab.views {
+               for _, v := range tab.Views {
                        v.Buf.UpdateRules()
                }
        }
@@ -275,7 +286,9 @@ func main() {
                fmt.Println("-config-dir dir")
                fmt.Println("    \tSpecify a custom location for the configuration directory")
                fmt.Println("-startpos LINE,COL")
+               fmt.Println("+LINE:COL")
                fmt.Println("    \tSpecify a line and column to start the cursor at when opening a buffer")
+               fmt.Println("    \tThis can also be done by opening file:LINE:COL")
                fmt.Println("-options")
                fmt.Println("    \tShow all option help")
                fmt.Println("-version")
@@ -367,7 +380,7 @@ func main() {
                tab.SetNum(len(tabs))
                tabs = append(tabs, tab)
                for _, t := range tabs {
-                       for _, v := range t.views {
+                       for _, v := range t.Views {
                                v.Center(false)
                        }
 
@@ -446,7 +459,7 @@ func main() {
        LoadPlugins()
 
        for _, t := range tabs {
-               for _, v := range t.views {
+               for _, v := range t.Views {
                        GlobalPluginCall("onViewOpen", v)
                        GlobalPluginCall("onBufferOpen", v.Buf)
                }
@@ -492,7 +505,7 @@ func main() {
                case <-updateterm:
                        continue
                case vnum := <-closeterm:
-                       tabs[curTab].views[vnum].CloseTerminal()
+                       tabs[curTab].Views[vnum].CloseTerminal()
                case event = <-events:
                }
 
@@ -522,7 +535,7 @@ func main() {
                                                if CurView().mouseReleased {
                                                        // We loop through each view in the current tab and make sure the current view
                                                        // is the one being clicked in
-                                                       for _, v := range tabs[curTab].views {
+                                                       for _, v := range tabs[curTab].Views {
                                                                if x >= v.x && x < v.x+v.Width && y >= v.y && y < v.y+v.Height {
                                                                        tabs[curTab].CurView = v.Num
                                                                }
@@ -531,9 +544,9 @@ func main() {
                                        } else if e.Buttons() == tcell.WheelUp || e.Buttons() == tcell.WheelDown {
                                                var view *View
                                                x, y := e.Position()
-                                               for _, v := range tabs[curTab].views {
+                                               for _, v := range tabs[curTab].Views {
                                                        if x >= v.x && x < v.x+v.Width && y >= v.y && y < v.y+v.Height {
-                                                               view = tabs[curTab].views[v.Num]
+                                                               view = tabs[curTab].Views[v.Num]
                                                        }
                                                }
                                                if view != nil {