Implement buffer opening at a location

This commit is contained in:
Zachary Yedidia
2019-06-15 18:22:36 -04:00
parent aa774164a7
commit aa305c2676
2 changed files with 45 additions and 28 deletions

View File

@@ -6,7 +6,6 @@ import (
"io/ioutil"
"os"
"sort"
"strings"
"github.com/go-errors/errors"
isatty "github.com/mattn/go-isatty"
@@ -25,7 +24,6 @@ var (
// Command line flags
flagVersion = flag.Bool("version", false, "Show the version number and information")
flagStartPos = flag.String("startpos", "", "LINE,COL to start the cursor at when opening a buffer.")
flagConfigDir = flag.String("config-dir", "", "Specify a custom location for the configuration directory")
flagOptions = flag.Bool("options", false, "Show all option help")
optionFlags map[string]*string
@@ -36,8 +34,7 @@ func InitFlags() {
fmt.Println("Usage: micro [OPTIONS] [FILE]...")
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("[FILE]: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")
@@ -109,16 +106,6 @@ func LoadInput() []*buffer.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 := buffer.NewBufferFromFile(args[i], buffer.BTDefault)
if err != nil {
screen.TermMessage(err)